The personal finance app for everyone (by everyone)
Ruby
<%# locals: (budget:) %>
<%# Beside the plan, never inside it. The figures above answer "what did I plan
to spend"; these answer "what do I actually have". Folding one into the
other leaves the reader unsure which number drives the split, so the panel
keeps its own frame and its own heading. %>
<div class="w-full bg-container rounded-xl shadow-border-xs p-4">
<div class="flex items-start justify-between gap-3 mb-3">
<div class="min-w-0">
<h2 class="text-sm font-medium text-primary"><%= t(".heading") %></h2>
<p class="text-xs text-secondary mt-0.5"><%= t(".subtitle") %></p>
</div>
<%= render DS::Link.new(
text: t(".goals_link"),
href: goals_path,
variant: "outline",
size: "sm"
) %>
</div>
<%# Hand-built, not DS::DetailRow: its fixed label/value colours clash with
the secondary earmark and the primary, larger free figure. %>
<dl class="space-y-2">
<div class="flex items-baseline justify-between gap-3">
<dt class="text-sm text-secondary"><%= t(".available") %></dt>
<dd class="text-sm text-primary tabular-nums privacy-sensitive">
<%= format_money budget.available_cash_money %>
</dd>
</div>
<div class="flex items-baseline justify-between gap-3 border-b border-subdued pb-2">
<dt class="text-sm text-secondary"><%= t(".earmarked") %></dt>
<dd class="text-sm text-secondary tabular-nums privacy-sensitive">
−<%= format_money budget.earmarked_for_goals_money %>
</dd>
</div>
<div class="flex items-baseline justify-between gap-3 -mx-2 px-2 py-2 rounded-lg bg-surface-inset">
<dt class="text-sm font-medium text-primary"><%= t(".free") %></dt>
<dd class="text-2xl font-medium text-primary tabular-nums privacy-sensitive">
<%= format_money budget.free_cash_money %>
</dd>
</div>
</dl>
<% if budget.missing_cash_currencies.any? %>
<div class="mt-3">
<%= render DS::Alert.new(variant: "warning",
message: t(".currency_warning", currencies: budget.missing_cash_currencies.to_a.to_sentence, currency: budget.currency)) %>
</div>
<% end %>
</div>