Files
sure/app/views/reports/_net_worth.html.erb
Dream 61ee9d34cf Refactor report and dashboard table layouts to semantic HTML (#1222)
* Refactor report and dashboard tables from div grids to semantic HTML

Convert div-based grid layouts to proper <table>/<thead>/<tbody>/<tr>/<th>/<td>
elements in report views and the dashboard investment summary:

- reports/_breakdown_table + _category_row (income/expense breakdown)
- reports/_trends_insights (monthly trends)
- reports/_net_worth (asset/liability summaries)
- reports/_investment_performance (top holdings)
- pages/dashboard/_investment_summary (top holdings)

Replaces shared/ruler dividers with border-b border-divider on <tr> elements.
Updates test selectors from div[data-category] to tr[data-category] and from
[role="columnheader"] to thead/th.

Closes #1121

* Address PR review feedback

- Restore w-max sm:w-full wrapper on report tables to preserve horizontal
  scroll behavior on narrow screens
- Add sr-only accessible header for net worth amount columns
- Use border-divider instead of border-primary in dashboard investment summary

* Fix rounded corners on semantic table body containers

Move rounded-lg, shadow-border-xs, and bg-container from tbody
(where border-radius and box-shadow don't apply) to a wrapper div
with overflow-hidden. Add bg-container-inset on thead to preserve
the two-tone card design.
2026-03-22 11:50:33 +01:00

96 lines
4.7 KiB
Plaintext

<div class="space-y-6">
<%# Main Net Worth Stats %>
<div class="grid grid-cols-1 md: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" %>">
<%= net_worth_metrics[:current_net_worth].format %>
</p>
</div>
<%# Period Change %>
<div class="p-4 bg-surface-inset rounded-lg">
<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 %>">
<%= trend.value.format(signify_positive: true) %>
</p>
<p class="text-xs" style="color: <%= trend.color %>">
<%= trend.value >= 0 ? "+" : "" %><%= trend.percent_formatted %>
</p>
<% else %>
<p class="text-2xl font-semibold mb-1 text-subdued">--</p>
<% end %>
</div>
<%# Assets vs Liabilities %>
<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-success break-words 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-destructive break-words privacy-sensitive"><%= net_worth_metrics[:total_liabilities].format %></span>
</div>
</div>
</div>
<%# 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 ? "border-b border-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-success 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 ? "border-b border-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-destructive 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>
</div>