Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

refactor(settings): consistency pass — header-less settings_section + guides (#2279)

Guillem Arias Fauste8736c7c27eac
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 4b89c3f8d5..7d006ad587 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -45,7 +45,7 @@ module SettingsHelper
}
end
- def settings_section(title:, subtitle: nil, collapsible: false, open: true, auto_open_param: nil, status: nil, meta: nil, actions: nil, badge: nil, &block)
+ def settings_section(title: nil, subtitle: nil, collapsible: false, open: true, auto_open_param: nil, status: nil, meta: nil, actions: nil, badge: nil, &block)
content = capture(&block)
render partial: "settings/section", locals: { title: title, subtitle: subtitle, content: content, collapsible: collapsible, open: open, auto_open_param: auto_open_param, status: status, meta: meta, actions: actions, badge: badge }
end
diff --git a/app/views/family_exports/index.html.erb b/app/views/family_exports/index.html.erb
index 9299b41315..266d8e96a0 100644
--- a/app/views/family_exports/index.html.erb
+++ b/app/views/family_exports/index.html.erb
@@ -1,8 +1,7 @@
<%= content_for :page_title, t(".title") %>
-<%= settings_section title: t(".title") do %>
- <div class="space-y-4">
- <% has_processing = @exports.any? { |e| e.pending? || e.processing? } %>
+<%= settings_section do %>
+ <% has_processing = @exports.any? { |e| e.pending? || e.processing? } %>
<%= turbo_frame_tag "family_exports",
data: has_processing ? {
controller: "polling",
@@ -18,7 +17,7 @@
<p><%= @pagy.count %></p>
</div>
- <div class="bg-container rounded-lg shadow-border-xs overflow-x-auto">
+ <div class="overflow-x-auto">
<% if @exports.any? %>
<table class="w-full overflow-x-auto">
<thead>
@@ -135,5 +134,4 @@
<%= icon("plus") %>
<%= t(".new") %>
<% end %>
- </div>
<% end %>
diff --git a/app/views/settings/_section.html.erb b/app/views/settings/_section.html.erb
index 14ef45a61b..cf29aeaff3 100644
--- a/app/views/settings/_section.html.erb
+++ b/app/views/settings/_section.html.erb
@@ -36,12 +36,14 @@
<% end %>
<% else %>
<section class="bg-container shadow-border-xs rounded-xl p-4 space-y-4">
- <div>
- <h2 class="text-lg font-medium text-primary"><%= title %></h2>
- <% if subtitle.present? %>
- <p class="text-secondary text-sm mt-1"><%= subtitle %></p>
- <% end %>
- </div>
+ <% if title.present? %>
+ <div>
+ <h2 class="text-lg font-medium text-primary"><%= title %></h2>
+ <% if subtitle.present? %>
+ <p class="text-secondary text-sm mt-1"><%= subtitle %></p>
+ <% end %>
+ </div>
+ <% end %>
<div class="space-y-4">
<%= content %>
</div>
diff --git a/app/views/settings/appearances/show.html.erb b/app/views/settings/appearances/show.html.erb
index f22096236c..88646f8a11 100644
--- a/app/views/settings/appearances/show.html.erb
+++ b/app/views/settings/appearances/show.html.erb
@@ -35,7 +35,7 @@
data: { controller: "auto-submit-form" } do |f| %>
<div class="flex cursor-pointer items-center gap-4 justify-between">
<div class="text-sm space-y-1">
- <h4 class="text-primary"><%= t(".dashboard_two_column_title") %></h4>
+ <p class="text-primary font-medium"><%= t(".dashboard_two_column_title") %></p>
<p class="text-secondary"><%= t(".dashboard_two_column_description") %></p>
</div>
<%= render DS::Toggle.new(
@@ -56,7 +56,7 @@
data: { controller: "auto-submit-form" } do |f| %>
<div class="flex cursor-pointer items-center gap-4 justify-between">
<div class="text-sm space-y-1">
- <h4 class="text-primary"><%= t(".split_grouped_title") %></h4>
+ <p class="text-primary font-medium"><%= t(".split_grouped_title") %></p>
<p class="text-secondary"><%= t(".split_grouped_description") %></p>
</div>
<%= render DS::Toggle.new(
diff --git a/app/views/settings/guides/show.html.erb b/app/views/settings/guides/show.html.erb
index c6e08bbb58..12d07f405d 100644
--- a/app/views/settings/guides/show.html.erb
+++ b/app/views/settings/guides/show.html.erb
@@ -1,5 +1,7 @@
-<%= content_for :page_title, "Guides" %>
+<%= content_for :page_title, t(".page_title") %>
-<div class="bg-container rounded-xl shadow-border-xs p-4 prose prose-sm max-w-none">
- <%= @guide_content.html_safe %>
-</div>
+<%= settings_section do %>
+ <div class="prose prose-sm max-w-none">
+ <%= @guide_content.html_safe %>
+ </div>
+<% end %>
diff --git a/app/views/settings/payments/show.html.erb b/app/views/settings/payments/show.html.erb
index 0768440cd7..dcddbbb071 100644
--- a/app/views/settings/payments/show.html.erb
+++ b/app/views/settings/payments/show.html.erb
@@ -2,7 +2,7 @@
<%= settings_section title: t(".subscription_title"), subtitle: t(".subscription_subtitle") do %>
<div class="space-y-4">
- <div class="p-3 shadow-border-xs bg-container rounded-lg flex justify-between items-center">
+ <div class="p-4 bg-container-inset rounded-lg flex justify-between items-center">
<div class="flex items-center gap-3">
<%= render DS::FilledIcon.new(
icon: "gem",
diff --git a/app/views/settings/preferences/show.html.erb b/app/views/settings/preferences/show.html.erb
index 80b767bd1f..0f6fbab3ef 100644
--- a/app/views/settings/preferences/show.html.erb
+++ b/app/views/settings/preferences/show.html.erb
@@ -29,9 +29,7 @@
{ label: t(".month_start_day"), hint: t(".month_start_day_hint") },
{ data: { auto_submit_form_target: "auto" } } %>
<% if @user.family.uses_custom_month_start? %>
- <div class="text-sm text-warning bg-warning/10 p-3 rounded-lg">
- <%= t(".month_start_day_warning") %>
- </div>
+ <%= render DS::Alert.new(message: t(".month_start_day_warning"), variant: :warning) %>
<% end %>
<p class="text-xs italic pl-2 text-secondary"><%= t(".translations_notice") %></p>
<% end %>
@@ -162,7 +160,7 @@
<div class="flex items-center gap-2">
<span class="text-sm font-medium text-primary"><%= currency.iso_code %></span>
<% if base_currency %>
- <span class="inline-flex items-center rounded-full bg-surface px-2 py-0.5 text-[11px] font-medium text-secondary">
+ <span class="inline-flex items-center rounded-full bg-surface px-2 py-0.5 text-xs font-medium text-secondary">
<%= t(".base_currency_badge") %>
</span>
<% end %>
@@ -207,7 +205,7 @@
toggle row is the entire surface. Posts directly to
settings#preferences#update via the Settings::PreferencesController,
matching the auto-submit pattern used on the Appearance page. %>
-<section class="bg-container shadow-border-xs rounded-xl p-4">
+<%= settings_section do %>
<%= form_with url: settings_preferences_path, method: :patch,
data: { controller: "auto-submit-form" } do |f| %>
<%# Wrapping the row in <label for=…> makes the title + description
@@ -215,7 +213,7 @@
affordance on the container is honest. %>
<label for="user_preview_features_enabled" class="flex cursor-pointer items-center gap-4 justify-between">
<div class="text-sm space-y-1">
- <h4 class="text-primary"><%= t(".preview.title") %></h4>
+ <p class="text-primary font-medium"><%= t(".preview.title") %></p>
<p class="text-secondary"><%= t(".preview.description") %></p>
</div>
<%= render DS::Toggle.new(
@@ -226,4 +224,4 @@
) %>
</label>
<% end %>
-</section>
+<% end %>
diff --git a/app/views/settings/profiles/show.html.erb b/app/views/settings/profiles/show.html.erb
index 5c431449d0..6a08fd33c3 100644
--- a/app/views/settings/profiles/show.html.erb
+++ b/app/views/settings/profiles/show.html.erb
@@ -9,7 +9,9 @@
<% if @user.unconfirmed_email.present? %>
<p class="mt-2 text-sm text-secondary">
- You have requested to change your email to <%= @user.unconfirmed_email %>. Please go to your email and confirm for the change to take effect. If you haven't received the email, please check your spam folder, or <%= link_to "request a new confirmation email", resend_confirmation_email_user_path(@user), class: "hover:underline text-secondary" %>.
+ <%= t(".unconfirmed_email_notice_html",
+ email: @user.unconfirmed_email,
+ resend_link: link_to(t(".resend_confirmation_link"), resend_confirmation_email_user_path(@user), class: "hover:underline text-secondary")) %>
</p>
<% end %>
@@ -49,9 +51,7 @@
<%= render "settings/user_avatar", avatar_url: user.profile_image&.variant(:small)&.url, initials: user.initials %>
</div>
<p class="text-primary font-medium text-sm"><%= user.display_name %></p>
- <div class="rounded-md bg-surface px-1.5 py-0.5">
- <p class="uppercase text-secondary font-medium text-xs"><%= t("users.roles.#{user.role}", default: user.role.humanize) %></p>
- </div>
+ <%= render DS::Pill.new(label: t("users.roles.#{user.role}", default: user.role.humanize), tone: :gray, marker: false, size: :sm) %>
<% if Current.user.admin? && user != Current.user %>
<div class="ml-auto">
<%= render DS::Button.new(
@@ -67,16 +67,14 @@
<% end %>
<% if @pending_invitations.any? %>
<% @pending_invitations.each do |invitation| %>
- <div class="flex gap-2 items-center justify-between bg-container p-4 border border-alpha-black-25 rounded-lg">
+ <div class="flex gap-2 items-center justify-between bg-container p-4 shadow-border-xs rounded-lg">
<div class="flex gap-2 items-center">
<div class="w-9 h-9 shrink-0">
<div class="text-inverse w-full h-full bg-surface-inset rounded-full flex items-center justify-center text-lg uppercase"><%= invitation.email[0] %></div>
</div>
- <div class="flex">
+ <div class="flex items-center gap-2">
<p class="text-primary font-medium text-sm"><%= invitation.email %></p>
- <div class="rounded-md bg-surface px-1.5 py-0.5">
- <p class="uppercase text-secondary font-medium text-xs"><%= t(".pending") %></p>
- </div>
+ <%= render DS::Pill.new(label: t(".pending"), tone: :gray, marker: false, size: :sm) %>
</div>
</div>
<div class="flex items-center gap-4">
diff --git a/config/locales/views/settings/en.yml b/config/locales/views/settings/en.yml
index 131994efa9..4e82fee8ed 100644
--- a/config/locales/views/settings/en.yml
+++ b/config/locales/views/settings/en.yml
@@ -207,7 +207,9 @@ en:
profile_title: Personal
remove_invitation: Remove Invitation
remove_member: Remove Member
+ resend_confirmation_link: request a new confirmation email
save: Save
+ unconfirmed_email_notice_html: You have requested to change your email to %{email}. Please go to your email and confirm for the change to take effect. If you haven't received the email, please check your spam folder, or %{resend_link}.
securities:
show:
page_title: Security
diff --git a/config/locales/views/settings/guides/en.yml b/config/locales/views/settings/guides/en.yml
new file mode 100644
index 0000000000..6df7c1929a
--- /dev/null
+++ b/config/locales/views/settings/guides/en.yml
@@ -0,0 +1,6 @@
+---
+en:
+ settings:
+ guides:
+ show:
+ page_title: Guides