Owner review 2026-11-23 of every widget: - A widget card is its main settings (the row and what needs room under it: pictures, a gallery's pictures or folder, weather details and place, a countdown's start and end, reviews' stars and author, a scrolling text's speed, a shape's colours and border, QR caption), then "Text and colours" (new LookFields.jsx: text colour, plate, font, style, size, weight, highlight, shadow, QR colours; a logo's / gallery's border), then More settings (opacity, rotation, animation, fit, typing, blink, QR logo; shadow / border only where there is no Text and colours). - Date format / separator and clock 12/24 / separator are main settings. - Alignment only where it lines something up; the TV now aligns the lines of a text, the hours (centre: days and times meet in the middle), contact rows, Wi-Fi (code left / right / above), the weather's column / card / list / hourly, reviews (stars too), a countdown, a QR caption. - Text and message: a 2-line textarea in its own row; Enter makes new lines (the TV sizes by the longest line and the number of lines). - Gallery: a title above or below the pictures (title_position). - A widget's box may reach 400 % of the slide (a logo zoomed in past the slide's edges saved again). - "Auto" stays "Auto" in Greek; scrolling text Left / Right; reviews' stars choice no longer clipped; countdown "When it ends" hint as an info tip (fields level). Calibration: an edge may go past the recognised window (down to -2000 px); the dialog's rows are centred, "Each click moves" sits above its choice, the window size is labelled "Recognised resolution" with what it means; the TV asks for its screen answer on every calibrate event and while calibrating (the outline shows the first time), the dialog sends "on" again after 1.5 s. NumberInput takes a leading minus when min < 0. E2E: waits for the Add-a-slide dialog to go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
103 lines
11 KiB
Markdown
103 lines
11 KiB
Markdown
# 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 2200 px (`--x-page-max`). On a 1080p monitor the page fills the screen; on an ultrawide it stays 2200 px wide and is **centred**. The width never depends on the window's height (owner 2026-11-21: a short window used to narrow the page),
|
||
- **the padding and gaps** (`--x-page-pad`, `--x-page-gap`), the same on every page.
|
||
|
||
```jsx
|
||
<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=`).
|
||
- `header={<PageHeader … />}` with `top`: the page's title and description come **first**, then the tabs (Offers & pricing). Each tab then starts with its own head: title, description, its "New" button at the top right.
|
||
- `fit`: the page is exactly the screen's height and doesn't scroll; its `Pane`s do, each on its own (Products). Put them in an element with `x-page__fill`. Phones scroll as usual.
|
||
- The scrollbar's room is always kept (`scrollbar-gutter: stable`), so a short tab is exactly as wide as a long one.
|
||
- `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.
|
||
|
||
Every page is on `<Page>` except Inventory → Stock (a placeholder). Two-column pages put each side in its own container. Products is a `Page fit` with two `Pane`s (header and footer stay, only the list scrolls; the list's body `sunken`, a shade darker, so the white product rows stand out). The floor editor: the map and its panels, the narrow side `sticky`.
|
||
|
||
## 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 small panel under a button | `Popover` (`open`, `anchor` = the button's ref, `onClose`) | a colour picker, an "Add…" menu. Drawn over everything (portal), flips above, stays inside the window: **never an `absolute` panel inside a section** (it is clipped and makes the section scroll) |
|
||
| A colour (a venue's: data) | `ColourField` (`auto`, `opacity`, `presets`) | a field with its swatch and code; its panel (over the page) has 12 ready colours, the picker, the opacity (`#rrggbbaa`) and the code. `auto` = a first choice that leaves it to something else ("As the slide"). **Never** a bare `<input type="color">` |
|
||
| An icon from a set | `IconPicker` (`icons` = { key: component }) | a field showing the icon; a grid of the set over the page, "No icon" first |
|
||
| A whole number (seconds, counts) | `NumberInput` (`min`, `max`, `suffix`) | − / + on its sides, as tall as an input; it may be emptied while typing (`onChange(null)`): the form shows the error and blocks saving. **Never** clamp on every key (the user can't clear the field). With a `min` below 0 a minus may be typed in front |
|
||
| A note in a box (what works, a caution) | `Notice` (`tone`, `title`, `icon`, `items` = [{ tone, label, text }]) | a tinted box with a bar on its left; `items` are points with a tone dot and a bold label. **Never** a local `bg-info-soft` paragraph rebuilt per page |
|
||
| A slider with its value | `Slider` (`suffix`) | framed and as tall as the fields beside it; the value sits as close to it as the frame's padding. **Never** a bare `<input type="range">` |
|
||
| Fields that should wrap | `FieldRow` (`min`, `shade` on every other row) | each field keeps its least width; a row that wraps is framed (and tinted with `shade`), a row on one line looks like any row |
|
||
| Toggles that go together (bold / italic / underline) | `Segmented multiple` | value is an array |
|
||
| 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. `inset`: the strip is a card's header (card padding at the sides, the same room above and below a button in `end`, the labels level with it, no line under it). `fill`: the tabs share the width equally (a narrow column) |
|
||
| A container whose list scrolls | `Pane` (`header`, `footer`, `sunken`) | header and footer stay, the body scrolls; one side of a `Page fit` |
|
||
| A help tip | `InfoTip` | opens on hover (mouse) and on tap. Beside a switch: `Switch info={<InfoTip>…}` puts it right after the text, never after the switch |
|
||
| Row actions that stand apart | `IconButton tone` | `danger` delete / archive · `warning` block · `info` zones · `accent` edit · `success` unblock: a **grey** square at rest; under the pointer it lights up in its colour (soft background, coloured icon). Every row action of a row has a tone, so they all look the same at rest. Neutral actions stay `ghost` |
|
||
| A quiet text action that warns | `Button variant="ghost" tone="danger"` | grey text, red under the pointer ("Remove" a picture) |
|
||
| A switch on its own in a row of buttons | `Switch` without a label | lines up with the buttons (centred), never with a text baseline |
|
||
| Dialogs | `Dialog` `sm` 400 · `md` 520 · `lg` 720 · `xl` 920 · `wide` (~88 % of a 16:9 screen, capped on ultrawides) | the day summary is `xl`, the product editor `wide` |
|
||
| Ask before doing something (delete, leave unsaved work) | `useConfirm()` → `confirm({ title, body, confirmLabel, tone })` (or `ConfirmDialog`) | **never the browser's `window.confirm`**; render the returned dialog in the component. Leaving unsaved work: add `altLabel` ("Save and leave"): the promise answers `'alt'` |
|
||
| A switch in a row of fields | `Switch boxed` | framed and as tall as an input: text left, switch right; a click anywhere in the frame toggles it |
|
||
| Two or three choices that fill a form column (alignment…) | `Segmented fill` | options share the width; icon-only options pass `ariaLabel` |
|
||
| A side drawer | `Sheet side="right"` (`size="wide"`: 600 px) | the permissions editor is `wide` |
|
||
| Something that stays at the top of a dialog or drawer | `toolbar` (Dialog / Sheet) | under the title, doesn't scroll: the permissions' search box |
|
||
| A control beside a dialog's close button | `headerEnd` (Dialog / Sheet) | the product editor's language picker |
|
||
| A toggle on a row (several, compact…) | `FilterChip size="sm" tone pressed` | takes its colour when on; a toned `IconButton` with `aria-pressed` (the favourite's heart) keeps its colour while on |
|
||
| Print only this | `PrintArea` (+ `PrintSheet` for cards to cut out) | rendered into `<body>`, hidden on screen; while mounted, printing prints only it. One per page |
|
||
| Section titles inside a panel or drawer | `text-overline font-semibold uppercase tracking-wide text-ink-3` + a `flex-1 border-t border-line` rule after it | as the navigation's group titles |
|
||
|
||
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.
|