The personal finance app for everyone (by everyone)
Ruby
Keep Reports amounts on one line in narrow columns (#4708)
Jakub Kottnauerc74fff045e2c
diff --git a/app/views/accounts/_balance_card.html.erb b/app/views/accounts/_balance_card.html.erbindex bb95fc2bb0..ecae749328 100644--- a/app/views/accounts/_balance_card.html.erb+++ b/app/views/accounts/_balance_card.html.erb@@ -1,14 +1,15 @@<%# locals: (account:, href:, truncate: false, focus_ring: false) %>-<%# An account's logo, name, type and balance as one link. `truncate` keeps a- long name or type on one line inside a narrow grid cell, with the balance- beside it unbroken. %>-<%= link_to href, class: class_names("bg-container-inset rounded-lg p-4 flex items-center justify-between hover:bg-container-hover transition-colors", "focus-ring" => focus_ring) do %>- <div class="<%= class_names("flex items-center gap-3", "min-w-0" => truncate) %>">+<%# An account's logo, name, type and balance as one link. The balance stays on+ one line, so a grouped amount like "1 284 960,00 kr" never breaks; a long+ name wraps beside it, or with `truncate` stays on one line inside a narrow+ grid cell. %>+<%= link_to href, class: class_names("bg-container-inset rounded-lg p-4 flex items-center justify-between gap-3 hover:bg-container-hover transition-colors", "focus-ring" => focus_ring) do %>+ <div class="flex items-center gap-3 min-w-0"><%= render "accounts/logo", account: account, size: "sm" %>- <%= tag.div class: ("min-w-0" if truncate) do %>- <p class="<%= class_names("font-medium text-primary text-sm", "truncate" => truncate) %>"><%= account.name %></p>+ <div class="min-w-0">+ <p class="<%= class_names("font-medium text-primary text-sm", truncate ? "truncate" : "break-words") %>"><%= account.name %></p><p class="<%= class_names("text-xs text-secondary", "truncate" => truncate) %>"><%= account.short_subtype_label %></p>- <% end %>+ </div></div>- <p class="<%= class_names("font-medium text-primary privacy-sensitive", "whitespace-nowrap" => truncate) %>"><%= format_money(account.balance_money) %></p>+ <p class="font-medium text-primary whitespace-nowrap privacy-sensitive"><%= format_money(account.balance_money) %></p><% end %>diff --git a/app/views/reports/_breakdown_table.html.erb b/app/views/reports/_breakdown_table.html.erbindex b783e56e32..1800bff732 100644--- a/app/views/reports/_breakdown_table.html.erb+++ b/app/views/reports/_breakdown_table.html.erb@@ -11,7 +11,7 @@<div class="text-large mb-4 flex items-center gap-2 text-lg"><%= icon(icon_name, class: "w-5 h-5") %><span><%= t(title_key) %>:</span>- <span class="font-medium text-secondary <%= color_class %> privacy-sensitive"> <%= Money.new(total, Current.family.currency).format %></span>+ <span class="font-medium text-secondary <%= color_class %> whitespace-nowrap privacy-sensitive"> <%= Money.new(total, Current.family.currency).format %></span></div><%diff --git a/app/views/reports/_budget_performance.html.erb b/app/views/reports/_budget_performance.html.erbindex 23b93bc3c9..ebf16fccf2 100644--- a/app/views/reports/_budget_performance.html.erb+++ b/app/views/reports/_budget_performance.html.erb@@ -63,13 +63,13 @@<div class="flex items-center gap-4"><div><span class="text-subdued"><%= t("reports.budget_performance.spent") %>:</span>- <span class="font-medium text-primary privacy-sensitive">+ <span class="font-medium text-primary whitespace-nowrap privacy-sensitive"><%= Money.new(budget_item[:actual], Current.family.currency).format %></span></div><div><span class="text-subdued"><%= t("reports.budget_performance.budgeted") %>:</span>- <span class="font-medium text-secondary privacy-sensitive">+ <span class="font-medium text-secondary whitespace-nowrap privacy-sensitive"><%= Money.new(budget_item[:budgeted], Current.family.currency).format %></span></div>@@ -78,12 +78,12 @@<div><% if budget_item[:remaining] >= 0 %><span class="text-subdued"><%= t("reports.budget_performance.remaining") %>:</span>- <span class="font-medium text-success privacy-sensitive">+ <span class="font-medium text-success whitespace-nowrap privacy-sensitive"><%= Money.new(budget_item[:remaining], Current.family.currency).format %></span><% else %><span class="text-subdued"><%= t("reports.budget_performance.over_by") %>:</span>- <span class="font-medium text-destructive privacy-sensitive">+ <span class="font-medium text-destructive whitespace-nowrap privacy-sensitive"><%= Money.new(budget_item[:remaining].abs, Current.family.currency).format %></span><% end %>@@ -96,8 +96,9 @@<% if days_remaining > 0 %><div class="mt-3 pt-3 border-t border-tertiary"><p class="text-xs text-subdued">+ <%# Non-breaking spaces keep a grouped amount like "1 234 kr" whole mid-sentence. %><%= t("reports.budget_performance.suggested_daily",- amount: Money.new((budget_item[:remaining] / days_remaining), Current.family.currency).format,+ amount: Money.new((budget_item[:remaining] / days_remaining), Current.family.currency).format.gsub(" ", " "),days: days_remaining) %></p></div>diff --git a/app/views/reports/_investment_flows.html.erb b/app/views/reports/_investment_flows.html.erbindex ee773b994a..c2993d8518 100644--- a/app/views/reports/_investment_flows.html.erb+++ b/app/views/reports/_investment_flows.html.erb@@ -1,17 +1,17 @@<%# locals: (investment_flows:) %>-<div class="space-y-4">+<div class="@container space-y-4"><p class="text-sm text-secondary"><%= t(".description") %></p>- <div class="grid grid-cols-1 md:grid-cols-3 gap-4">+ <div class="grid grid-cols-1 @4xl:grid-cols-3 gap-4"><!-- Contributions --><div class="bg-container border border-primary rounded-lg p-4"><div class="flex items-center gap-2 mb-2"><%= icon("trending-up", size: "sm", class: "text-green-600") %><h3 class="text-sm font-medium text-secondary"><%= t(".contributions") %></h3></div>- <div class="text-2xl font-semibold privacy-sensitive" style="color: rgb(34 197 94);">+ <div class="text-2xl font-semibold whitespace-nowrap privacy-sensitive" style="color: rgb(34 197 94);"><%= format_money(investment_flows.contributions) %></div><p class="text-xs text-secondary mt-1"><%= t(".contributions_description") %></p>@@ -23,7 +23,7 @@<%= icon("trending-down", size: "sm", class: "text-orange-600") %><h3 class="text-sm font-medium text-secondary"><%= t(".withdrawals") %></h3></div>- <div class="text-2xl font-semibold privacy-sensitive" style="color: rgb(249 115 22);">+ <div class="text-2xl font-semibold whitespace-nowrap privacy-sensitive" style="color: rgb(249 115 22);"><%= format_money(investment_flows.withdrawals) %></div><p class="text-xs text-secondary mt-1"><%= t(".withdrawals_description") %></p>@@ -35,7 +35,7 @@<%= icon("arrow-right-left", size: "sm", class: "text-primary") %><h3 class="text-sm font-medium text-secondary"><%= t(".net_flow") %></h3></div>- <div class="text-2xl font-semibold text-primary privacy-sensitive">+ <div class="text-2xl font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= format_money(investment_flows.net_flow) %></div><p class="text-xs text-secondary mt-1"><%= t(".net_flow_description") %></p>diff --git a/app/views/reports/_investment_performance.html.erb b/app/views/reports/_investment_performance.html.erbindex dd13d2d2d8..5e973bf56b 100644--- a/app/views/reports/_investment_performance.html.erb+++ b/app/views/reports/_investment_performance.html.erb@@ -1,16 +1,16 @@<%# locals: (investment_metrics:) %><% if investment_metrics[:has_investments] %>- <div class="space-y-6">+ <div class="@container space-y-6"><%# Investment Summary Cards %>- <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4">+ <div class="grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 @6xl:grid-cols-5 gap-4"><%# Portfolio Value Card %><div class="bg-container-inset rounded-lg p-4"><div class="flex items-center gap-2 mb-3"><%= icon("briefcase", size: "sm") %><span class="text-sm text-secondary"><%= t("reports.investment_performance.portfolio_value") %></span></div>- <p class="text-xl font-semibold text-primary privacy-sensitive">+ <p class="text-xl font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= format_money(investment_metrics[:portfolio_value]) %></p></div>@@ -23,8 +23,8 @@</div><% if investment_metrics[:unrealized_trend] %><p class="text-xl font-semibold privacy-sensitive" style="color: <%= investment_metrics[:unrealized_trend].color %>">- <%= format_money(Money.new(investment_metrics[:unrealized_trend].value, Current.family.currency)) %>- (<%= investment_metrics[:unrealized_trend].percent_formatted %>)+ <span class="whitespace-nowrap"><%= format_money(Money.new(investment_metrics[:unrealized_trend].value, Current.family.currency)) %></span>+ <span class="whitespace-nowrap">(<%= investment_metrics[:unrealized_trend].percent_formatted %>)</span></p><% else %><p class="text-xl font-semibold text-secondary"><%= t("reports.investment_performance.no_data") %></p>@@ -39,8 +39,8 @@</div><% if investment_metrics[:period_return_trend] %><p class="text-xl font-semibold privacy-sensitive" style="color: <%= investment_metrics[:period_return_trend].color %>">- <%= format_money(Money.new(investment_metrics[:period_return_trend].value, Current.family.currency)) %>- (<%= investment_metrics[:period_return_trend].percent_formatted %>)+ <span class="whitespace-nowrap"><%= format_money(Money.new(investment_metrics[:period_return_trend].value, Current.family.currency)) %></span>+ <span class="whitespace-nowrap">(<%= investment_metrics[:period_return_trend].percent_formatted %>)</span></p><% else %><p class="text-xl font-semibold text-secondary"><%= t("reports.investment_performance.no_data") %></p>@@ -53,7 +53,7 @@<%= icon("arrow-down-to-line", size: "sm") %><span class="text-sm text-secondary"><%= t("reports.investment_performance.contributions") %></span></div>- <p class="text-xl font-semibold text-primary privacy-sensitive">+ <p class="text-xl font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= format_money(investment_metrics[:period_contributions]) %></p></div>@@ -64,7 +64,7 @@<%= icon("arrow-up-from-line", size: "sm") %><span class="text-sm text-secondary"><%= t("reports.investment_performance.withdrawals") %></span></div>- <p class="text-xl font-semibold text-primary privacy-sensitive">+ <p class="text-xl font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= format_money(investment_metrics[:period_withdrawals]) %></p></div>@@ -74,54 +74,36 @@<% if investment_metrics[:top_holdings].any? %><div class="space-y-3"><h4 class="text-lg font-medium"><%= t("reports.investment_performance.top_holdings") %></h4>- <div class="bg-container-inset rounded-xl p-1 overflow-x-auto">- <div class="w-max sm:w-full">- <div class="rounded-lg shadow-border-xs bg-container overflow-hidden">- <table class="w-full">- <thead class="bg-container-inset">- <tr class="uppercase text-xs font-medium text-secondary">- <th class="px-4 py-2 text-left font-medium"><%= t("reports.investment_performance.holding") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.investment_performance.weight") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.investment_performance.value") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.investment_performance.return") %></th>- </tr>- </thead>- <tbody class="text-secondary text-sm">- <% investment_metrics[:top_holdings].each_with_index do |holding, idx| %>- <tr class="<%= idx < investment_metrics[:top_holdings].size - 1 ? "table-divider" : "" %>">- <td class="py-3 px-4 lg:px-6">- <div class="flex items-center gap-3">- <% if (logo = holding.security.display_logo_url).present? %>- <img src="<%= Setting.transform_brand_fetch_url(logo) %>" alt="<%= holding.ticker %>" class="w-6 h-6 rounded-full">- <% else %>- <div class="w-8 h-8 rounded-full bg-container-inset flex items-center justify-center text-xs font-medium text-secondary">- <%= holding.ticker[0..1] %>- </div>- <% end %>- <div>- <p class="font-medium text-primary"><%= holding.ticker %></p>- <p class="text-xs text-secondary"><%= truncate(holding.name, length: 25) %></p>- </div>- </div>- </td>- <td class="py-3 px-4 lg:px-6 text-right text-secondary"><%= number_to_percentage(holding.weight || 0, precision: 1) %></td>- <td class="py-3 px-4 lg:px-6 text-right font-medium text-primary privacy-sensitive"><%= format_money(holding.amount_money) %></td>- <td class="py-3 px-4 lg:px-6 text-right">- <% if holding.trend %>- <span style="color: <%= holding.trend.color %>">- <%= holding.trend.percent_formatted %>- </span>- <% else %>- <span class="text-secondary"><%= t("reports.investment_performance.no_data") %></span>- <% end %>- </td>- </tr>+ <%= render DS::Table.new(rows: investment_metrics[:top_holdings], inset: true, label: t("reports.investment_performance.top_holdings"), row_class: ->(_holding) { "text-secondary" }) do |table| %>+ <% table.with_column(t("reports.investment_performance.holding")) do |holding| %>+ <div class="flex items-center gap-3">+ <% if (logo = holding.security.display_logo_url).present? %>+ <img src="<%= Setting.transform_brand_fetch_url(logo) %>" alt="<%= holding.ticker %>" class="w-6 h-6 rounded-full">+ <% else %>+ <div class="w-8 h-8 rounded-full bg-container-inset flex items-center justify-center text-xs font-medium text-secondary">+ <%= holding.ticker[0..1] %>+ </div><% end %>- </tbody>- </table>- </div>- </div>- </div>+ <div>+ <p class="font-medium text-primary"><%= holding.ticker %></p>+ <p class="text-xs text-secondary"><%= truncate(holding.name, length: 25) %></p>+ </div>+ </div>+ <% end %>+ <% table.with_column(t("reports.investment_performance.weight"), numeric: true) do |holding| %>+ <%= number_to_percentage(holding.weight || 0, precision: 1) %>+ <% end %>+ <% table.with_column(t("reports.investment_performance.value"), numeric: true, class: "font-medium text-primary privacy-sensitive") do |holding| %>+ <%= format_money(holding.amount_money) %>+ <% end %>+ <% table.with_column(t("reports.investment_performance.return"), numeric: true) do |holding| %>+ <% if holding.trend %>+ <span style="color: <%= holding.trend.color %>"><%= holding.trend.percent_formatted %></span>+ <% else %>+ <%= t("reports.investment_performance.no_data") %>+ <% end %>+ <% end %>+ <% end %></div><% end %>@@ -133,7 +115,7 @@<div class="flex flex-wrap gap-4"><% investment_metrics[:gains_by_tax_treatment].each do |treatment, data| %><div class="bg-container-inset rounded-lg p-4 space-y-3 flex-1 min-w-64" data-testid="tax-treatment-gains">- <div class="flex items-center justify-between">+ <div class="flex flex-wrap items-center justify-between gap-x-3 gap-y-2"><%= render DS::Pill.new(label: t("accounts.tax_treatments.#{treatment}"),tone: tax_treatment_pill_tone(treatment),@@ -141,7 +123,7 @@show_dot: false,title: t("accounts.tax_treatment_descriptions.#{treatment}")) %>- <span class="text-sm font-semibold text-primary privacy-sensitive">+ <span class="text-sm font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= format_money(data[:total_gain]) %></span></div>@@ -149,11 +131,11 @@<div class="space-y-2 text-sm"><div class="flex justify-between"><span class="text-secondary"><%= t("reports.investment_performance.unrealized_gains") %></span>- <span class="text-primary privacy-sensitive"><%= format_money(data[:unrealized_gain]) %></span>+ <span class="text-primary whitespace-nowrap privacy-sensitive"><%= format_money(data[:unrealized_gain]) %></span></div><div class="flex justify-between"><span class="text-secondary"><%= t("reports.investment_performance.realized_gains") %></span>- <span class="text-primary privacy-sensitive"><%= format_money(data[:realized_gain]) %></span>+ <span class="text-primary whitespace-nowrap privacy-sensitive"><%= format_money(data[:realized_gain]) %></span></div></div>@@ -188,7 +170,7 @@<% gain = data[:unrealized_gain_by_holding][holding.id] %><div class="flex justify-between pl-2"><span class="text-primary"><%= holding.ticker %></span>- <span class="<%= gain ? "" : "text-secondary" %>" style="<%= gain ? "color: #{holding.trend.color}" : "" %>">+ <span class="whitespace-nowrap <%= gain ? "" : "text-secondary" %>" style="<%= gain ? "color: #{holding.trend.color}" : "" %>"><%= gain ? format_money(gain) : t("reports.investment_performance.no_data") %></span></div>@@ -208,7 +190,7 @@<% amount = data[:realized_gain_by_trade][trade.id] %><div class="flex justify-between pl-2" data-testid="realized-gain-line"><span class="text-primary"><%= trade.security.ticker %></span>- <span class="<%= amount ? "" : "text-secondary" %>" style="<%= amount ? "color: #{gain.color}" : "" %>">+ <span class="whitespace-nowrap <%= amount ? "" : "text-secondary" %>" style="<%= amount ? "color: #{gain.color}" : "" %>"><%= amount ? format_money(amount) : t("reports.investment_performance.no_data") %></span></div>@@ -231,7 +213,7 @@<div class="space-y-3"><h4 class="text-lg font-medium"><%= t("reports.investment_performance.accounts") %></h4>- <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3">+ <div class="grid grid-cols-1 @2xl:grid-cols-2 @5xl:grid-cols-3 gap-3"><% investment_metrics[:accounts].each do |account| %><%= render "accounts/balance_card", account: account, href: account_path(account) %><% end %>diff --git a/app/views/reports/_net_worth.html.erb b/app/views/reports/_net_worth.html.erbindex 6c87fafd65..533d2f2d9f 100644--- a/app/views/reports/_net_worth.html.erb+++ b/app/views/reports/_net_worth.html.erb@@ -1,10 +1,10 @@-<div class="space-y-6">+<div class="@container space-y-6"><%# Main Net Worth Stats %>- <div class="grid grid-cols-1 md:grid-cols-3 gap-4">+ <div class="grid grid-cols-1 @4xl:grid-cols-3 gap-4"><%# Current Net Worth %><div class="p-4 bg-surface-inset rounded-lg"><p class="text-sm text-secondary mb-2"><%= t("reports.net_worth.current_net_worth") %></p>- <p class="text-2xl font-semibold privacy-sensitive <%= net_worth_metrics[:current_net_worth] >= 0 ? "text-success" : "text-destructive" %>">+ <p class="text-2xl font-semibold whitespace-nowrap privacy-sensitive <%= net_worth_metrics[:current_net_worth] >= 0 ? "text-success" : "text-destructive" %>"><%= net_worth_metrics[:current_net_worth].format %></p></div>@@ -14,7 +14,7 @@<p class="text-sm text-secondary mb-2"><%= t("reports.net_worth.period_change") %></p><% if net_worth_metrics[:trend] %><% trend = net_worth_metrics[:trend] %>- <p class="text-2xl font-semibold mb-1 privacy-sensitive" style="color: <%= trend.color %>">+ <p class="text-2xl font-semibold mb-1 whitespace-nowrap privacy-sensitive" style="color: <%= trend.color %>"><%= trend.value.format(signify_positive: true) %></p><% if trend.percent.finite? %>@@ -31,9 +31,9 @@<div class="p-4 bg-surface-inset rounded-lg"><p class="text-sm text-secondary mb-2"><%= t("reports.net_worth.assets_vs_liabilities") %></p><div class="flex items-baseline gap-2 flex-wrap">- <span class="text-lg font-semibold text-primary break-words privacy-sensitive"><%= net_worth_metrics[:total_assets].format %></span>+ <span class="text-lg font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= net_worth_metrics[:total_assets].format %></span><span class="text-xs text-subdued shrink-0">-</span>- <span class="text-lg font-semibold text-primary break-words privacy-sensitive"><%= net_worth_metrics[:total_liabilities].format %></span>+ <span class="text-lg font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= net_worth_metrics[:total_liabilities].format %></span></div></div></div>@@ -51,59 +51,8 @@<% end %><%# Asset/Liability Breakdown %>- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">- <%# Assets Summary %>- <div class="bg-container-inset rounded-xl p-1 overflow-x-auto w-full flex flex-col">- <div class="rounded-lg shadow-border-xs bg-container overflow-hidden">- <table class="w-full">- <thead class="bg-container-inset">- <tr class="uppercase text-xs font-medium text-secondary">- <th class="px-4 py-2 text-left font-medium"><%= t("reports.net_worth.total_assets") %></th>- <th class="px-4 py-2 text-right font-medium"><span class="sr-only"><%= t("reports.transactions_breakdown.table.amount") %></span></th>- </tr>- </thead>- <tbody>- <% net_worth_metrics[:asset_groups].each_with_index do |group, idx| %>- <tr class="<%= idx < net_worth_metrics[:asset_groups].size - 1 ? "table-divider" : "" %>">- <td class="py-3 px-4 lg:px-6 text-sm font-medium text-secondary"><%= group[:name] %></td>- <td class="py-3 px-4 lg:px-6 text-sm font-medium text-right text-primary privacy-sensitive"><%= group[:total].format %></td>- </tr>- <% end %>- <% if net_worth_metrics[:asset_groups].empty? %>- <tr>- <td colspan="2" class="text-sm text-subdued py-3 px-4 lg:px-6"><%= t("reports.net_worth.no_assets") %></td>- </tr>- <% end %>- </tbody>- </table>- </div>- </div>-- <%# Liabilities Summary %>- <div class="bg-container-inset rounded-xl p-1 overflow-x-auto w-full flex flex-col">- <div class="rounded-lg shadow-border-xs bg-container overflow-hidden">- <table class="w-full">- <thead class="bg-container-inset">- <tr class="uppercase text-xs font-medium text-secondary">- <th class="px-4 py-2 text-left font-medium"><%= t("reports.net_worth.total_liabilities") %></th>- <th class="px-4 py-2 text-right font-medium"><span class="sr-only"><%= t("reports.transactions_breakdown.table.amount") %></span></th>- </tr>- </thead>- <tbody>- <% net_worth_metrics[:liability_groups].each_with_index do |group, idx| %>- <tr class="<%= idx < net_worth_metrics[:liability_groups].size - 1 ? "table-divider" : "" %>">- <td class="py-3 px-4 lg:px-6 text-sm font-medium text-secondary"><%= group[:name] %></td>- <td class="py-3 px-4 lg:px-6 text-sm font-medium text-right text-primary privacy-sensitive"><%= group[:total].format %></td>- </tr>- <% end %>- <% if net_worth_metrics[:liability_groups].empty? %>- <tr>- <td colspan="2" class="text-sm text-subdued py-3 px-4 lg:px-6"><%= t("reports.net_worth.no_liabilities") %></td>- </tr>- <% end %>- </tbody>- </table>- </div>- </div>+ <div class="grid grid-cols-1 @2xl:grid-cols-2 gap-6">+ <%= render "reports/net_worth_groups", groups: net_worth_metrics[:asset_groups], title: t("reports.net_worth.total_assets"), empty: t("reports.net_worth.no_assets") %>+ <%= render "reports/net_worth_groups", groups: net_worth_metrics[:liability_groups], title: t("reports.net_worth.total_liabilities"), empty: t("reports.net_worth.no_liabilities") %></div></div>diff --git a/app/views/reports/_net_worth_groups.html.erb b/app/views/reports/_net_worth_groups.html.erbnew file mode 100644index 0000000000..c161c803f2--- /dev/null+++ b/app/views/reports/_net_worth_groups.html.erb@@ -0,0 +1,12 @@+<%# locals: (groups:, title:, empty:) %>+<% if groups.empty? %>+ <div class="min-w-0 rounded-xl bg-container-inset p-4">+ <p class="text-xs uppercase font-medium text-secondary mb-2"><%= title %></p>+ <p class="text-sm text-subdued"><%= empty %></p>+ </div>+<% else %>+ <%= render DS::Table.new(rows: groups, inset: true, label: title, class: "min-w-0") do |table| %>+ <% table.with_column(title, class: "font-medium text-secondary") { |group| group[:name] } %>+ <% table.with_column(tag.span(t("reports.transactions_breakdown.table.amount"), class: "sr-only"), numeric: true, class: "font-medium privacy-sensitive") { |group| group[:total].format } %>+ <% end %>+<% end %>diff --git a/app/views/reports/_spending_vs_normal.html.erb b/app/views/reports/_spending_vs_normal.html.erbindex ebdee2cab9..029474961c 100644--- a/app/views/reports/_spending_vs_normal.html.erb+++ b/app/views/reports/_spending_vs_normal.html.erb@@ -8,12 +8,12 @@<p class="text-sm text-secondary"><% if comparison.comparable? %><%= t(comparison.in_progress? ? "reports.spending_vs_normal.summary_so_far_html" : "reports.spending_vs_normal.summary_html",- total: tag.span(whole.call(comparison.total), class: "privacy-sensitive"),- normal: tag.span(whole.call(comparison.normal_total), class: "privacy-sensitive"),+ total: tag.span(whole.call(comparison.total), class: "whitespace-nowrap privacy-sensitive"),+ normal: tag.span(whole.call(comparison.normal_total), class: "whitespace-nowrap privacy-sensitive"),baseline_start: l(comparison.baseline_period.start_date, format: :long),baseline_end: l(comparison.baseline_period.end_date, format: :long)) %><% else %>- <%= t("reports.spending_vs_normal.no_history_html", total: tag.span(whole.call(comparison.total), class: "privacy-sensitive")) %>+ <%= t("reports.spending_vs_normal.no_history_html", total: tag.span(whole.call(comparison.total), class: "whitespace-nowrap privacy-sensitive")) %><% end %></p>@@ -50,11 +50,13 @@<% if changes.empty? %><p class="text-sm text-secondary"><%= comparison.comparable? ? t("reports.spending_vs_normal.no_changes") : t("reports.spending_vs_normal.no_history_short") %></p><% else %>- <ul class="space-y-1" data-testid="spending-changes">+ <%# One grid for the whole list, with each row on its subgrid, so the amount+ column takes the widest amount and the bars stay aligned. %>+ <ul class="grid grid-cols-[minmax(0,9rem)_1fr_auto] gap-x-2 gap-y-1" data-testid="spending-changes"><% changes.each do |change| %>- <li>+ <li class="col-span-3 grid grid-cols-subgrid"><%= link_to change[:href],- class: "grid grid-cols-[minmax(0,9rem)_1fr_5rem] items-center gap-2 rounded-md px-1 py-1 hover:bg-container-inset text-sm" do %>+ class: "col-span-3 grid grid-cols-subgrid items-center rounded-md px-1 py-1 hover:bg-container-inset text-sm" do %><span class="truncate text-primary"><%= change[:row].category.name %></span><span class="grid grid-cols-2 h-3" aria-hidden="true"><span class="flex justify-end">@@ -64,7 +66,7 @@<% if change[:row].change.positive? %><span class="h-3 rounded-r bg-destructive" style="width: <%= change[:width] %>%"></span><% end %></span></span>- <span class="text-right text-secondary privacy-sensitive tabular-nums"><%= change[:amount_label] %></span>+ <span class="text-right text-secondary whitespace-nowrap privacy-sensitive tabular-nums"><%= change[:amount_label] %></span><% end %></li><% end %>diff --git a/app/views/reports/_summary_dashboard.html.erb b/app/views/reports/_summary_dashboard.html.erbindex 927cfd2a7c..5d9109f80e 100644--- a/app/views/reports/_summary_dashboard.html.erb+++ b/app/views/reports/_summary_dashboard.html.erb@@ -1,4 +1,4 @@-<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">+<div class="grid grid-cols-1 @lg:grid-cols-2 @6xl:grid-cols-4 gap-4"><%# Total Income Card %><div class="bg-container rounded-xl shadow-border-xs p-6"><div class="flex items-start justify-between mb-3">@@ -11,7 +11,7 @@</div><div class="space-y-2">- <p class="text-2xl font-semibold text-primary privacy-sensitive">+ <p class="text-2xl font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= metrics[:current_income].format %></p>@@ -48,7 +48,7 @@</div><div class="space-y-2">- <p class="text-2xl font-semibold text-primary privacy-sensitive">+ <p class="text-2xl font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= metrics[:current_expenses].format %></p>@@ -85,7 +85,7 @@</div><div class="space-y-2">- <p class="text-2xl font-semibold privacy-sensitive <%= metrics[:net_savings] >= 0 ? "text-success" : "text-destructive" %>">+ <p class="text-2xl font-semibold whitespace-nowrap privacy-sensitive <%= metrics[:net_savings] >= 0 ? "text-success" : "text-destructive" %>"><%= metrics[:net_savings].format %></p>diff --git a/app/views/reports/_transactions_breakdown.html.erb b/app/views/reports/_transactions_breakdown.html.erbindex 2ce774bda9..ca45adc3e0 100644--- a/app/views/reports/_transactions_breakdown.html.erb+++ b/app/views/reports/_transactions_breakdown.html.erb@@ -15,7 +15,7 @@%><%# Export Options %>- <div class="flex items-center gap-2">+ <div class="flex flex-wrap items-center justify-end gap-2"><%= link_to export_transactions_reports_path(base_params.merge(format: :csv)),class: "font-medium whitespace-nowrap inline-flex items-center gap-1 rounded-lg px-3 py-2 text-sm text-primary border border-secondary bg-transparent hover:bg-surface-hover" do %><%= icon("download", class: "w-3 h-3") %>diff --git a/app/views/reports/_trends_insights.html.erb b/app/views/reports/_trends_insights.html.erbindex c74ab704f0..fd450b8783 100644--- a/app/views/reports/_trends_insights.html.erb+++ b/app/views/reports/_trends_insights.html.erb@@ -1,4 +1,4 @@-<div class="space-y-8">+<div class="@container space-y-8"><%# Month-over-Month Trends %><div><h3 class="text-lg font-medium mb-4">@@ -6,74 +6,53 @@</h3><% if trends_data.any? %>- <div class="bg-container-inset rounded-xl p-1 overflow-x-auto">- <div class="w-max sm:w-full">- <div class="rounded-lg shadow-border-xs bg-container overflow-hidden">- <table class="w-full">- <thead class="bg-container-inset">- <tr class="uppercase text-xs font-medium text-secondary">- <th class="px-4 py-2 text-left font-medium"><%= t("reports.trends.month") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.trends.income") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.trends.expenses") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.trends.net") %></th>- <th class="px-4 py-2 text-right font-medium"><%= t("reports.trends.savings_rate") %></th>- </tr>- </thead>- <tbody class="text-secondary text-sm">- <% trends_data.each_with_index do |trend, idx| %>- <tr class="<%= idx < trends_data.size - 1 ? "table-divider" : "" %>">- <td class="py-3 px-4 lg:px-6">- <span class="flex items-center gap-2 <%= trend[:is_current_month] ? "font-medium" : "" %>">- <%= trend[:month] %>- <% if trend[:is_current_month] %>- <span class="text-xs text-subdued">(<%= t("reports.trends.current") %>)</span>- <% end %>- </span>- </td>- <td class="py-3 px-4 lg:px-6 text-right privacy-sensitive">- <%= Money.new(trend[:income], Current.family.currency).format %>- </td>- <td class="py-3 px-4 lg:px-6 text-right privacy-sensitive">- <%= Money.new(trend[:expenses], Current.family.currency).format %>- </td>- <td class="py-3 px-4 lg:px-6 text-right privacy-sensitive <%= trend[:net] >= 0 ? "text-success" : "text-destructive" %>">- <%= Money.new(trend[:net], Current.family.currency).format %>- </td>- <td class="py-3 px-4 lg:px-6 text-right <%= trend[:net] >= 0 ? "text-success" : "text-destructive" %>">- <% savings_rate = trend[:income] > 0 ? ((trend[:net].to_f / trend[:income].to_f) * 100).round(1) : 0 %>- <%= savings_rate %>%- </td>- </tr>+ <%= render DS::Table.new(rows: trends_data, inset: true, label: t("reports.trends.monthly_breakdown"), row_class: ->(_trend) { "text-secondary" }) do |table| %>+ <% table.with_column(t("reports.trends.month")) do |trend| %>+ <span class="<%= class_names("flex items-center gap-2", "font-medium" => trend[:is_current_month]) %>">+ <%= trend[:month] %>+ <% if trend[:is_current_month] %>+ <span class="text-xs text-subdued">(<%= t("reports.trends.current") %>)</span><% end %>- </tbody>- </table>- </div>- </div>- </div>+ </span>+ <% end %>+ <% table.with_column(t("reports.trends.income"), numeric: true, class: "privacy-sensitive") do |trend| %>+ <%= Money.new(trend[:income], Current.family.currency).format %>+ <% end %>+ <% table.with_column(t("reports.trends.expenses"), numeric: true, class: "privacy-sensitive") do |trend| %>+ <%= Money.new(trend[:expenses], Current.family.currency).format %>+ <% end %>+ <% table.with_column(t("reports.trends.net"), numeric: true, class: "privacy-sensitive") do |trend| %>+ <%= tag.span Money.new(trend[:net], Current.family.currency).format, class: trend[:net] >= 0 ? "text-success" : "text-destructive" %>+ <% end %>+ <% table.with_column(t("reports.trends.savings_rate"), numeric: true) do |trend| %>+ <% savings_rate = trend[:income] > 0 ? ((trend[:net].to_f / trend[:income].to_f) * 100).round(1) : 0 %>+ <%= tag.span "#{savings_rate}%", class: trend[:net] >= 0 ? "text-success" : "text-destructive" %>+ <% end %>+ <% end %><%# Trend Insights %>- <div class="mt-6 grid grid-cols-1 md:grid-cols-3 gap-4">+ <div class="mt-6 grid grid-cols-1 @2xl:grid-cols-3 gap-4"><% avg_income = trends_data.sum { |t| t[:income] } / trends_data.length %><% avg_expenses = trends_data.sum { |t| t[:expenses] } / trends_data.length %><% avg_net = trends_data.sum { |t| t[:net] } / trends_data.length %><div class="p-4 bg-surface-inset rounded-lg"><p class="text-sm text-secondary mb-1"><%= t("reports.trends.avg_monthly_income") %></p>- <p class="text-lg font-semibold text-success privacy-sensitive">+ <p class="text-lg font-semibold text-success whitespace-nowrap privacy-sensitive"><%= Money.new(avg_income, Current.family.currency).format %></p></div><div class="p-4 bg-surface-inset rounded-lg"><p class="text-sm text-secondary mb-1"><%= t("reports.trends.avg_monthly_expenses") %></p>- <p class="text-lg font-semibold text-primary privacy-sensitive">+ <p class="text-lg font-semibold text-primary whitespace-nowrap privacy-sensitive"><%= Money.new(avg_expenses, Current.family.currency).format %></p></div><div class="p-4 bg-surface-inset rounded-lg"><p class="text-sm text-secondary mb-1"><%= t("reports.trends.avg_monthly_savings") %></p>- <p class="text-lg font-semibold privacy-sensitive <%= avg_net >= 0 ? "text-success" : "text-destructive" %>">+ <p class="text-lg font-semibold whitespace-nowrap privacy-sensitive <%= avg_net >= 0 ? "text-success" : "text-destructive" %>"><%= Money.new(avg_net, Current.family.currency).format %></p></div>diff --git a/app/views/reports/index.html.erb b/app/views/reports/index.html.erbindex 8bc44ebd1e..c73e10f29e 100644--- a/app/views/reports/index.html.erb+++ b/app/views/reports/index.html.erb@@ -159,7 +159,7 @@<% if Current.family.transactions.any? %><%# Summary Dashboard - Always visible, not collapsible %>- <section>+ <section class="@container"><%= render partial: "reports/summary_dashboard", locals: {metrics: @summary_metrics,period_type: @period_typediff --git a/test/controllers/reports_controller_test.rb b/test/controllers/reports_controller_test.rbindex 9c0c48f7b1..b594b3a59f 100644--- a/test/controllers/reports_controller_test.rb+++ b/test/controllers/reports_controller_test.rb@@ -769,6 +769,16 @@ class ReportsControllerTest < ActionDispatch::IntegrationTestassert_select "[role=region][tabindex='0'][aria-label=?] table", "Expenses"end+ test "index lets keyboard users scroll the trends and net worth tables" do+ create_transaction(account: @family.accounts.first, name: "Lunch", amount: 15, category: categories(:food_and_drink))++ get reports_path(period_type: :monthly)++ %w[Monthly\ Breakdown Assets Liabilities].each do |label|+ assert_select "[role=region][tabindex='0'][aria-label=?] table", label+ end+ end+test "index links income and expense categories to filtered transactions" dostart_date = Date.current.beginning_of_monthend_date = Date.current.end_of_monthdiff --git a/test/system/reports_test.rb b/test/system/reports_test.rbindex b3ec3e0ae5..04fd25a5e9 100644--- a/test/system/reports_test.rb+++ b/test/system/reports_test.rb@@ -54,6 +54,13 @@ class ReportsTest < ApplicationSystemTestCaseassert_equal %w[ArrowLeft], clicked_hotkeysend+ test "the arrow keys scroll a focused trends or net worth table instead of changing the period" do+ %w[trends_insights net_worth].each do |key|+ find("section[data-section-key='#{key}'] [role='region']", match: :first).send_keys(:arrow_left)+ end+ assert_empty clicked_hotkeys+ end+test "a held arrow key steps one period" dopage.execute_script(<<~JS)for (const repeat of [false, true, true]) {diff --git a/test/views/accounts/balance_card_view_test.rb b/test/views/accounts/balance_card_view_test.rbindex 0c92e2c413..c6955c611e 100644--- a/test/views/accounts/balance_card_view_test.rb+++ b/test/views/accounts/balance_card_view_test.rb@@ -7,19 +7,19 @@ class AccountsBalanceCardViewTest < ActionView::TestCase@account = accounts(:investment)end- # The Reports investment card renders with the defaults, so these are the- # classes that page has always drawn.+ # The Reports investment card renders with the defaults: a long name wraps+ # beside the balance, and the balance never breaks.test "the defaults draw the plain card" dorender partial: "accounts/balance_card", locals: { account: @account, href: "/accounts/1" }- assert_select "a[href='/accounts/1'][class=?]", "bg-container-inset rounded-lg p-4 flex items-center justify-between hover:bg-container-hover transition-colors" do- assert_select "> div[class=?]", "flex items-center gap-3" do- assert_select "> div:not([class])" do- assert_select "p[class=?]", "font-medium text-primary text-sm", text: @account.name+ assert_select "a[href='/accounts/1'][class=?]", "bg-container-inset rounded-lg p-4 flex items-center justify-between gap-3 hover:bg-container-hover transition-colors" do+ assert_select "> div[class=?]", "flex items-center gap-3 min-w-0" do+ assert_select "> div[class=?]", "min-w-0" do+ assert_select "p[class=?]", "font-medium text-primary text-sm break-words", text: @account.nameassert_select "p[class=?]", "text-xs text-secondary", text: @account.short_subtype_labelendend- assert_select "> p[class=?]", "font-medium text-primary privacy-sensitive", text: "$10,000.00"+ assert_select "> p[class=?]", "font-medium text-primary whitespace-nowrap privacy-sensitive", text: "$10,000.00"endend