The personal finance app for everyone (by everyone)
Ruby
<div class="space-y-4 pb-6 lg:pb-12">
<%= render "bills/view_switcher", active: "all" %>
<%# What the Subscriptions tab existed to answer. It was a whole destination
for a filter All bills already had, so the rollup now appears when that
filter is on rather than living behind its own tab. %>
<% if @subscription_rollup %>
<%# A text-xl currency figure does not fit an 85px cell, which is what three
columns leaves at 375px. %>
<div class="grid grid-cols-1 sm:grid-cols-3 bg-container rounded-xl shadow-border-xs divide-y sm:divide-y-0 sm:divide-x divide-subdued">
<div class="p-4 space-y-1">
<p class="text-sm text-secondary"><%= t(".subscription_monthly") %></p>
<p class="text-primary font-medium text-xl privacy-sensitive">
<%= @subscription_rollup[:monthly] ? format_money(@subscription_rollup[:monthly]) : "–" %>
</p>
<% if @subscription_rollup[:unconvertible].positive? %>
<p class="text-xs text-warning"><%= t("bills.index.unconvertible", count: @subscription_rollup[:unconvertible]) %></p>
<% end %>
</div>
<div class="p-4 space-y-1">
<p class="text-sm text-secondary"><%= t(".subscription_annual") %></p>
<p class="text-primary font-medium text-xl privacy-sensitive">
<%= @subscription_rollup[:annual] ? format_money(@subscription_rollup[:annual]) : "–" %>
</p>
</div>
<div class="p-4 space-y-1">
<p class="text-sm text-secondary"><%= t(".subscription_active") %></p>
<p class="text-primary font-medium text-xl"><%= @subscription_rollup[:active_count] %></p>
</div>
</div>
<% end %>
<%# One card, the way Transactions does it: the filters live with the list
they filter, and the table sits in an inset tray inside it. Nothing is
left on the page background but the header and the switcher. %>
<div class="bg-container rounded-xl shadow-border-xs px-3 py-4 lg:p-4 space-y-4">
<%# Built with the styled form builder, so each filter sits in the boxed field
every form uses, one height with the search box. As bare selects they read
as loose words with a chevron, and had no focus ring at all. %>
<%= styled_form_with url: bills_path, method: :get, scope: :q,
data: { controller: "auto-submit-form" },
class: "flex flex-wrap items-center gap-2" do |form| %>
<%= hidden_field_tag :view, "all" %>
<%= render DS::SearchInput.new(
name: "q[search]",
value: params.dig(:q, :search),
placeholder: t(".search_placeholder"),
class: "grow max-w-xs",
data: { "auto-submit-form-target": "auto" }) %>
<%= form.select :status,
options_for_select(
[ [ t(".current_bills"), "" ] ] + BillsController::STATUS_FILTERS.map { |status| [ t(".status_filters.#{status}"), status ] },
params.dig(:q, :status)
),
{ container_class: "w-auto py-2.5" },
{ class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>
<%= form.select :bill_type,
options_for_select(
[ [ t(".any_type"), "" ] ] + RecurringTransaction.bill_types.keys.map { |type| [ t(".types.#{type}"), type ] },
params.dig(:q, :bill_type)
),
{ container_class: "w-auto py-2.5" },
{ class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>
<%= form.select :sort,
options_for_select(
[ [ t(".sort_due"), "" ], [ t(".sort_name"), "name" ], [ t(".sort_amount"), "amount" ] ],
params.dig(:q, :sort)
),
{ container_class: "w-auto py-2.5" },
{ class: "form-field__input w-auto", "data-auto-submit-form-target": "auto" } %>
<% end %>
<% if @all_series.empty? %>
<% if @dismissed_series_hidden %>
<%= render DS::EmptyState.new(
icon: "receipt",
title: t(".no_matches_title"),
description: t(".dismissed_hidden_description")
) do |empty| %>
<% empty.with_action do %>
<%= render DS::Link.new(
text: t(".status_filters.ended"),
icon: "receipt",
variant: "outline",
href: bills_path(view: "all", q: { status: "ended" })
) %>
<% end %>
<% end %>
<% else %>
<%= render DS::EmptyState.new(
icon: "receipt",
title: t(".no_matches_title"),
description: t(".no_matches_description")
) %>
<% end %>
<% else %>
<%# A table on a phone is a table you scroll sideways to read. The same
rows, laid out the way the Calendar already does it: a purpose-built
small-screen list rather than a squeezed desktop one. Switched on the
container, not the viewport: the app shell's sidebars can squeeze a
desktop window to phone-list widths, and a viewport breakpoint cannot
see that. Four columns now, so the table fits from @2xl rather than
from the width the seven it had needed. %>
<div class="@container">
<%# Same recipe as the overview rows and a transaction row: the face,
the name over what it is, the figure at the end, and a click
anywhere on the row opens the drawer. A live row says nothing about
its status; a paused or dismissed one says it where a date would be,
because it has no next due, and recedes. %>
<%# Rows straight on the card, no tray inside it: on a phone the tray
and a second card cost 20px a row, which is the name. %>
<div class="@2xl:hidden">
<% @all_series.each do |series| %>
<div class="flex items-center gap-3 py-3"
data-controller="clickable-row"
data-action="click->clickable-row#open">
<%= link_to bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false, clickable_row_target: "link" }, class: "flex items-center gap-3 min-w-0 flex-1 rounded-lg focus-ring outline-offset-4" do %>
<%= render "bills/series_avatar", series: series %>
<div class="min-w-0 flex-1">
<p class="text-sm font-medium <%= bills_series_tone(series) %> truncate hover:underline"><%= series.display_name %></p>
<p class="text-xs text-secondary truncate"><%= bills_series_subline(series) %></p>
</div>
<div class="shrink-0 text-right">
<p class="text-sm font-medium <%= bills_series_amount_tone(series) %> privacy-sensitive">
<%= format_money(Money.new(series.amount.abs, series.currency)) %>
</p>
<%# Under the figure, where the table puts it in its own
column: the subline already spends its width on the
schedule. %>
<% if series.active? %>
<% if series.next_expected_date %>
<p class="text-xs text-secondary"><%= bills_upcoming_date(series.next_expected_date) %></p>
<% end %>
<% else %>
<p class="text-xs">
<%= render DS::Pill.new(label: t("recurring_transactions.status.#{series.status}"), tone: recurring_status_pill_tone(series.status), marker: false) %>
</p>
<% end %>
</div>
<% end %>
<div class="shrink-0">
<%= render "bills/series_menu", series: series %>
</div>
</div>
<% end %>
</div>
<%# inset: the table sits in the card above, so it takes the tray frame
the transaction list's date groups have, not a card of its own. %>
<%= render DS::Table.new(
rows: @all_series,
inset: true,
label: t("bills.views.all"),
class: "hidden @2xl:block",
row_opts: ->(_series) { { data: { controller: "clickable-row", action: "click->clickable-row#open" } } }
) do |table| %>
<%# w-full max-w-0 is the table idiom for "take what the other columns
leave, and truncate inside it": a bank-style name is one long
unbreakable run, and without it the column grows past the card and
pushes the actions menu out of reach. %>
<% table.with_column(t(".col_name"), class: "w-full max-w-0") do |series| %>
<div class="flex items-center gap-3 @lg:gap-4">
<%= render "bills/series_avatar", series: series %>
<div class="min-w-0">
<%= link_to series.display_name, bill_path(series), data: { turbo_frame: "drawer", turbo_prefetch: false, clickable_row_target: "link" }, class: "block truncate font-medium #{bills_series_tone(series)} hover:underline" %>
<p class="text-xs text-secondary truncate"><%= bills_series_subline(series) %></p>
</div>
</div>
<% end %>
<% table.with_column(t(".col_next"), class: "text-secondary") do |series| %>
<% if series.active? %>
<%= series.next_expected_date ? bills_upcoming_date(series.next_expected_date) : "–" %>
<% else %>
<%= render DS::Pill.new(label: t("recurring_transactions.status.#{series.status}"), tone: recurring_status_pill_tone(series.status), marker: false) %>
<% end %>
<% end %>
<% table.with_column(t(".col_amount"), numeric: true, class: "privacy-sensitive") do |series| %>
<% amount = Money.new(series.amount.abs, series.currency) %>
<% monthly = series.monthly_equivalent_amount.abs %>
<span class="font-medium <%= bills_series_amount_tone(series) %>"><%= format_money(amount) %></span>
<%# A monthly bill's monthly equivalent is its own amount, so the
second line said "$5.99" under "$5.99". It only carries
information for the other cadences. %>
<%# A one-off's monthly equivalent is zero, which would read as
"$0/mo" under the real amount. %>
<% if !series.one_off? && monthly != amount %>
<p class="text-xs text-secondary"><%= t(".monthly_equivalent", amount: format_money(monthly)) %></p>
<% end %>
<% end %>
<% table.with_column(t(".col_actions"), align: :right) do |series| %>
<%= render "bills/series_menu", series: series %>
<% end %>
<% end %>
</div>
<% end %>
</div>
<%# Across every bill, not just the one you have open. Per-bill history lives
in the bill's own detail. %>
<% if @recent_price_changes&.any? %>
<%= render DS::Section.new(title: t(".subscription_price_changes"), count: @recent_price_changes.size) do %>
<% @recent_price_changes.each do |change| %>
<div class="flex items-center justify-between gap-3 px-4 py-2">
<div>
<p class="text-sm text-primary"><%= change.recurring_transaction.display_name %></p>
<p class="text-xs text-secondary"><%= l(change.effective_on, format: :long) %></p>
</div>
<p class="text-sm privacy-sensitive <%= change.new_amount > change.previous_amount ? "text-warning" : "text-success" %>">
<%= t(".subscription_price_change_line",
from: format_money(change.previous_amount_money),
to: format_money(change.new_amount_money),
percent: change.previous_amount.positive? ? ((change.new_amount - change.previous_amount) / change.previous_amount * 100).round(1) : 0) %>
</p>
</div>
<% end %>
<% end %>
<% end %>
</div>