Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
4.4 KB
Raw Blame

Design system

Consult app/assets/tailwind/sure-design-system.css and existing DS::* components before building UI.

  • Use functional tokens: text-primary, bg-container, border-primary, bg-warning/10, text-destructive. Do not use raw palette classes or hex literals.
  • Reach for DS::Alert, DS::Button, DS::Disclosure, DS::Dialog, DS::Menu and other existing primitives before making an alert, badge, button, disclosure, dialog or input shape.
  • If a diff contains the same hand-built shape at least twice and no DS equivalent exists, propose a new DS primitive before introducing the second copy.
  • Use the icon helper from ApplicationHelper, never lucide_icon directly. Raw SVG belongs only inside DS primitives.
  • Use scale tokens rather than arbitrary pixel values when a scale token fits.
  • Do not add new styles to sure-design-system.css or application.css without explicit permission.
  • Reviewers escalate DS reuse and repeated-shape violations to close/rewrite. Token, icon/SVG, localization and scale violations are request-changes.

For templates, Hotwire, Stimulus and localization guidance, see the UI guide.

Tables

Render data tables with DS::Table, not hand-written <table> markup. Declare each column once; the table renders the header and every cell with the standard padding, header style and row rules.

<%= render DS::Table.new(rows: payments) do |table| %>
  <% table.with_column(t(".date")) { |payment| l(payment.date, format: :long) } %>
  <% table.with_column(t(".amount"), numeric: true, class: "privacy-sensitive") { |payment| format_money(payment.amount) } %>
<% end %>
  • numeric: true for figures (right-aligned, tabular digits, no wrapping); align: :right for other right-hand columns such as actions.
  • inset: true when the table sits inside a card; its header row takes the frame's container-inset. On the page background the table is a card of its own.
  • sticky_header: true for long tables.
  • Pass label: whenever the table can scroll, including sideways on a narrow screen, so keyboard users can reach it.
  • A column block must output markup or return a String; call to_s on numbers.

Form actions

A form with one action ends in f.submit, which renders a full-width primary DS::Button on a styled_form_with form. A form with Cancel and a primary action ends in a right-aligned pair of natural-width buttons at the default size: Cancel, then the primary action. The variant carries the hierarchy, not the width.

<div class="flex justify-end gap-2">
  <%= render DS::Button.new(text: t(".cancel"), variant: :secondary, data: { action: "DS--dialog#close" }) %>
  <%= render DS::Button.new(text: t(".save"), type: :submit) %>
</div>
  • Cancel takes variant: :secondary or :ghost. A Cancel that leaves the page is a DS::Link with the same variant.
  • A destructive action takes variant: :destructive in the primary's place. f.submit is always primary, so a destructive single action is a DS::Button with full_width: true and type: :submit.
  • Don't put f.submit in a pair: it is always full width and ignores class:. Render the primary with type: :submit, as above.
  • Keep the default size. size: :sm text buttons are 28px tall, and the 44px coarse-pointer target only applies to icon-only buttons.
  • When a DS::Dialog's buttons don't submit a form, dialog.with_action renders this row; cancel_action: true makes a button close the dialog.
  • Examples: budget_categories/_move_dialog, goals/consume, the currencies dialog in settings/preferences/show, the bulk edit drawer and the filter popover.
  • Amount inputs stay left-aligned, as money_field renders them. Right alignment with tabular digits is for displayed figures (numeric: true above) and for inputs inside a column of them, such as the budget grid.