Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

feat(design-system): DS::Disclosure :card_inset variant + migrate ibkr_panel + settings/_section (#1715 §6) (#1857)

Guillem Arias Fauste834ec19fdc45
diff --git a/app/components/DS/disclosure.html.erb b/app/components/DS/disclosure.html.erb
index 6923183b54..876dc054c0 100644
--- a/app/components/DS/disclosure.html.erb
+++ b/app/components/DS/disclosure.html.erb
@@ -1,4 +1,4 @@
-<details class="<%= details_classes %>" <%= "open" if open %>>
+<%= tag.details class: details_classes, open: open, **details_opts do %>
<%= tag.summary class: summary_classes do %>
<% if summary_content? %>
<%# `<summary>` is `display: list-item`, so a flex inner div would
@@ -28,4 +28,4 @@
<div class="mt-2">
<%= content %>
</div>
-</details>
+<% end %>
diff --git a/app/components/DS/disclosure.rb b/app/components/DS/disclosure.rb
index a634b2143b..ad4bdb37e5 100644
--- a/app/components/DS/disclosure.rb
+++ b/app/components/DS/disclosure.rb
@@ -1,7 +1,7 @@
class DS::Disclosure < DesignSystemComponent
renders_one :summary_content
- VARIANTS = %i[default card].freeze
+ VARIANTS = %i[default card card_inset].freeze
attr_reader :title, :align, :open, :variant, :opts
@@ -12,8 +12,15 @@ class DS::Disclosure < DesignSystemComponent
# rounded-xl` card; the summary inherits the container (no own bg).
# Use for provider-item rows (binance, lunchflow, plaid, etc.) where
# each card is the surface and the summary is custom rich content.
- # Callers in `:card` mode should pass their own `summary_content`
- # slot; the built-in title rendering assumes the `:default` shape.
+ #
+ # `:card_inset` — `<details>` is `bg-surface-inset rounded-xl` (no
+ # shadow). Use for inset sub-panels inside a parent card surface
+ # (e.g. the IBKR flex-query "report details" panel embedded inside
+ # the IBKR settings flow). Same summary contract as `:card`.
+ #
+ # In both card variants, callers should pass their own
+ # `summary_content` slot; the built-in title rendering assumes the
+ # `:default` shape.
def initialize(title: nil, align: "right", open: false, variant: :default, **opts)
@title = title
@align = align.to_sym
@@ -25,18 +32,29 @@ class DS::Disclosure < DesignSystemComponent
end
def details_classes
- case variant
+ base = case variant
when :card
"group bg-container p-4 shadow-border-xs rounded-xl"
+ when :card_inset
+ "group bg-surface-inset rounded-xl p-4"
else
"group"
end
+
+ class_names(base, opts[:class])
+ end
+
+ # `opts` minus the `:class` key, since `details_classes` merges that
+ # separately to avoid duplicate-keyword collisions when forwarding to
+ # `tag.details`.
+ def details_opts
+ opts.except(:class)
end
def summary_classes
case variant
- when :card
- # Card variant: no bg on summary — the parent details *is* the
+ when :card, :card_inset
+ # Card variants: no bg on summary — the parent details *is* the
# surface. Keep cursor + focus-visible ring + flex baseline.
# Ring token matches `settings/provider_card.html.erb` (the
# established focus pattern on container cards).
diff --git a/app/views/enable_banking_items/_enable_banking_item.html.erb b/app/views/enable_banking_items/_enable_banking_item.html.erb
index a63eaa478c..2e3af279ba 100644
--- a/app/views/enable_banking_items/_enable_banking_item.html.erb
+++ b/app/views/enable_banking_items/_enable_banking_item.html.erb
@@ -55,7 +55,7 @@
<% if enable_banking_item.requires_update? %>
<%= button_to reauthorize_enable_banking_item_path(enable_banking_item),
method: :post,
- class: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-lg text-white bg-warning hover:opacity-90 transition-colors",
+ class: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-lg text-inverse bg-warning hover:opacity-90 transition-colors",
data: { turbo: false } do %>
<%= icon "refresh-cw", size: "sm" %>
<%= t(".update") %>
diff --git a/app/views/indexa_capital_items/_indexa_capital_item.html.erb b/app/views/indexa_capital_items/_indexa_capital_item.html.erb
index e6535d76a4..d03c2ffb1a 100644
--- a/app/views/indexa_capital_items/_indexa_capital_item.html.erb
+++ b/app/views/indexa_capital_items/_indexa_capital_item.html.erb
@@ -9,7 +9,7 @@
<div class="flex items-center gap-2">
<%= icon "chevron-right", class: "group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-150" %>
- <div class="flex items-center justify-center h-8 w-8 bg-gray-tint-10 rounded-full">
+ <div class="flex items-center justify-center h-8 w-8 bg-container-inset rounded-full">
<div class="flex items-center justify-center">
<%= tag.p indexa_capital_item.name.first.upcase, class: "text-primary text-xs font-medium" %>
</div>
diff --git a/app/views/plaid_items/_plaid_item.html.erb b/app/views/plaid_items/_plaid_item.html.erb
index 96e621d643..36408d89e7 100644
--- a/app/views/plaid_items/_plaid_item.html.erb
+++ b/app/views/plaid_items/_plaid_item.html.erb
@@ -21,7 +21,7 @@
<div class="flex items-center gap-2">
<%= tag.p plaid_item.name, class: "font-medium text-primary" %>
<% if plaid_item.scheduled_for_deletion? %>
- <p class="text-destructive text-sm animate-pulse">(deletion in progress...)</p>
+ <p class="text-destructive text-sm animate-pulse"><%= t(".deletion_in_progress") %></p>
<% end %>
</div>
<% if plaid_item.syncing? %>
diff --git a/app/views/settings/_section.html.erb b/app/views/settings/_section.html.erb
index 0c05833e8a..14ef45a61b 100644
--- a/app/views/settings/_section.html.erb
+++ b/app/views/settings/_section.html.erb
@@ -1,35 +1,39 @@
<%# locals: (title:, subtitle: nil, content:, collapsible: false, open: true, auto_open_param: nil, status: nil, meta: nil, actions: nil, badge: nil) %>
<% if collapsible %>
- <details <%= "open" if open %>
- class="group bg-container shadow-border-xs rounded-xl p-4"
- <%= "data-controller=\"auto-open\" data-auto-open-param-value=\"#{h(auto_open_param)}\"".html_safe if auto_open_param.present? %>>
- <summary class="flex items-center justify-between gap-2 cursor-pointer rounded-lg list-none [&::-webkit-details-marker]:hidden">
- <div class="flex items-center gap-2">
- <%= icon "chevron-right", class: "text-secondary group-open:transform group-open:rotate-90 transition-transform" %>
- <div>
- <div class="flex items-center gap-2 flex-wrap">
- <h2 class="text-lg font-medium text-primary"><%= title %></h2>
- <%= badge if badge.present? %>
+ <%= render DS::Disclosure.new(
+ variant: :card,
+ open: open,
+ data: auto_open_param.present? ? { controller: "auto-open", auto_open_param_value: auto_open_param } : nil
+ ) do |disclosure| %>
+ <% disclosure.with_summary_content do %>
+ <div class="flex items-center justify-between gap-2 w-full">
+ <div class="flex items-center gap-2">
+ <%= icon "chevron-right", class: "text-secondary group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-150" %>
+ <div>
+ <div class="flex items-center gap-2 flex-wrap">
+ <h2 class="text-lg font-medium text-primary"><%= title %></h2>
+ <%= badge if badge.present? %>
+ </div>
+ <% if subtitle.present? %>
+ <p class="text-secondary text-sm"><%= subtitle %></p>
+ <% end %>
</div>
- <% if subtitle.present? %>
- <p class="text-secondary text-sm"><%= subtitle %></p>
- <% end %>
</div>
+ <% if status.present? %>
+ <div class="flex items-center gap-2 shrink-0 group-open:hidden">
+ <% if meta.present? %>
+ <span class="text-xs text-subdued"><%= meta %></span>
+ <% end %>
+ <%= status %>
+ <%= actions if actions.present? %>
+ </div>
+ <% end %>
</div>
- <% if status.present? %>
- <div class="flex items-center gap-2 shrink-0 group-open:hidden">
- <% if meta.present? %>
- <span class="text-xs text-subdued"><%= meta %></span>
- <% end %>
- <%= status %>
- <%= actions if actions.present? %>
- </div>
- <% end %>
- </summary>
+ <% end %>
<div class="space-y-4 mt-4">
<%= content %>
</div>
- </details>
+ <% end %>
<% else %>
<section class="bg-container shadow-border-xs rounded-xl p-4 space-y-4">
<div>
diff --git a/app/views/settings/providers/_ibkr_panel.html.erb b/app/views/settings/providers/_ibkr_panel.html.erb
index 578c6af344..7e9e686d9c 100644
--- a/app/views/settings/providers/_ibkr_panel.html.erb
+++ b/app/views/settings/providers/_ibkr_panel.html.erb
@@ -13,17 +13,17 @@
t(".steps.step_5")
] %>
- <details class="group bg-surface-inset rounded-xl p-4">
- <summary class="list-none cursor-pointer [&::-webkit-details-marker]:hidden">
+ <%= render DS::Disclosure.new(variant: :card_inset) do |disclosure| %>
+ <% disclosure.with_summary_content do %>
<div class="flex items-start justify-between gap-3">
<div>
<p class="text-xs font-medium uppercase text-subdued tracking-wider mb-2"><%= t(".flex_query_details.eyebrow") %></p>
<p class="text-sm font-medium text-primary"><%= t(".flex_query_details.title") %></p>
<p class="text-xs text-secondary mt-1"><%= t(".flex_query_details.summary") %></p>
</div>
- <%= icon "chevron-down", class: "mt-0.5 text-secondary transition-transform group-open:rotate-180" %>
+ <%= icon "chevron-down", class: "mt-0.5 text-secondary group-open:rotate-180 motion-safe:transition-transform motion-safe:duration-150" %>
</div>
- </summary>
+ <% end %>
<div class="mt-4 space-y-4 text-sm text-secondary">
<div class="space-y-2">
@@ -89,7 +89,7 @@
<p class="text-xs text-secondary"><%= t(".report_window_note") %></p>
</div>
- </details>
+ <% end %>
<%
ibkr_item = Current.family.ibkr_items.first_or_initialize(name: "Interactive Brokers")
diff --git a/config/locales/views/plaid_items/en.yml b/config/locales/views/plaid_items/en.yml
index 0dbe8ee519..25e87511ce 100644
--- a/config/locales/views/plaid_items/en.yml
+++ b/config/locales/views/plaid_items/en.yml
@@ -15,6 +15,7 @@ en:
connection_lost_description: This connection is no longer valid. You'll need
to delete this connection and add it again to continue syncing data.
delete: Delete
+ deletion_in_progress: (deletion in progress...)
error: Error occurred while syncing data
no_accounts_description: We could not load any accounts from this financial
institution.