The personal finance app for everyone (by everyone)
Ruby
Document form action buttons in the design system guide (#4313)
Guillem Arias Fauste7917bc1e4dfa
diff --git a/docs/llm-guides/design-system.md b/docs/llm-guides/design-system.mdindex b2bb8536a4..67b519f838 100644--- a/docs/llm-guides/design-system.md+++ b/docs/llm-guides/design-system.md@@ -42,3 +42,39 @@ header and every cell with the standard padding, header style and row rules.- Pass `label:` whenever the table can scroll, including sideways on a narrowscreen, 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`](../../app/helpers/styled_form_builder.rb),+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.++```erb+<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`](../../app/components/DS/dialog.rb)'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`](../../app/views/budget_categories/_move_dialog.html.erb),+ [`goals/consume`](../../app/views/goals/consume.html.erb), the currencies+ dialog in [`settings/preferences/show`](../../app/views/settings/preferences/show.html.erb),+ the [bulk edit drawer](../../app/views/transactions/bulk_updates/new.html.erb)+ and the [filter popover](../../app/views/transactions/searches/_menu.html.erb).+- 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.