diff --git a/dashboard/DESIGN.md b/dashboard/DESIGN.md new file mode 100644 index 00000000..adaf8fc3 --- /dev/null +++ b/dashboard/DESIGN.md @@ -0,0 +1,146 @@ +# Dashboard design system + +One type ramp, one spacing scale, a handful of radii and semantic colors, so +every page reads as the same product. The values live in +[`src/app/tokens.css`](src/app/tokens.css) (CSS variables plus Tailwind's +`@theme`); code that cannot take a class (charts, QR codes, Mermaid, the +highlighter) reads the same values from [`src/lib/tokens.ts`](src/lib/tokens.ts). +`npm run lint` holds the rest of the code to them. + +## Type + +The root is the browser's 16px, so `1rem` is 16px. Seven sizes, each with a +fixed line height on the 4px grid: + +| Class | Size / line height | Use | +|---|---|---| +| `text-xs` | 13 / 18 | captions, metadata, badges, table headers, timestamps | +| `text-sm` | 15 / 22 | body, controls, list rows, section titles (16 / 24 on a phone) | +| `text-base` | 16 / 24 | lead text; fields on a phone | +| `text-lg` | 18 / 26 | the title of a card that is the page's subject | +| `text-xl` | 20 / 28 | a dialog's or an empty state's title | +| `text-2xl` | 24 / 32 | the page title (`` draws it) | +| `text-3xl` | 32 / 40 | a headline number on a stat tile | + +Three weights: `font-normal` (400) for reading, `font-medium` (500) for +labels, buttons and names, `font-semibold` (600) for titles. Nothing bolder. + +Semantic styles, size and weight only (add the color separately): + +| Class | What it is | +|---|---| +| `text-page-title` | 24 / 32 semibold, tracking tight | +| `text-section-title` | 15 / 22 semibold (``) | +| `text-body` | 15 / 22 normal | +| `text-caption` | 13 / 18 normal; pair with `text-fg-muted` | +| `text-data` | 13 / 18 mono, tabular numbers: ids, shas, durations in tables | +| `text-numeric` | tabular, lining figures for counts that line up | +| `text-display` | 32 / 40 semibold, tabular: a headline number | +| `text-code-inline` | 13px: inline code inside running text, keeping the line's height | + +"Secondary" text is body size in `text-fg-muted`. + +## Spacing + +Tailwind's steps on a 4px grid. Padding, margin and gap use only: +`0, px, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24` +(0 to 96px). A value built from a token or the safe area +(`pb-[calc(var(--bottom-bar)+1rem)]`) is fine; `mt-[7px]` and `p-3.5` are not. + +The page rhythm, the same on every page: + +- the shell's gutter: 16px on a phone, 32px from `md:` (`
`); +- ``, then **24px**, then the content (globals.css holds the + first block under the header to it, whatever margin it asks for); +- **40px** between titled sections (`
`, `mt-10`); +- **12px** from a section's heading to its body; +- cards pad **16px** (`cardClass`, `p-4`); a list row pads `px-4 py-3`; +- **8px** between related controls (`gap-2`), **12px** between groups (`gap-3`). + +## Lists, rails and groups + +The places a page most often drifts: + +- **A row's title** is `text-sm font-medium text-fg` (15px), its metadata + `text-xs text-fg-muted` (13px). A row title is never `text-base` or larger. +- **A group header** in a list ("Waiting on you 3") is ``: + `text-section-title` in sentence case with its count in `text-fg-muted`. + No uppercase overlines, no `tracking-wide` headers. +- **A number in a side rail or a summary row** is `text-lg font-semibold + text-numeric` (18px). `text-display` (32px) is only for the one headline + number of a stat tile. +- **Buttons in a row or a card** are `buttonClass(variant, "sm")` (32px); + the page's own actions beside its title are `"md"` (36px). One size per row. + +## Radii + +| Class | Size | Use | +|---|---|---| +| `rounded-sm` | 4px | badges, chips, keys, inline code | +| `rounded-md` | 6px | buttons, fields, menu items | +| `rounded-lg` | 8px | cards, panels, list boxes, menus, popovers, toasts | +| `rounded-xl` | 12px | dialogs and sheets | +| `rounded-full` | | pills, dots, avatars | + +## Colors + +Semantic names only; the palette (`zinc-400`, `amber-300`) is counted by the +lint and may only go down. Values are in `:root` so a light theme later +redefines `--ch-*` and nothing else changes. + +| Role | Classes | +|---|---| +| Surfaces | `bg-canvas` (page), `bg-surface` (card), `bg-raised` (menu, dialog, sheet), `bg-inset` (a well inside a card), `bg-control` / `bg-control-hover` (secondary button, chip), `bg-hover` (row and ghost hover), `bg-inverse` / `bg-inverse-hover` (primary button), `bg-scrim` (behind a dialog) | +| Lines | `border-line` (cards, dividers), `border-line-strong` (fields), `border-line-emphasis` (hover, selected) | +| Text | `text-fg-strong` (titles), `text-fg` (body), `text-fg-secondary`, `text-fg-muted` (secondary, captions), `text-fg-subtle` (15px and up only), `text-fg-disabled` (disabled only), `text-fg-inverse` (on `bg-inverse`) | +| Status | `good`, `warn`, `bad`, `info`, plus `severe` (high severity) and `done` (merged, pull requests): `text-warn`, `text-warn-strong`, `bg-warn-solid` (dots, bars), `bg-warn-soft`, `border-warn-line` | +| Accent | CoderHelm blue: `text-accent`, `bg-accent-solid`, `bg-accent-soft`, `border-accent-line` | +| Charts | `SERIES` / `CHART` from `src/lib/tokens.ts`; `bg-chart-1`, `bg-chart-2` for legends | + +A badge is `rounded-sm border border--line bg--soft px-1.5 text-xs text-`. + +## Elevation + +Only what floats casts a shadow: `shadow-popover` (menus, popovers, +toasts) and `shadow-dialog` (dialogs, sheets). Cards on the page have a +border and no shadow. + +## Components + +Use the shared pieces before writing classes: ``, ``, +`
`, ``, `cardClass` (components/page.tsx); +`buttonClass(variant, size)` and `inputClass` (components/ui.ts); +``, ``, `({ list, labels, layout, onChange, group }: { lis onChange={(e) => onChange(list, e.target.checked ? layout.hidden.filter((h) => h !== k) : [...layout.hidden, k])} className={`h-4 w-4 ${focusRing}`} /> - {label} + {label} - @@ -114,18 +114,18 @@ export function GiveSheet({ <>

- {preview.points != null && {preview.points} pt} - Nothing starts until you confirm + {preview.points != null && {preview.points} pt} + Nothing starts until you confirm

-

Plan preview

-

+

Plan preview

+

{preview.plan.text}

{preview.criteria.length > 0 && ( <> -

What the ticket asks for:

-
    +

    What the ticket asks for:

    +
      {preview.criteria.map((c) => (
    1. {c}
    2. ))} @@ -134,27 +134,27 @@ export function GiveSheet({ )}
-

Repositories it will touch

+

Repositories it will touch

{preview.repos.length ? (

{preview.repos.map((r) => ( - + {r} ))}

) : ( -

Not known yet: CoderHelm picks it from the ticket and the code first.

+

Not known yet: CoderHelm picks it from the ticket and the code first.

)} - {preview.files.length > 0 &&

{preview.files.join(", ")}

} + {preview.files.length > 0 &&

{preview.files.join(", ")}

}
{preview.fit.why.length > 0 && (
-

What it has

+

What it has