The personal finance app for everyone (by everyone)
Ruby
<% content_for :page_header do %>
<div class="space-y-1 mb-6 flex gap-4 justify-between items-center lg:items-start">
<div class="space-y-1">
<h1 class="text-xl lg:text-3xl font-medium text-primary">
<%= t("pages.dashboard.welcome", name: Current.user.first_name) %>
</h1>
<p class="text-sm lg:text-base text-secondary">
<%= t("pages.dashboard.subtitle") %>
</p>
</div>
<div class="flex items-center gap-2">
<% if accessible_accounts.any? %>
<% if @customizing_dashboard %>
<%= render DS::Link.new(
variant: "outline",
icon: "check",
text: t("pages.dashboard.customize.done"),
href: root_path(@dashboard_view_params)
) %>
<% else %>
<%= render DS::Link.new(
variant: "outline",
icon: "layout-grid",
href: root_path(@dashboard_view_params.merge(customize: true)),
aria: { label: t("pages.dashboard.customize.start") },
title: t("pages.dashboard.customize.start"),
class: "hidden lg:inline-flex"
) %>
<%= render DS::Link.new(
variant: "icon",
icon: "layout-grid",
href: root_path(@dashboard_view_params.merge(customize: true)),
aria: { label: t("pages.dashboard.customize.start") },
class: "rounded-full lg:hidden"
) %>
<% end %>
<% end %>
<%= render DS::Link.new(
icon: "plus",
text: t("pages.dashboard.new"),
href: new_account_path,
frame: :modal,
class: "hidden lg:inline-flex"
) %>
<%= render DS::Link.new(
variant: "icon-inverse",
icon: "plus",
href: new_account_path,
frame: :modal,
class: "rounded-full lg:hidden"
) %>
</div>
</div>
<% end %>
<%= turbo_frame_tag "dashboard_sections", target: "_top" do %>
<%= render "shared/exchange_rate_notes", family: Current.family, classes: "mb-4" %>
<% if accessible_accounts.any? %>
<div class="flex items-center justify-end mb-4">
<%# Keeps the widgets' own months and filters; a preset replaces any custom range. %>
<%= render UI::PeriodPicker.new(selected: @period, url: root_path, frame: "dashboard_sections", extra_params: @dashboard_view_params.except(:start_date, :end_date)) %>
</div>
<% end %>
<% if @customizing_dashboard && accessible_accounts.any? %>
<%= render DS::Card.new(class: "mb-6 gap-3") do %>
<div class="space-y-1">
<h2 class="text-base font-medium text-primary"><%= t("pages.dashboard.customize.hidden_title") %></h2>
<p class="text-sm text-secondary">
<%= @hidden_dashboard_sections.any? ? t("pages.dashboard.customize.hidden_description") : t("pages.dashboard.customize.none_hidden") %>
</p>
</div>
<% if @hidden_dashboard_sections.any? %>
<div class="flex flex-wrap gap-2">
<% @hidden_dashboard_sections.each do |section| %>
<%= render DS::Button.new(
variant: "outline",
size: "sm",
icon: "plus",
text: t(section[:title]),
href: dashboard_section_hidden_path(section[:key]),
method: :patch,
params: @dashboard_view_params.merge(hidden: false),
autofocus: @just_hidden_section == section[:key]
) %>
<% end %>
</div>
<% end %>
<% end %>
<% end %>
<% if accessible_accounts.any? && @dashboard_sections.empty? && !@customizing_dashboard %>
<%= render DS::Card.new(class: "mb-6") do %>
<%= render DS::EmptyState.new(
icon: "layout-grid",
title: t("pages.dashboard.customize.all_hidden_title"),
description: t("pages.dashboard.customize.all_hidden_description")
) do |empty_state| %>
<% empty_state.with_action do %>
<%= render DS::Link.new(
variant: "outline",
icon: "layout-grid",
text: t("pages.dashboard.customize.start"),
href: root_path(@dashboard_view_params.merge(customize: true))
) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% two_column = Current.user.dashboard_two_column? %>
<div class="grid grid-cols-1 <%= "2xl:grid-cols-2 2xl:items-start 2xl:gap-y-0 2xl:[grid-auto-flow:row_dense] 2xl:[grid-auto-rows:1px]" if two_column %> gap-6 pb-6 lg:pb-12" data-controller="sortable-list dashboard-masonry" data-sortable-list-url-value="<%= dashboard_preferences_path %>" data-sortable-list-param-value="preferences.section_order" data-sortable-list-hold-delay-value="800" data-sortable-list-drop-target-value="nearest" data-sortable-list-own-keys-only-value="true" data-action="dragover->sortable-list#dragOver drop->sortable-list#drop turbo:before-visit@window->sortable-list#saveBeforeVisit" role="list" aria-label="<%= t("pages.dashboard.sections_aria_label") %>">
<% if accessible_accounts.any? %>
<% @dashboard_sections.each do |section| %>
<section
class="bg-container rounded-xl shadow-border-xs transition-all group focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-900 focus-visible:ring-offset-2 [-webkit-touch-callout:none]<%= " 2xl:col-span-2" if two_column && section[:layout][:col_span] == "full" %>"
style="<%= "--dash-widget-h: #{section[:layout][:height_px]}px;" if section[:layout][:grow] %>"
data-sortable-list-target="item"
data-sortable-list-id="<%= section[:key] %>"
data-section-key="<%= section[:key] %>"
<%= "autofocus" if @just_shown_section == section[:key] %>
data-controller="dashboard-section<%= " cashflow-expand" if section[:key] == "cashflow_sankey" %>"
data-dashboard-section-section-key-value="<%= section[:key] %>"
data-dashboard-section-collapsed-value="<%= Current.user.dashboard_section_collapsed?(section[:key]) %>"
draggable="true"
tabindex="0"
role="listitem"
aria-grabbed="false"
aria-label="<%= t(section[:title]) %> section. Press Enter or Space to grab for reordering, then use arrow keys to move."
data-action="
dragstart->sortable-list#dragStart
dragend->sortable-list#dragEnd
touchstart->sortable-list#touchStart
touchmove->sortable-list#touchMove
touchend->sortable-list#touchEnd
touchcancel->sortable-list#touchCancel
contextmenu->sortable-list#suppressContextMenu
keydown->sortable-list#handleKeyDown">
<div class="px-4 py-2 flex items-center justify-between">
<div class="flex items-center gap-2">
<button
type="button"
class="flex items-center justify-center w-6 h-6 rounded-md text-secondary hover:text-primary hover:bg-container-inset-hover transition-colors"
data-action="click->dashboard-section#toggle keydown->dashboard-section#handleToggleKeydown"
data-dashboard-section-target="button"
aria-label="<%= t("pages.dashboard.toggle_section") %>"
aria-expanded="<%= !Current.user.dashboard_section_collapsed?(section[:key]) %>">
<%= icon("chevron-down", size: "sm", class: "transition-transform", data: { dashboard_section_target: "chevron" }) %>
</button>
<h2 class="text-base font-medium">
<%= t(section[:title]) %>
</h2>
</div>
<div class="flex items-center gap-1">
<%# Expand/Collapse-all for the balance sheet, as the leftmost
icon in the header's hover cluster. Wired by the inline script
in _balance_sheet.html.erb (which finds it via this section). %>
<% if section[:key] == "balance_sheet" && @balance_sheet.classification_groups.any? { |cg| cg.account_groups.any? } %>
<button
type="button"
class="flex items-center justify-center w-6 h-6 rounded-md text-secondary hover:text-primary hover:bg-container-inset-hover transition-colors opacity-0 group-hover:opacity-100"
data-balance-sheet-expand-all="true"
data-expand-label="<%= t("pages.dashboard.balance_sheet.expand_all") %>"
data-collapse-label="<%= t("pages.dashboard.balance_sheet.collapse_all") %>"
aria-expanded="false"
aria-label="<%= t("pages.dashboard.balance_sheet.expand_all") %>">
<span data-icon="expand" aria-hidden="true"><%= icon("chevrons-up-down", size: "sm", class: "!w-3.5 !h-3.5") %></span>
<span data-icon="collapse" aria-hidden="true" style="display:none"><%= icon("chevrons-down-up", size: "sm", class: "!w-3.5 !h-3.5") %></span>
</button>
<% end %>
<% if section[:key] == "cashflow_sankey" && section[:locals][:sankey_data][:links].present? %>
<button
type="button"
class="flex items-center justify-center w-6 h-6 rounded-md text-secondary hover:text-primary hover:bg-container-inset-hover transition-colors opacity-100 lg:opacity-0 lg:group-hover:opacity-100 ml-auto lg:ml-0"
data-action="click->cashflow-expand#open"
aria-label="<%= t("global.expand") %>">
<%= icon("maximize-2", size: "sm", class: "!w-3.5 !h-3.5") %>
</button>
<% end %>
<% if @customizing_dashboard %>
<% hide_label = t("pages.dashboard.customize.hide", title: t(section[:title])) %>
<%= render DS::Button.new(
variant: "icon",
size: "sm",
icon: "eye-off",
href: dashboard_section_hidden_path(section[:key]),
method: :patch,
params: @dashboard_view_params.merge(hidden: true),
aria_label: hide_label,
title: hide_label
) %>
<% end %>
<% layout = section[:layout] %>
<% show_width = layout[:width_toggle] && two_column %>
<% if layout[:grow] || show_width %>
<details
class="relative hidden lg:block"
data-controller="dashboard-widget-size"
data-dashboard-widget-size-section-key-value="<%= section[:key] %>"
data-action="keydown->dashboard-widget-size#stopKeydown">
<summary
class="focus-ring list-none cursor-pointer flex items-center justify-center w-6 h-6 rounded-md text-secondary hover:text-primary hover:bg-container-inset-hover transition-colors opacity-0 group-hover:opacity-100 [&::-webkit-details-marker]:hidden"
aria-label="<%= t("pages.dashboard.widget_size.label") %>">
<%= icon("sliders-horizontal", size: "sm", class: "!w-3.5 !h-3.5") %>
</summary>
<div class="absolute right-0 top-full mt-1.5 z-10 w-48 p-2.5 space-y-2.5 bg-surface rounded-xl shadow-border-xs border border-primary">
<% if show_width %>
<div class="space-y-1.5">
<p class="flex items-center gap-1.5 text-xs font-medium text-secondary">
<%= icon("move-horizontal", size: "xs") %>
<%= t("pages.dashboard.widget_size.width_label") %>
</p>
<%= render DS::SegmentedControl.new(full_width: true, aria_label: t("pages.dashboard.widget_size.width_label")) do |sc| %>
<% { "single" => "half", "full" => "full" }.each do |value, i18n_key| %>
<% sc.with_segment(
t("pages.dashboard.widget_size.#{i18n_key}"),
active: layout[:col_span] == value,
data: { action: "dashboard-widget-size#selectWidth", col_span: value }
) %>
<% end %>
<% end %>
</div>
<% end %>
<% if layout[:grow] %>
<div class="space-y-1.5">
<p class="flex items-center gap-1.5 text-xs font-medium text-secondary">
<%= icon("move-vertical", size: "xs") %>
<%= t("pages.dashboard.widget_size.height_label") %>
</p>
<%= render DS::SegmentedControl.new(full_width: true, aria_label: t("pages.dashboard.widget_size.height_label")) do |sc| %>
<% PagesController::DASHBOARD_HEIGHT_PRESETS.each do |preset, px| %>
<% sc.with_segment(
t("pages.dashboard.widget_size.#{preset}"),
active: layout[:height_preset] == preset,
data: { action: "dashboard-widget-size#selectHeight", preset: preset, height: px }
) %>
<% end %>
<% end %>
</div>
<% end %>
</div>
</details>
<% end %>
<%# A grab surface, not a button — clicking it does nothing. It keeps
cursor-grab and the colour shift, and deliberately skips the hover
background the other header controls use: a filled hover state
reads as "clickable" and would promise a click that never lands.
Still sized to the same 24px box so the icons stay aligned. Keys
only grab the section itself, so it stays out of the tab order. %>
<span
class="cursor-grab active:cursor-grabbing hidden lg:flex items-center justify-center w-6 h-6 text-secondary hover:text-primary transition-colors opacity-0 group-hover:opacity-100"
aria-hidden="true">
<%= icon("grip-vertical", size: "sm") %>
</span>
</div>
</div>
<div class="py-4" data-dashboard-section-target="content">
<%= render partial: section[:partial], locals: section[:locals] %>
<%# Preview features reveal the opt-in. The comparison chart itself
stays hidden until this user turns that preference on. %>
<% if section[:key] == "cashflow_sankey" && preview_features_enabled? %>
<%= render "pages/dashboard/cashflow_preview_opt_in" %>
<% if Current.user.cashflow_preview_enabled? %>
<%= render "pages/dashboard/cashflow_preview", period: @period, legacy_data: section[:locals][:sankey_data] %>
<% end %>
<% end %>
</div>
</section>
<% end %>
<% else %>
<section>
<%= render "pages/dashboard/no_accounts_graph_placeholder" %>
</section>
<% end %>
</div>
<% end %>