The personal finance app for everyone (by everyone)
Ruby
Give the bills overview one focus ring and readable autopay rows (#3911)
Guillem Arias Faustebc093a1a502c
diff --git a/app/views/bills/_month_pulse.html.erb b/app/views/bills/_month_pulse.html.erbindex fe3d9d35fc..0224003d42 100644--- a/app/views/bills/_month_pulse.html.erb+++ b/app/views/bills/_month_pulse.html.erb@@ -77,8 +77,12 @@<div class="pt-3 border-t border-subdued space-y-2"><div class="flex items-center justify-between gap-3"><p class="text-xs font-medium uppercase tracking-wide text-secondary"><%= t(".next_up") %></p>- <%= link_to t(".view_calendar"), bills_path(view: "calendar"),- class: "text-xs text-link hover:underline shrink-0 focus-ring rounded-sm" %>+ <%= render DS::Link.new(+ text: t(".view_calendar"),+ variant: :default,+ href: bills_path(view: "calendar"),+ class: "text-xs shrink-0"+ ) %></div><%# A horizontal strip where there is room, a scrollable one where therediff --git a/app/views/bills/_notice.html.erb b/app/views/bills/_notice.html.erbindex 34eed76eca..ba077ee9f8 100644--- a/app/views/bills/_notice.html.erb+++ b/app/views/bills/_notice.html.erb@@ -20,6 +20,10 @@</span><% end %></p>- <%= link_to t("bills.manage"), bill_path(notice.series),- class: "text-xs text-link hover:underline shrink-0" %>+ <%= render DS::Link.new(+ text: t("bills.manage"),+ variant: :default,+ href: bill_path(notice.series),+ class: "text-xs shrink-0"+ ) %></div>diff --git a/app/views/bills/_occurrence.html.erb b/app/views/bills/_occurrence.html.erbindex 846f959354..96b5705833 100644--- a/app/views/bills/_occurrence.html.erb+++ b/app/views/bills/_occurrence.html.erb@@ -2,23 +2,28 @@<% series = occurrence.recurring_transaction %><% expected = occurrence.resolved_expected_amount_money %><% paid = occurrence.confirmed_allocated_money %>+<% lead_tone = series.autopay? ? "text-secondary" : "text-primary" %><%# SCAN. What is this, and does it need me?Everything past that question lives one tap deeper, in the drawer.An autopaying bill is still worth seeing and still counts toward the total,- but it recedes so the rows that want something from you carry the weight. %>+ but it recedes so the rows that want something from you carry the weight.+ It recedes through lead_tone, on the name and the amount: opacity on the+ whole row took the secondary text below 3:1 in light mode. %><%# The row reads as interactive without dressing up as a button: a hover tintand the name underlining, the same cues the transaction list uses. %>-<div class="flex items-center gap-3 lg:gap-4 p-3 lg:p-4 transition-colors hover:bg-surface-hover <%= "opacity-70" if series.autopay? %>">+<div class="flex items-center gap-3 lg:gap-4 p-3 lg:p-4 transition-colors hover:bg-surface-hover"><%# The bulk of the row is the inspect control. Only the trailing verb sits- outside it, so there are no anchors inside anchors. %>+ outside it, so there are no anchors inside anchors. The link has no+ padding of its own, so its ring is pushed out into the row's: clear of+ the date and the amount, and still inside the row. %><%# Names the cycle it was opened from. Without it the drawer falls back tothe series' current occurrence, so opening a settled row described theNEXT one and reported it unpaid. %><%= link_to bill_path(series, display: "drawer", occurrence: occurrence.id),data: { turbo_frame: "drawer", turbo_prefetch: false },- class: "flex items-center gap-3 lg:gap-4 min-w-0 flex-1 group" do %>+ class: "flex items-center gap-3 lg:gap-4 min-w-0 flex-1 group rounded-lg focus-ring outline-offset-4" do %><%# A date rail, and only a date. It used to print "Overdue" beside asubline already reading "14 days overdue", which spent the row's onepiece of temporal context saying the same word twice. The colour still@@ -46,7 +51,7 @@<% reason = date_label ? bills_attention_reason(occurrence, suggestion: suggestion) : nil %><div class="min-w-0 flex-1">- <p class="text-primary text-sm font-medium truncate group-hover:underline">+ <p class="<%= lead_tone %> text-sm font-medium truncate group-hover:underline"><%= series.display_name %><% if series.transfer? %><span class="text-xs text-secondary font-normal"><%= t("bills.debt_payment") %></span>@@ -77,7 +82,7 @@<% end %></p><% if series.notes.present? %>- <p class="text-xs text-subdued truncate"><%= series.notes %></p>+ <p class="text-xs text-secondary truncate"><%= series.notes %></p><% end %></div>@@ -85,7 +90,7 @@used to be printed twice: a coloured subline on the left and a figureon the right. %><div class="shrink-0 text-right min-w-0">- <p class="text-sm font-medium text-primary privacy-sensitive whitespace-nowrap">+ <p class="text-sm font-medium <%= lead_tone %> privacy-sensitive whitespace-nowrap"><% if occurrence.paid? %><%= format_money(paid) %><% elsif occurrence.partially_paid? %>diff --git a/app/views/bills/index.html.erb b/app/views/bills/index.html.erbindex a6314f4921..e302636020 100644--- a/app/views/bills/index.html.erb+++ b/app/views/bills/index.html.erb@@ -11,8 +11,12 @@<p class="text-sm text-primary"><%= t(".detected_review", count: @detected_awaiting_review) %></p>- <%= link_to t(".detected_review_action"), bills_path(view: "all"),- class: "text-xs text-secondary hover:text-primary shrink-0" %>+ <%= render DS::Link.new(+ text: t(".detected_review_action"),+ variant: :default,+ href: bills_path(view: "all"),+ class: "text-xs shrink-0"+ ) %></div><% end %>diff --git a/app/views/layouts/shared/_breadcrumbs.html.erb b/app/views/layouts/shared/_breadcrumbs.html.erbindex f9739921cf..f1f6762c55 100644--- a/app/views/layouts/shared/_breadcrumbs.html.erb+++ b/app/views/layouts/shared/_breadcrumbs.html.erb@@ -7,7 +7,7 @@<% end %><% if path.present? && index < breadcrumbs.size - 1 %>- <%= link_to name, path, class: "text-sm text-secondary font-medium" %>+ <%= link_to name, path, class: "text-sm text-secondary font-medium focus-ring rounded-sm" %><% elsif index == breadcrumbs.size - 1 %><span class="text-primary font-medium text-sm"><%= name %></span><% else %>diff --git a/test/controllers/bills_controller_test.rb b/test/controllers/bills_controller_test.rbindex 4d35239292..8445bfa53a 100644--- a/test/controllers/bills_controller_test.rb+++ b/test/controllers/bills_controller_test.rb@@ -1,6 +1,10 @@require "test_helper"class BillsControllerTest < ActionDispatch::IntegrationTest+ # A bill row's drawer link. The scope leaves out Next up, whose items open+ # the same drawer URL from outside the lists.+ BILL_ROW_LINK = "[class~='@container'] a[data-turbo-frame=drawer][href*='display=drawer']".freeze+teardown dotravel_backend@@ -232,6 +236,41 @@ class BillsControllerTest < ActionDispatch::IntegrationTest"the donut is gone; progress is a rule, not a centrepiece")end+ # A raw link_to falls back to the browser's own focus outline: blue, square,+ # and drawn tight against the text. Every stop on the page shows the DS ring.+ test "every link on the overview shows the DS focus ring" do+ # Never confirmed, so the detection banner shows its "Review them" link.+ gym = create_bill(name: "Gym", amount: 90)+ gym.recurring_price_changes.create!(effective_on: 5.days.ago.to_date,+ previous_amount: 80, new_amount: 90, currency: "USD", source: "detected")+ soon = 3.days.from_now.to_date+ create_bill(name: "Amazon Prime", amount: 16.23, expected_day_of_month: soon.day,+ next_expected_date: soon)++ get bills_url+ assert_response :success++ text_links = [+ I18n.t("bills.index.detected_review_action"),+ I18n.t("bills.manage"),+ I18n.t("bills.month_pulse.view_calendar")+ ]+ # One text link style: DS::Link's underlined text link, kept at the+ # compact text-xs the default variant does not set.+ text_links.each do |text|+ assert_select "main a.text-link.underline.focus-ring.text-xs", text: text+ end+ # Premise: the rows are on the page, so the sweep below covers them.+ assert_select "main #{BILL_ROW_LINK}", minimum: 2++ assert_select "main a, main summary" do |stops|+ stops.each do |stop|+ assert_includes stop["class"].to_s.split, "focus-ring",+ "falls back to the browser outline: #{stop.to_html.squish.truncate(160)}"+ end+ end+ end+# Something already past its due date is not "coming up" -- it is the thing# the list below is for, and putting it in Next up makes the summary argue# with the worklist under it.@@ -1304,6 +1343,28 @@ class BillsControllerTest < ActionDispatch::IntegrationTest"the portal stays reachable, just not as the row's headline action"end+ # Opacity on the whole row took the secondary text to about 2.7:1 in light+ # mode. The row recedes through the text tokens instead.+ test "an autopay row recedes through its text colour, not opacity" do+ create_bill(name: "Handled bill", amount: 30, autopay: true, notes: "Card ending 4242")+ create_bill(name: "Power Co", amount: 80)++ get bills_url+ assert_response :success++ assert_select BILL_ROW_LINK, text: /Handled bill/ do |links|+ assert_not_includes links.first.parent["class"].split, "opacity-70"+ assert_select links.first, "p.font-medium.text-secondary", text: /Handled bill/+ assert_select links.first, "p.font-medium.text-secondary.privacy-sensitive", text: /\$30\.00/+ # text-subdued is about 2.7:1 on white; notes have to stay readable.+ assert_select links.first, "p.text-secondary", text: "Card ending 4242"+ end+ assert_select BILL_ROW_LINK, text: /Power Co/ do |links|+ assert_select links.first, "p.font-medium.text-primary", text: /Power Co/+ assert_select links.first, "p.font-medium.text-primary.privacy-sensitive", text: /\$80\.00/+ end+ end+# Pause, inactive and paused were three words for one thing, and the filter# asked for the one the button never writes.test "a bill you paused is findable under Paused" do