Files
xenia-pos-local/docs/DESIGN.md
T

5.5 KiB
Raw Blame History

Design language (on-site frontends)

The rules every screen of the manager (and later the terminal and the waiter app) follows, so the product looks like one thing. Read this before writing or changing any page, dialog or component. Change a rule here first, then in packages/ui, never in one page. Started 2026-11-20 from the owner's UI review (modelled on the BellSystems control panel's DESIGN.md).

1. Principles

  • Global, never local. Anything that two pages need is a component or a token in @xenia/ui (packages/ui). If a page needs a new look, add it to @xenia/ui and use it from there. Never rebuild a dropdown, a tab strip or a page frame inside a page.
  • Tokens only. Colours, sizes, radii, paddings and heights come from packages/ui/src/tokens.css (Tailwind names from tailwind-preset.js). No hex or rgb values in app code (see also CS-16).
  • Same height in a row. Controls that sit side by side (a search box, dropdowns, chips, buttons) share one height: md (44 px, --x-control-md) unless the whole row is sm.
  • Quiet secondary text. text-ink-2 / text-ink-3 are muted on purpose. Don't make subtitles, hints or labels darker to make them stand out.

2. The page rule

Every page's root is <Page> from @xenia/ui. It provides:

  • its own scrolling (the shell's <main> never scrolls),
  • the width: it fills the content area up to the width of a 16:9 screen (--x-page-max = max(1280px, 100vh × 16/9)). On a 1080p monitor the page fills the screen; on an ultrawide it stays 16:9 wide and is centred,
  • the padding and gaps (--x-page-pad, --x-page-gap), the same on every page.
<Page testId="contacts-page">
  <PageHeader title="…" subtitle="…" actions={<Button>New</Button>} />
  <Toolbar>
    <SearchInput value={q} onChange={setQ} placeholder="…" />
    <Dropdown multiple value={kinds} onChange={setKinds} allLabel="All kinds" options={…} />
  </Toolbar>
  <Panel padded={false}><Table … /></Panel>
</Page>
  • top={<Tabs … />} keeps a tab strip above the scrolling part (Online orders, Settings). The tab is kept in the address (?tab=).
  • width="form" for settings and forms (centred at --x-page-form-max, 880 px). Lists, tables and dashboards use the default (full).
  • Never put p-*, max-w-*, mx-auto, h-full or overflow-* on a page's root, and never nest a second width limit inside it.
  • Checked by tests/e2e/manager_layout.mjs (1920×1080 and 3440×1440: every page fills / is centred, and scrolls). Add a new page to its PAGES list.

Pages not on <Page> yet (own layouts, next review pass): Management → Products (category tree + list), Management → Tables (list + floor editor), Inventory → Stock (placeholder).

3. Components (@xenia/ui)

Need Use Notes
A page Page, PageHeader §2
Filters / actions over a list Toolbar, ToolbarSpacer every control in it the same height; the search box grows
Search SearchInput icon, clear button; onChange(text)
Choose one / several Dropdown (multiple) never a native <select> in a toolbar. Multi: value is an array, [] = all (allLabel). Options can carry a dot (a zone's colour) and a hint. Search box from 9 options. Same heights as Input. Native Select stays only inside forms where the phone's own picker is better
A toggle filter (a state) FilterChip (tone, count)
Two or three views (List / Map / QR) Segmented the view in the address (?view=)
Sections of a page or a dialog Tabs (size="lg" on pages) scrolls sideways only, never up/down
A help tip InfoTip opens on hover (mouse) and on tap
Dialogs Dialog sm 400 · md 520 · lg 720 · xl 920 the day summary is xl

The manager's own building blocks (until they move to @xenia/ui): Panel, Table, Stat in pages/reports/kit/parts.jsx; Card, Figure, Pill, SplitBar in pages/overview/parts.jsx.

4. Type and spacing tokens

Token / class Value Use
text-overline + font-semibold uppercase tracking-wide text-ink-3 11 px the small labels over figures and sections ("REVENUE", "TOTAL"). Never text-caption for these
text-caption 12 px hints, sub-lines
text-label 13 px rows in summaries, table cells, chips
text-body 14 px body text
p-card, px-card, py-card-y 20 px / 14 px inside every card, panel and section: header rows (px-card py-card-y) and bodies (p-card)

5. Tables

  • Table cells are vertically centred (align-middle): a one-line cell sits in the middle of a two-line row.
  • Row actions last, right-aligned, IconButton size="sm" variant="ghost".
  • A column's help is tip (an InfoTip in the header, opens on hover).

6. Before you finish a UI change

  1. npm run build:manager and npm run lint -w manager-dashboard pass.
  2. npm test -w @xenia/ui (contrast in every look) passes.
  3. node tests/e2e/manager_layout.mjs passes; look at its screenshots in tests/e2e/out/manager-layout/.
  4. Live preview while working: npx vite --port 5184 in manager_dashboard/ (hot reload, uses the running backend on :8000; touches nothing in Docker). After a change to packages/ui/tailwind-preset.js, restart every running dev server. Vite reloads CSS and components, but Tailwind reads the preset only at start: a server started before the change never makes the new classes (p-card, text-overline, max-w-page …), and cards lose all their padding.