diff --git a/dashboard/DESIGN.md b/dashboard/DESIGN.md new file mode 100644 index 00000000..f0fb6687 --- /dev/null +++ b/dashboard/DESIGN.md @@ -0,0 +1,147 @@ +# 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); +``, ``, `
- +
-
)} -

+

Every call the app makes is checked against your role and written to the team's log. See and remove connected apps in{" "} - + Settings, Connected AI apps . @@ -232,10 +232,10 @@ function Consent() { function ScopeWords({ s }: { s: Pick }) { return ( - {s.plain ? {s.plain}: : null} + {s.plain ? {s.plain}: : null} {s.label} {s.opens && s.opens.length > 0 && ( - + Opens {s.opens.join(", ")} )} @@ -247,10 +247,10 @@ function LookupChoice({ s, checked, onChange }: { s: LookupScope; checked: boole const id = useId(); return (

  • - onChange(e.target.checked)} /> -
  • ); diff --git a/dashboard/src/app/chat/answer.tsx b/dashboard/src/app/chat/answer.tsx index e3d9329b..1a543edf 100644 --- a/dashboard/src/app/chat/answer.tsx +++ b/dashboard/src/app/chat/answer.tsx @@ -54,7 +54,7 @@ import { // The mini map's frame, loaded only when an answer has a map. const AnswerMapFrame = dynamic(() => import("./answer-map"), { ssr: false, - loading: () =>
    , + loading: () =>
    , }); // One answer, the way the best answer pages read: @@ -119,7 +119,7 @@ export function AnswerMap({ map }: { map: ChatMap }) { return (
    -

    +

    From the app map: {map.parts.length === 1 ? "1 part" : `${map.parts.length} parts`}

    @@ -198,18 +198,18 @@ function SourceCard({ doc }: { doc: SourceDoc }) { const code = isCode(doc); return (
    -
    +
    {whereOf(doc)}
    -

    {c.title}

    +

    {c.title}

    {c.passage && (code ? ( - + ) : ( -

    {excerpt(doc, 6)}

    +

    {excerpt(doc, 6)}

    ))} {c.authoritative && (

    @@ -218,12 +218,12 @@ function SourceCard({ doc }: { doc: SourceDoc }) { )} {open && (open.external ? ( - + {open.label} ) : ( - + {open.label} ))} @@ -255,7 +255,7 @@ function CiteMarker({ doc }: { doc: SourceDoc }) { onClick={() => setOpen((o) => !o)} onMouseEnter={() => fine() && hover(true)} onMouseLeave={() => fine() && hover(false)} - className={`relative -top-[0.35em] mx-[0.1em] inline-flex h-[1.15rem] min-w-[1.15rem] items-center justify-center rounded-[0.3rem] px-1 align-baseline text-[0.66rem] font-semibold tabular-nums leading-none transition-colors motion-reduce:transition-none ${open ? "bg-zinc-200 text-zinc-900" : "bg-zinc-800 text-zinc-300 hover:bg-zinc-700 hover:text-zinc-100"} ${focusRing}`} + className={`relative -top-[0.35em] mx-0.5 inline-flex h-[1.15rem] min-w-[1.15rem] items-center justify-center rounded-sm px-1 align-baseline text-xs font-semibold tabular-nums leading-none transition-colors motion-reduce:transition-none ${open ? "bg-inverse text-fg-inverse" : "bg-control text-fg-secondary hover:bg-control-hover hover:text-fg"} ${focusRing}`} > {doc.n} @@ -283,7 +283,7 @@ export function SourceList({ docs, onOpen }: { docs: SourceDoc[]; onOpen: (d: So const shown = all ? docs : docs.slice(0, SHOWN_SOURCES); return (

    -

    Sources

    +

    Sources

      {shown.map((d) => { const c = d.parts[0]; @@ -293,15 +293,15 @@ export function SourceList({ docs, onOpen }: { docs: SourceDoc[]; onOpen: (d: So type="button" onClick={() => onOpen(d)} data-testid="source" - className={`group flex w-full min-w-0 items-baseline gap-2.5 rounded-lg px-2 py-1.5 text-left hover:bg-zinc-900 ${focusRing}`} + className={`group flex w-full min-w-0 items-baseline gap-2.5 rounded-lg px-2 py-1.5 text-left hover:bg-raised ${focusRing}`} > - {d.n} -