feat(ui): board design language as global tokens; KDS on tokens and shared components (platform-v2 3.2b-2)
- @xenia/ui: --x-board-* tokens (the kitchen display's look: dark board, light cards, status colours, card radius/shadows, number font), Tailwind board.* colours, contrast test for the board pairs; near-identical shades merged. - New shared Stepper component (gallery + ui.mjs), labels ui.decrease / ui.increase. - KDS: theme.js maps to the board tokens, no colour literals left (only stored setting values); decline / call waiter / settings use Dialog, Button, Switch, Select, Stepper; toasts are @xenia/ui toasts (ToastProvider at the terminal root). - Terminal: apps can set their theme (APP_THEMES, KDS dark) while they run. - CS-16: board screens and "no hard-coded colours in app code". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -171,7 +171,7 @@ Paired devices (D-8, `routers/devices.py`, `core/access/context.py`) send `X-Xen
|
|||||||
Manager override (D-10, `core/access/override.py`): mark a key `Perm(..., overridable=True)` and a user without it gets `access.override_possible`; the client gets a manager's one-time token from `POST /api/access/override {key, username, pin}` and retries with `X-Xenia-Override`. `require()` routes handle it in `check()`; an endpoint with its own rule calls `require_override(request, db, key, target="order:12")` where the rule says no, **after** its other checks (a used token is spent).
|
Manager override (D-10, `core/access/override.py`): mark a key `Perm(..., overridable=True)` and a user without it gets `access.override_possible`; the client gets a manager's one-time token from `POST /api/access/override {key, username, pin}` and retries with `X-Xenia-Override`. `require()` routes handle it in `check()`; an endpoint with its own rule calls `require_override(request, db, key, target="order:12")` where the rule says no, **after** its other checks (a used token is spent).
|
||||||
|
|
||||||
**CS-16. Shared UI lives in `packages/ui` and never restyles an app** (branch `platform-v2`, D-15, §9).
|
**CS-16. Shared UI lives in `packages/ui` and never restyles an app** (branch `platform-v2`, D-15, §9).
|
||||||
Design tokens are CSS variables prefixed `--x-` (`packages/ui/src/tokens.css`), components use `.x-*` classes (`src/components.css`); neither file has element selectors, resets or anything that applies outside `.x-*` (the waiter keeps its own `--bg`/`--text`…; the manager's Tailwind classes keep their meaning). Theme comes from `data-theme` (`light`/`dark`/`system`) and `data-venue-theme` on `<html>`. Tailwind apps use `@xenia/ui/tailwind-preset` (adds `bg-surface`, `text-ink-2`, `rounded-control`… only). A colour change must pass `npm test -w @xenia/ui` (WCAG AA for every pair the components use, every venue theme, light and dark). Components take their visible text as props with English defaults until `@xenia/i18n` (2.4). New components get a section in `packages/ui/gallery/Gallery.jsx` (dev-only `/ui-gallery` in the manager) and checks in `tests/e2e/ui.mjs`.
|
Design tokens are CSS variables prefixed `--x-` (`packages/ui/src/tokens.css`), components use `.x-*` classes (`src/components.css`); neither file has element selectors, resets or anything that applies outside `.x-*` (the waiter keeps its own `--bg`/`--text`…; the manager's Tailwind classes keep their meaning). Theme comes from `data-theme` (`light`/`dark`/`system`) and `data-venue-theme` on `<html>`. Tailwind apps use `@xenia/ui/tailwind-preset` (adds `bg-surface`, `text-ink-2`, `rounded-control`… only). A colour change must pass `npm test -w @xenia/ui` (WCAG AA for every pair the components use, every venue theme, light and dark). Components take their visible text as props with English defaults until `@xenia/i18n` (2.4). New components get a section in `packages/ui/gallery/Gallery.jsx` (dev-only `/ui-gallery` in the manager) and checks in `tests/e2e/ui.mjs`. **Board screens** (the kitchen display, and any later screen in the same style) use the board design language: `--x-board-*` tokens in the same file (Tailwind `bg-board-bg`, `text-board-ink-2`…; always dark, contrast-tested too) for the board itself, and the normal components in `data-theme="dark"` for their dialogs, toasts and forms (the terminal sets an app's theme from `apps/registry.js` `APP_THEMES`). No hard-coded colours in app code: a colour that isn't a token yet becomes one (values the user stores, like a KDS screen's age colours, are data, not styling).
|
||||||
|
|
||||||
**CS-17. Frontend text is a key; dates are venue time** (branch `platform-v2`, D-11, D-12, §7.2, §8).
|
**CS-17. Frontend text is a key; dates are venue time** (branch `platform-v2`, D-11, D-12, §7.2, §8).
|
||||||
New UI text goes into `packages/i18n/locales/en/<ns>.json` first, then `el` (same keys, same `{{placeholders}}`), and is shown with `t()` from `@xenia/i18n` (`useTranslation`, re-exported). Dates and times are shown only through `useFormat()` (`formatTime`, `formatDateTime`, `formatDate`, `formatRelative`), which use the venue zone from bootstrap; money with `formatMoney`, numbers with `formatNumber`; typed numbers are read with `parseNumber` (comma or dot). Business dates (`YYYY-MM-DD`) go to `formatDate` as they are. `npm test -w @xenia/i18n` runs `scripts/check-i18n.mjs`, which fails on keys missing in English, placeholder mismatches, and `toLocale…String()` / `new Intl.DateTimeFormat(` without `timeZone` in new code (`packages/*`, `terminal/`); it warns for missing Greek. Module names, their limits and **every permission key** have texts in `modules.json` (`modules:<module>.name`, `.limits.<key>`, `.permissions.<rest of the key, nested by its dots>`); `tests/test_module_texts.py` fails for a new module or key without them in both languages. The v1 apps' Greek strings convert in phases 4 and 6. The `@xenia/ui` components get their texts from `<UiLabelsProvider labels={useUiLabels()}>` at the app root.
|
New UI text goes into `packages/i18n/locales/en/<ns>.json` first, then `el` (same keys, same `{{placeholders}}`), and is shown with `t()` from `@xenia/i18n` (`useTranslation`, re-exported). Dates and times are shown only through `useFormat()` (`formatTime`, `formatDateTime`, `formatDate`, `formatRelative`), which use the venue zone from bootstrap; money with `formatMoney`, numbers with `formatNumber`; typed numbers are read with `parseNumber` (comma or dot). Business dates (`YYYY-MM-DD`) go to `formatDate` as they are. `npm test -w @xenia/i18n` runs `scripts/check-i18n.mjs`, which fails on keys missing in English, placeholder mismatches, and `toLocale…String()` / `new Intl.DateTimeFormat(` without `timeZone` in new code (`packages/*`, `terminal/`); it warns for missing Greek. Module names, their limits and **every permission key** have texts in `modules.json` (`modules:<module>.name`, `.limits.<key>`, `.permissions.<rest of the key, nested by its dots>`); `tests/test_module_texts.py` fails for a new module or key without them in both languages. The v1 apps' Greek strings convert in phases 4 and 6. The `@xenia/ui` components get their texts from `<UiLabelsProvider labels={useUiLabels()}>` at the app root.
|
||||||
|
|||||||
@@ -32,7 +32,9 @@
|
|||||||
"notifications": "Ειδοποιήσεις",
|
"notifications": "Ειδοποιήσεις",
|
||||||
"backspace": "Διαγραφή",
|
"backspace": "Διαγραφή",
|
||||||
"pinProgress": "{{count}} από {{total}} ψηφία",
|
"pinProgress": "{{count}} από {{total}} ψηφία",
|
||||||
"submit": "OK"
|
"submit": "OK",
|
||||||
|
"decrease": "Λιγότερο",
|
||||||
|
"increase": "Περισσότερο"
|
||||||
},
|
},
|
||||||
"override": {
|
"override": {
|
||||||
"title": "Έγκριση υπευθύνου",
|
"title": "Έγκριση υπευθύνου",
|
||||||
|
|||||||
@@ -32,7 +32,9 @@
|
|||||||
"notifications": "Notifications",
|
"notifications": "Notifications",
|
||||||
"backspace": "Delete",
|
"backspace": "Delete",
|
||||||
"pinProgress": "{{count}} of {{total}} digits entered",
|
"pinProgress": "{{count}} of {{total}} digits entered",
|
||||||
"submit": "OK"
|
"submit": "OK",
|
||||||
|
"decrease": "Less",
|
||||||
|
"increase": "More"
|
||||||
},
|
},
|
||||||
"override": {
|
"override": {
|
||||||
"title": "Manager approval",
|
"title": "Manager approval",
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ export function useUiLabels() {
|
|||||||
moreInfo: t('ui.moreInfo'),
|
moreInfo: t('ui.moreInfo'),
|
||||||
notifications: t('ui.notifications'),
|
notifications: t('ui.notifications'),
|
||||||
backspace: t('ui.backspace'),
|
backspace: t('ui.backspace'),
|
||||||
|
decrease: t('ui.decrease'),
|
||||||
|
increase: t('ui.increase'),
|
||||||
submit: t('ui.submit'),
|
submit: t('ui.submit'),
|
||||||
pinProgress: (count, total) => t('ui.pinProgress', { count, total }),
|
pinProgress: (count, total) => t('ui.pinProgress', { count, total }),
|
||||||
}), [t, language]) // eslint-disable-line react-hooks/exhaustive-deps
|
}), [t, language]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
Button, Dialog, EmptyState, Field, IconButton, InfoTip, Input, PinPad, Select, Sheet,
|
Button, Dialog, EmptyState, Field, IconButton, InfoTip, Input, PinPad, Select, Sheet,
|
||||||
Spinner, Switch, Textarea, ToastProvider, useToast,
|
Spinner, Stepper, Switch, Textarea, ToastProvider, useToast,
|
||||||
} from '../src/index.js'
|
} from '../src/index.js'
|
||||||
import '../src/styles.css'
|
import '../src/styles.css'
|
||||||
|
|
||||||
@@ -44,6 +44,7 @@ function Demo() {
|
|||||||
const [locked, setLocked] = useState(false)
|
const [locked, setLocked] = useState(false)
|
||||||
const [sheet, setSheet] = useState(null)
|
const [sheet, setSheet] = useState(null)
|
||||||
const [on, setOn] = useState(true)
|
const [on, setOn] = useState(true)
|
||||||
|
const [step, setStep] = useState(30)
|
||||||
const [off, setOff] = useState(false)
|
const [off, setOff] = useState(false)
|
||||||
const [name, setName] = useState('')
|
const [name, setName] = useState('')
|
||||||
const [lang, setLang] = useState('el')
|
const [lang, setLang] = useState('el')
|
||||||
@@ -143,6 +144,7 @@ function Demo() {
|
|||||||
<Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="Send new items to the kitchen printer." />
|
<Switch checked={on} onChange={setOn} label="Print kitchen tickets" description="Send new items to the kitchen printer." />
|
||||||
<Switch checked={off} onChange={setOff} label="Alert after print failures" />
|
<Switch checked={off} onChange={setOff} label="Alert after print failures" />
|
||||||
<Switch checked disabled label="Disabled (on)" />
|
<Switch checked disabled label="Disabled (on)" />
|
||||||
|
<div style={row}><Stepper value={step} steps={[10, 15, 20, 30, 45, 60]} format={v => `${v}s`} onChange={setStep} label="Check every" /> <Stepper value={3} min={1} max={5} disabled label="Disabled" /></div>
|
||||||
<div style={row}>Alert after <InfoTip side="bottom">How many failed print attempts before managers are notified. 0 turns the alert off.</InfoTip></div>
|
<div style={row}>Alert after <InfoTip side="bottom">How many failed print attempts before managers are notified. 0 turns the alert off.</InfoTip></div>
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
@@ -271,6 +271,24 @@
|
|||||||
.x-select__control { appearance: none; -webkit-appearance: none; padding-right: var(--x-space-10); cursor: pointer; }
|
.x-select__control { appearance: none; -webkit-appearance: none; padding-right: var(--x-space-10); cursor: pointer; }
|
||||||
.x-select__chevron { position: absolute; right: var(--x-space-3); top: 50%; transform: translateY(-50%); color: var(--x-ink-3); pointer-events: none; }
|
.x-select__chevron { position: absolute; right: var(--x-space-3); top: 50%; transform: translateY(-50%); color: var(--x-ink-3); pointer-events: none; }
|
||||||
|
|
||||||
|
/* ── Stepper ─────────────────────────────────────────────────────────────── */
|
||||||
|
.x-stepper { display: inline-flex; align-items: center; gap: var(--x-space-1-5); flex-shrink: 0; }
|
||||||
|
.x-stepper__btn {
|
||||||
|
display: inline-flex; align-items: center; justify-content: center;
|
||||||
|
width: var(--x-control-md); height: var(--x-control-md); padding: 0;
|
||||||
|
border: 1px solid var(--x-line-strong); border-radius: var(--x-radius-control);
|
||||||
|
background: var(--x-surface-2); color: var(--x-ink); cursor: pointer;
|
||||||
|
transition: background-color var(--x-duration-fast) var(--x-ease);
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
.x-stepper__btn:hover:not(:disabled) { background: var(--x-surface-3); }
|
||||||
|
.x-stepper__btn:focus-visible { outline: none; box-shadow: var(--x-focus-ring); }
|
||||||
|
.x-stepper__btn:disabled { color: var(--x-ink-3); opacity: 0.5; cursor: default; }
|
||||||
|
.x-stepper__value {
|
||||||
|
min-width: 64px; text-align: center; font-family: var(--x-font-mono);
|
||||||
|
font-size: var(--x-text-body-lg); font-weight: var(--x-weight-bold); color: var(--x-ink);
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Switch ──────────────────────────────────────────────────────────────── */
|
/* ── Switch ──────────────────────────────────────────────────────────────── */
|
||||||
.x-switch {
|
.x-switch {
|
||||||
position: relative; flex-shrink: 0;
|
position: relative; flex-shrink: 0;
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { useLabels } from './labels.js'
|
||||||
|
|
||||||
|
const Icon = ({ d }) => (
|
||||||
|
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" aria-hidden="true"><path d={d} /></svg>
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* − value + for numbers picked in steps on a touch screen (plan step 3.2b-2).
|
||||||
|
* <Stepper value={30} steps={[10, 15, 20, 30, 45, 60]} format={v => `${v}s`} onChange={setSeconds} />
|
||||||
|
* <Stepper value={5} min={1} max={12} onChange={setMinutes} /> (step 1)
|
||||||
|
* With `steps`, the value snaps to the nearest step; min/max limit the steps too.
|
||||||
|
* aria: the value is announced (aria-live); label names the group.
|
||||||
|
*/
|
||||||
|
export function Stepper({ value, onChange, steps, min = -Infinity, max = Infinity, step = 1, format = String, label, disabled = false, className, ...rest }) {
|
||||||
|
const labels = useLabels()
|
||||||
|
const options = steps ? steps.filter(s => s >= min && s <= max) : null
|
||||||
|
const cur = options?.length ? options.reduce((a, b) => (Math.abs(b - value) < Math.abs(a - value) ? b : a)) : value
|
||||||
|
const i = options ? options.indexOf(cur) : -1
|
||||||
|
const canDec = !disabled && (options ? i > 0 : cur - step >= min)
|
||||||
|
const canInc = !disabled && (options ? i < options.length - 1 : cur + step <= max)
|
||||||
|
const dec = () => canDec && onChange?.(options ? options[i - 1] : cur - step)
|
||||||
|
const inc = () => canInc && onChange?.(options ? options[i + 1] : cur + step)
|
||||||
|
return (
|
||||||
|
<div role="group" aria-label={label} className={cx('x-stepper', disabled && 'x-stepper--disabled', className)} {...rest}>
|
||||||
|
<button type="button" className="x-stepper__btn" onClick={dec} disabled={!canDec} aria-label={labels.decrease}><Icon d="M5 12h14" /></button>
|
||||||
|
<span className="x-stepper__value" aria-live="polite">{format(cur)}</span>
|
||||||
|
<button type="button" className="x-stepper__btn" onClick={inc} disabled={!canInc} aria-label={labels.increase}><Icon d="M12 5v14M5 12h14" /></button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ export const DEFAULT_LABELS = {
|
|||||||
moreInfo: 'More info',
|
moreInfo: 'More info',
|
||||||
notifications: 'Notifications',
|
notifications: 'Notifications',
|
||||||
backspace: 'Delete',
|
backspace: 'Delete',
|
||||||
|
decrease: 'Less',
|
||||||
|
increase: 'More',
|
||||||
submit: 'OK',
|
submit: 'OK',
|
||||||
pinProgress: (n, total) => `${n} of ${total} digits entered`,
|
pinProgress: (n, total) => `${n} of ${total} digits entered`,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export { EmptyState } from './components/EmptyState.jsx'
|
|||||||
export { Spinner } from './components/Spinner.jsx'
|
export { Spinner } from './components/Spinner.jsx'
|
||||||
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||||
export { Switch } from './components/Switch.jsx'
|
export { Switch } from './components/Switch.jsx'
|
||||||
|
export { Stepper } from './components/Stepper.jsx'
|
||||||
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
|
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
|
||||||
export { cx } from './internal/cx.js'
|
export { cx } from './internal/cx.js'
|
||||||
export { THEMES, THEME_STORAGE_KEY, applyTheme, getStoredTheme } from './theme.js'
|
export { THEMES, THEME_STORAGE_KEY, applyTheme, getStoredTheme } from './theme.js'
|
||||||
|
|||||||
@@ -246,6 +246,94 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Board (the kitchen display's design language, plan step 3.2b-2) ───────
|
||||||
|
* A dark board with light cards, for screens read from a distance (kitchen, bar,
|
||||||
|
* and any later "board" screen). Always dark: it doesn't follow data-theme; the
|
||||||
|
* dialogs on a board use the normal components in data-theme="dark".
|
||||||
|
* The age colours here are only defaults: each KDS screen stores its own. */
|
||||||
|
:root {
|
||||||
|
--x-board-bg-rgb: 29 35 43; /* the board behind the cards */
|
||||||
|
--x-board-rail-rgb: 22 27 33; /* side rail, side panels */
|
||||||
|
--x-board-topbar-rgb: 32 39 47; /* top bar */
|
||||||
|
--x-board-line-rgb: 43 51 61; /* dividers, tabs, badges */
|
||||||
|
--x-board-deep-rgb: 10 14 19; /* action bars, text on light badges, scrims */
|
||||||
|
--x-board-ink-rgb: 231 236 242; /* text on the board */
|
||||||
|
--x-board-ink-2-rgb: 170 180 192; /* secondary text, tabs */
|
||||||
|
--x-board-ink-3-rgb: 123 134 148; /* muted text, idle rail buttons */
|
||||||
|
--x-board-ink-4-rgb: 94 103 114; /* empty states */
|
||||||
|
--x-board-tab-active-rgb: 243 246 249; /* the selected tab */
|
||||||
|
--x-board-on-status-rgb: 255 255 255; /* text on coloured headers */
|
||||||
|
--x-board-card-rgb: 255 255 255; /* card body */
|
||||||
|
--x-board-card-ink-rgb: 31 36 43; /* item names */
|
||||||
|
--x-board-card-ink-2-rgb: 65 71 79; /* card footer text */
|
||||||
|
--x-board-card-muted-rgb: 174 180 188; /* done items, labels on the card */
|
||||||
|
--x-board-card-soft-rgb: 240 242 245; /* quantity badges, footer, scheduled orders */
|
||||||
|
--x-board-card-line-rgb: 232 235 239; /* lines inside a card */
|
||||||
|
--x-board-card-progress-rgb: 243 248 255; /* body of an order in progress */
|
||||||
|
--x-board-card-done-rgb: 244 247 244; /* body of a done order */
|
||||||
|
--x-board-note-rgb: 255 251 235; /* order note background */
|
||||||
|
--x-board-note-ink-rgb: 180 83 9; /* order note text */
|
||||||
|
--x-board-fresh-rgb: 52 181 106; /* new order (default age colour) */
|
||||||
|
--x-board-fresh-deep-rgb: 30 128 72; /* its subheader; extras on items */
|
||||||
|
--x-board-warning-rgb: 240 165 42; /* waiting a while */
|
||||||
|
--x-board-warning-deep-rgb: 184 115 16; /* its subheader; choices on items; call waiter */
|
||||||
|
--x-board-late-rgb: 232 81 63; /* late */
|
||||||
|
--x-board-late-deep-rgb: 160 45 30; /* its subheader; removed on items; decline */
|
||||||
|
--x-board-done-rgb: 61 71 87; /* done order header */
|
||||||
|
--x-board-done-deep-rgb: 42 49 64; /* its subheader */
|
||||||
|
--x-board-future-rgb: 74 85 104; /* scheduled order header */
|
||||||
|
--x-board-future-deep-rgb: 55 65 81; /* its subheader */
|
||||||
|
--x-board-future-glow-rgb: 109 208 138; /* scheduled: rail badge, card glow */
|
||||||
|
--x-board-progress-rgb: 47 127 240; /* in progress, selection, item notes */
|
||||||
|
--x-board-fresh-soft-rgb: 134 239 172; /* extras in the totals panel */
|
||||||
|
--x-board-warning-soft-rgb: 252 211 77; /* choices in the totals panel */
|
||||||
|
--x-board-late-soft-rgb: 252 165 165; /* removed in the totals panel */
|
||||||
|
--x-board-progress-soft-rgb: 147 197 253; /* notes in the totals panel */
|
||||||
|
|
||||||
|
--x-board-bg: rgb(var(--x-board-bg-rgb));
|
||||||
|
--x-board-rail: rgb(var(--x-board-rail-rgb));
|
||||||
|
--x-board-topbar: rgb(var(--x-board-topbar-rgb));
|
||||||
|
--x-board-line: rgb(var(--x-board-line-rgb));
|
||||||
|
--x-board-deep: rgb(var(--x-board-deep-rgb));
|
||||||
|
--x-board-ink: rgb(var(--x-board-ink-rgb));
|
||||||
|
--x-board-ink-2: rgb(var(--x-board-ink-2-rgb));
|
||||||
|
--x-board-ink-3: rgb(var(--x-board-ink-3-rgb));
|
||||||
|
--x-board-ink-4: rgb(var(--x-board-ink-4-rgb));
|
||||||
|
--x-board-tab-active: rgb(var(--x-board-tab-active-rgb));
|
||||||
|
--x-board-on-status: rgb(var(--x-board-on-status-rgb));
|
||||||
|
--x-board-card: rgb(var(--x-board-card-rgb));
|
||||||
|
--x-board-card-ink: rgb(var(--x-board-card-ink-rgb));
|
||||||
|
--x-board-card-ink-2: rgb(var(--x-board-card-ink-2-rgb));
|
||||||
|
--x-board-card-muted: rgb(var(--x-board-card-muted-rgb));
|
||||||
|
--x-board-card-soft: rgb(var(--x-board-card-soft-rgb));
|
||||||
|
--x-board-card-line: rgb(var(--x-board-card-line-rgb));
|
||||||
|
--x-board-card-progress: rgb(var(--x-board-card-progress-rgb));
|
||||||
|
--x-board-card-done: rgb(var(--x-board-card-done-rgb));
|
||||||
|
--x-board-note: rgb(var(--x-board-note-rgb));
|
||||||
|
--x-board-note-ink: rgb(var(--x-board-note-ink-rgb));
|
||||||
|
--x-board-fresh: rgb(var(--x-board-fresh-rgb));
|
||||||
|
--x-board-fresh-deep: rgb(var(--x-board-fresh-deep-rgb));
|
||||||
|
--x-board-warning: rgb(var(--x-board-warning-rgb));
|
||||||
|
--x-board-warning-deep: rgb(var(--x-board-warning-deep-rgb));
|
||||||
|
--x-board-late: rgb(var(--x-board-late-rgb));
|
||||||
|
--x-board-late-deep: rgb(var(--x-board-late-deep-rgb));
|
||||||
|
--x-board-done: rgb(var(--x-board-done-rgb));
|
||||||
|
--x-board-done-deep: rgb(var(--x-board-done-deep-rgb));
|
||||||
|
--x-board-future: rgb(var(--x-board-future-rgb));
|
||||||
|
--x-board-future-deep: rgb(var(--x-board-future-deep-rgb));
|
||||||
|
--x-board-future-glow: rgb(var(--x-board-future-glow-rgb));
|
||||||
|
--x-board-progress: rgb(var(--x-board-progress-rgb));
|
||||||
|
--x-board-fresh-soft: rgb(var(--x-board-fresh-soft-rgb));
|
||||||
|
--x-board-warning-soft: rgb(var(--x-board-warning-soft-rgb));
|
||||||
|
--x-board-late-soft: rgb(var(--x-board-late-soft-rgb));
|
||||||
|
--x-board-progress-soft: rgb(var(--x-board-progress-soft-rgb));
|
||||||
|
|
||||||
|
--x-board-radius-card: 10px;
|
||||||
|
--x-board-shadow-card: 0 1px 2px rgb(0 0 0 / 0.25), 0 6px 16px rgb(0 0 0 / 0.22);
|
||||||
|
--x-board-shadow-focus: 0 10px 24px rgb(0 0 0 / 0.40), 0 0 0 4px rgb(var(--x-board-progress-rgb) / 0.25);
|
||||||
|
--x-board-font-number: "Inter", "SF Pro Display", var(--x-font-sans);
|
||||||
|
}
|
||||||
|
|
||||||
/* ── Ready-to-use colours ────────────────────────────────────────────────────
|
/* ── Ready-to-use colours ────────────────────────────────────────────────────
|
||||||
* Redeclared wherever the channels can change, so a nested data-theme /
|
* Redeclared wherever the channels can change, so a nested data-theme /
|
||||||
* data-venue-theme container gets its own values (custom properties are
|
* data-venue-theme container gets its own values (custom properties are
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
// The app must also load the tokens: import '@xenia/ui/tokens.css' (or styles.css).
|
// The app must also load the tokens: import '@xenia/ui/tokens.css' (or styles.css).
|
||||||
|
|
||||||
const c = name => `rgb(var(--x-${name}-rgb) / <alpha-value>)`
|
const c = name => `rgb(var(--x-${name}-rgb) / <alpha-value>)`
|
||||||
|
const BOARD = ['bg', 'rail', 'topbar', 'line', 'deep', 'ink', 'ink-2', 'ink-3', 'ink-4', 'tab-active', 'on-status', 'card', 'card-ink', 'card-ink-2', 'card-muted', 'card-soft', 'card-line', 'card-progress', 'card-done', 'note', 'note-ink', 'fresh', 'fresh-deep', 'warning', 'warning-deep', 'late', 'late-deep', 'done', 'done-deep', 'future', 'future-deep', 'future-glow', 'progress', 'fresh-soft', 'warning-soft', 'late-soft', 'progress-soft']
|
||||||
const tone = name => ({ DEFAULT: c(name), fg: c(`${name}-fg`), soft: c(`${name}-soft`), ink: c(`${name}-ink`) })
|
const tone = name => ({ DEFAULT: c(name), fg: c(`${name}-fg`), soft: c(`${name}-soft`), ink: c(`${name}-ink`) })
|
||||||
|
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
@@ -31,6 +32,8 @@ export default {
|
|||||||
warning: tone('warning'),
|
warning: tone('warning'),
|
||||||
danger: tone('danger'),
|
danger: tone('danger'),
|
||||||
info: tone('info'),
|
info: tone('info'),
|
||||||
|
// the board design language (kitchen display): bg-board-bg, text-board-ink-2, bg-board-late…
|
||||||
|
board: Object.fromEntries(BOARD.map(n => [n, c(`board-${n}`)])),
|
||||||
},
|
},
|
||||||
fontSize: {
|
fontSize: {
|
||||||
caption: ['var(--x-text-caption)', { lineHeight: 'var(--x-leading-caption)' }],
|
caption: ['var(--x-text-caption)', { lineHeight: 'var(--x-leading-caption)' }],
|
||||||
@@ -45,6 +48,7 @@ export default {
|
|||||||
control: 'var(--x-radius-control)',
|
control: 'var(--x-radius-control)',
|
||||||
card: 'var(--x-radius-card)',
|
card: 'var(--x-radius-card)',
|
||||||
dialog: 'var(--x-radius-dialog)',
|
dialog: 'var(--x-radius-dialog)',
|
||||||
|
'board-card': 'var(--x-board-radius-card)',
|
||||||
},
|
},
|
||||||
boxShadow: {
|
boxShadow: {
|
||||||
raised: 'var(--x-shadow-raised)',
|
raised: 'var(--x-shadow-raised)',
|
||||||
|
|||||||
@@ -65,3 +65,20 @@ test('system theme mirrors dark', () => {
|
|||||||
const darkCanvas = dark.canvas.join(' ')
|
const darkCanvas = dark.canvas.join(' ')
|
||||||
assert.ok(sys.includes(`--x-canvas-rgb: ${darkCanvas};`), 'system dark uses the dark canvas')
|
assert.ok(sys.includes(`--x-canvas-rgb: ${darkCanvas};`), 'system dark uses the dark canvas')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// The board (kitchen display, 3.2b-2): always dark, so one set. Done items (card-muted) and
|
||||||
|
// empty states (ink-4) are meant to recede and aren't checked.
|
||||||
|
test('board token pairs are readable', () => {
|
||||||
|
const b = Object.fromEntries([...css.matchAll(/--x-board-([\w-]+)-rgb:\s*([\d\s]+);/g)].map(([, k, v]) => [k, v.trim().split(/\s+/).map(Number)]))
|
||||||
|
const boardPairs = [
|
||||||
|
['ink', 'bg', TEXT], ['ink-2', 'bg', TEXT], ['ink-2', 'line', TEXT], ['ink-3', 'rail', TEXT], ['bg', 'tab-active', TEXT],
|
||||||
|
['card-ink', 'card', TEXT], ['card-ink-2', 'card-soft', TEXT], ['note-ink', 'note', TEXT],
|
||||||
|
['late-deep', 'card', TEXT], ['fresh-deep', 'card', TEXT], ['on-status', 'fresh-deep', TEXT], ['on-status', 'late-deep', TEXT],
|
||||||
|
['warning-deep', 'card', UI], ['progress', 'card', UI], ['on-status', 'warning-deep', UI],
|
||||||
|
]
|
||||||
|
for (const [fg, bg, min] of boardPairs) {
|
||||||
|
assert.ok(b[fg] && b[bg], `board tokens ${fg} / ${bg} exist`)
|
||||||
|
const r = ratio(b[fg], b[bg])
|
||||||
|
assert.ok(r >= min, `board ${fg} on ${bg}: ${r.toFixed(2)} < ${min}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { lazy, Suspense } from 'react'
|
|||||||
import { BrowserRouter, Route, Routes } from 'react-router-dom'
|
import { BrowserRouter, Route, Routes } from 'react-router-dom'
|
||||||
import { AccessProvider } from '@xenia/access'
|
import { AccessProvider } from '@xenia/access'
|
||||||
import { createI18n } from '@xenia/i18n'
|
import { createI18n } from '@xenia/i18n'
|
||||||
import { Spinner } from '@xenia/ui'
|
import { Spinner, ToastProvider } from '@xenia/ui'
|
||||||
import client from './api/client'
|
import client from './api/client'
|
||||||
import DeviceProvider from './device/DeviceProvider'
|
import DeviceProvider from './device/DeviceProvider'
|
||||||
import { useDevice } from './device/context'
|
import { useDevice } from './device/context'
|
||||||
@@ -29,7 +29,9 @@ function Root() {
|
|||||||
const { sessionKey } = useDevice()
|
const { sessionKey } = useDevice()
|
||||||
return (
|
return (
|
||||||
<AccessProvider client={client} token={sessionKey} i18n={i18n} loading={loading} autoRetryMs={AUTO_RETRY_MS}>
|
<AccessProvider client={client} token={sessionKey} i18n={i18n} loading={loading} autoRetryMs={AUTO_RETRY_MS}>
|
||||||
<Terminal />
|
<ToastProvider placement="bottom-center">
|
||||||
|
<Terminal />
|
||||||
|
</ToastProvider>
|
||||||
</AccessProvider>
|
</AccessProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,17 +7,20 @@
|
|||||||
// (this session only; the saved size is the font_scale setting);
|
// (this session only; the saved size is the font_scale setting);
|
||||||
// - the board: cards packed in columns without vertical scrolling (logic/layout.js), tap a
|
// - the board: cards packed in columns without vertical scrolling (logic/layout.js), tap a
|
||||||
// card to select it, tap its items to move them on, long press to decline;
|
// card to select it, tap its items to move them on, long press to decline;
|
||||||
// - item totals panel, decline / call-waiter dialogs, toasts.
|
// - item totals panel, decline / call-waiter dialogs, toasts (@xenia/ui).
|
||||||
|
// Look: the board design language of @xenia/ui (--x-board-* tokens, ./theme.js); the app runs
|
||||||
|
// in the dark theme (apps/registry.js), so the shared dialogs and toasts match the board.
|
||||||
// Settings are the device's (3.2a): GET /api/devices/me → me.config, live on device.updated.
|
// Settings are the device's (3.2a): GET /api/devices/me → me.config, live on device.updated.
|
||||||
// Orders come from the backend for this screen's zone and stay fresh through the live
|
// Orders come from the backend for this screen's zone and stay fresh through the live
|
||||||
// connection (useKdsData). Sound needs one tap after the screen starts (browser rule).
|
// connection (useKdsData). Sound needs one tap after the screen starts (browser rule).
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { CookingPot } from 'lucide-react'
|
import { CookingPot } from 'lucide-react'
|
||||||
import { useLanguage, useTranslation } from '@xenia/i18n'
|
import { useLanguage, useTranslation } from '@xenia/i18n'
|
||||||
|
import { useToast } from '@xenia/ui'
|
||||||
import client from '../../api/client'
|
import client from '../../api/client'
|
||||||
import { useDevice } from '../../device/context'
|
import { useDevice } from '../../device/context'
|
||||||
import { chime, soundUnlocked, unlockSound } from './chime'
|
import { chime, soundUnlocked, unlockSound } from './chime'
|
||||||
import { CallWaiterDialog, DeclineDialog, Toasts } from './components/Dialogs'
|
import { CallWaiterDialog, DeclineDialog } from './components/Dialogs'
|
||||||
import MeasureLayer from './components/MeasureLayer'
|
import MeasureLayer from './components/MeasureLayer'
|
||||||
import OrderCard from './components/OrderCard'
|
import OrderCard from './components/OrderCard'
|
||||||
import { SideRail, TopBar } from './components/Rails'
|
import { SideRail, TopBar } from './components/Rails'
|
||||||
@@ -29,7 +32,7 @@ import {
|
|||||||
} from './logic/board'
|
} from './logic/board'
|
||||||
import { layoutBoard } from './logic/layout'
|
import { layoutBoard } from './logic/layout'
|
||||||
import { boardSettings, senderName, zoomStep } from './logic/settings'
|
import { boardSettings, senderName, zoomStep } from './logic/settings'
|
||||||
import { KDS, KEYFRAMES } from './theme'
|
import { KDS, KEYFRAMES, alpha } from './theme'
|
||||||
import useKdsData from './useKdsData'
|
import useKdsData from './useKdsData'
|
||||||
|
|
||||||
const HISTORY = 10
|
const HISTORY = 10
|
||||||
@@ -52,7 +55,6 @@ export default function KdsApp() {
|
|||||||
const [showSummary, setShowSummary] = useState(false)
|
const [showSummary, setShowSummary] = useState(false)
|
||||||
const [soundOn, setSoundOn] = useState(true)
|
const [soundOn, setSoundOn] = useState(true)
|
||||||
const [started, setStarted] = useState(() => soundUnlocked())
|
const [started, setStarted] = useState(() => soundUnlocked())
|
||||||
const [toasts, setToasts] = useState([])
|
|
||||||
const [boardH, setBoardH] = useState(0)
|
const [boardH, setBoardH] = useState(0)
|
||||||
const [measured, setMeasured] = useState({})
|
const [measured, setMeasured] = useState({})
|
||||||
const undoStack = useRef([])
|
const undoStack = useRef([])
|
||||||
@@ -60,11 +62,8 @@ export default function KdsApp() {
|
|||||||
const [hist, setHist] = useState({ undo: 0, redo: 0 }) // stack sizes, for the rail buttons
|
const [hist, setHist] = useState({ undo: 0, redo: 0 }) // stack sizes, for the rail buttons
|
||||||
const known = useRef(null) // order ids seen so far (new-order chime)
|
const known = useRef(null) // order ids seen so far (new-order chime)
|
||||||
|
|
||||||
const toast = useCallback(msg => {
|
const ui = useToast()
|
||||||
const id = Math.random().toString(36).slice(2)
|
const toast = useCallback((msg, tone = 'neutral') => ui.show({ title: msg, tone, duration: TOAST_MS }), [ui])
|
||||||
setToasts(ts => [...ts, { id, msg }])
|
|
||||||
setTimeout(() => setToasts(ts => ts.filter(x => x.id !== id)), TOAST_MS)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
// a fresh answer replaces the board; new orders chime (not the first load)
|
// a fresh answer replaces the board; new orders chime (not the first load)
|
||||||
const soundRef = useRef(false)
|
const soundRef = useRef(false)
|
||||||
@@ -134,7 +133,7 @@ export default function KdsApp() {
|
|||||||
|
|
||||||
const callWaiter = useCallback(orderId => {
|
const callWaiter = useCallback(orderId => {
|
||||||
client.post(`/api/kds/orders/${orderId}/call-waiter`, {})
|
client.post(`/api/kds/orders/${orderId}/call-waiter`, {})
|
||||||
.then(() => toast(t('kds.toast.waiterCalled'))).catch(() => toast(t('kds.toast.sendFailed')))
|
.then(() => toast(t('kds.toast.waiterCalled'))).catch(() => toast(t('kds.toast.sendFailed'), 'danger'))
|
||||||
}, [t, toast])
|
}, [t, toast])
|
||||||
|
|
||||||
const setOrderStatus = useCallback((orderId, status) => {
|
const setOrderStatus = useCallback((orderId, status) => {
|
||||||
@@ -180,14 +179,14 @@ export default function KdsApp() {
|
|||||||
toast(t('kds.toast.orderDeclined'))
|
toast(t('kds.toast.orderDeclined'))
|
||||||
}
|
}
|
||||||
reload()
|
reload()
|
||||||
} catch { toast(t('kds.toast.declineFailed')) }
|
} catch { toast(t('kds.toast.declineFailed'), 'danger') }
|
||||||
}, [reload, t, toast])
|
}, [reload, t, toast])
|
||||||
|
|
||||||
const print = useCallback(async orderId => {
|
const print = useCallback(async orderId => {
|
||||||
try {
|
try {
|
||||||
await client.post(`/api/kds/orders/${orderId}/retry-print`)
|
await client.post(`/api/kds/orders/${orderId}/retry-print`)
|
||||||
toast(t('kds.toast.printSent'))
|
toast(t('kds.toast.printSent'))
|
||||||
} catch { toast(t('kds.toast.printFailed')) }
|
} catch { toast(t('kds.toast.printFailed'), 'danger') }
|
||||||
}, [t, toast])
|
}, [t, toast])
|
||||||
|
|
||||||
const replay = useCallback((entry, which) => {
|
const replay = useCallback((entry, which) => {
|
||||||
@@ -267,7 +266,7 @@ export default function KdsApp() {
|
|||||||
return (
|
return (
|
||||||
<div data-testid="app-kds" style={{
|
<div data-testid="app-kds" style={{
|
||||||
display: 'flex', position: 'absolute', inset: 0, overflow: 'hidden',
|
display: 'flex', position: 'absolute', inset: 0, overflow: 'hidden',
|
||||||
background: KDS.bg, color: '#e7ecf2', WebkitFontSmoothing: 'antialiased', userSelect: 'none', WebkitUserSelect: 'none',
|
background: KDS.bg, color: KDS.ink, WebkitFontSmoothing: 'antialiased', userSelect: 'none', WebkitUserSelect: 'none',
|
||||||
}}>
|
}}>
|
||||||
<style>{KEYFRAMES}</style>
|
<style>{KEYFRAMES}</style>
|
||||||
<SideRail filters={filters} counts={counts} fontScale={fs} onToggleFilter={toggleFilter}
|
<SideRail filters={filters} counts={counts} fontScale={fs} onToggleFilter={toggleFilter}
|
||||||
@@ -292,15 +291,15 @@ export default function KdsApp() {
|
|||||||
<div style={{ position: 'relative', height: '100%', width: Math.max(layout.totalW, 1), minWidth: '100%',
|
<div style={{ position: 'relative', height: '100%', width: Math.max(layout.totalW, 1), minWidth: '100%',
|
||||||
paddingRight: summary === 'floating' ? `calc(${sideWidth} + 32px)` : 0 }}>
|
paddingRight: summary === 'floating' ? `calc(${sideWidth} + 32px)` : 0 }}>
|
||||||
{loaded === null && (
|
{loaded === null && (
|
||||||
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#5e6772', fontSize: 14 }}>
|
<div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', color: KDS.ink4, fontSize: 14 }}>
|
||||||
{t('kds.loading')}
|
{t('kds.loading')}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{loaded !== null && visible.length === 0 && (
|
{loaded !== null && visible.length === 0 && (
|
||||||
<div data-testid="kds-empty" onClick={e => e.stopPropagation()} style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column',
|
<div data-testid="kds-empty" onClick={e => e.stopPropagation()} style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column',
|
||||||
alignItems: 'center', justifyContent: 'center', gap: 14, color: '#5e6772' }}>
|
alignItems: 'center', justifyContent: 'center', gap: 14, color: KDS.ink4 }}>
|
||||||
<CookingPot style={{ width: 54, height: 54, opacity: 0.5 }} />
|
<CookingPot style={{ width: 54, height: 54, opacity: 0.5 }} />
|
||||||
<div style={{ fontSize: 17, fontWeight: 600, color: '#7b8694' }}>{t('kds.empty')}</div>
|
<div style={{ fontSize: 17, fontWeight: 600, color: KDS.ink3 }}>{t('kds.empty')}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{visible.map(order => {
|
{visible.map(order => {
|
||||||
@@ -346,7 +345,7 @@ export default function KdsApp() {
|
|||||||
{dialog === 'call' && (
|
{dialog === 'call' && (
|
||||||
<CallWaiterDialog zoneName={sender} onClose={() => setDialog(null)}
|
<CallWaiterDialog zoneName={sender} onClose={() => setDialog(null)}
|
||||||
onSend={ids => client.post('/api/kds/call-waiter-general', { waiter_ids: ids })
|
onSend={ids => client.post('/api/kds/call-waiter-general', { waiter_ids: ids })
|
||||||
.then(() => toast(t('kds.toast.called'))).catch(() => toast(t('kds.toast.sendFailed')))} />
|
.then(() => toast(t('kds.toast.called'))).catch(() => toast(t('kds.toast.sendFailed'), 'danger'))} />
|
||||||
)}
|
)}
|
||||||
{dialog?.decline && (
|
{dialog?.decline && (
|
||||||
<DeclineDialog itemId={dialog.decline.itemId} itemName={dialog.decline.itemName}
|
<DeclineDialog itemId={dialog.decline.itemId} itemName={dialog.decline.itemName}
|
||||||
@@ -355,15 +354,14 @@ export default function KdsApp() {
|
|||||||
|
|
||||||
{!started && settings.sound && (
|
{!started && settings.sound && (
|
||||||
<button type="button" data-testid="kds-start" onClick={() => { unlockSound(); setStarted(true) }} style={{
|
<button type="button" data-testid="kds-start" onClick={() => { unlockSound(); setStarted(true) }} style={{
|
||||||
position: 'absolute', inset: 0, zIndex: 400, background: 'rgba(10,13,17,.72)', border: 'none', cursor: 'pointer', color: '#e7ecf2',
|
position: 'absolute', inset: 0, zIndex: 400, background: alpha('deep', 0.72), border: 'none', cursor: 'pointer', color: KDS.ink,
|
||||||
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 10, fontFamily: 'inherit',
|
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 10, fontFamily: 'inherit',
|
||||||
}}>
|
}}>
|
||||||
<span style={{ fontSize: 28, fontWeight: 800 }}>{t('kds.start.title')}</span>
|
<span style={{ fontSize: 28, fontWeight: 800 }}>{t('kds.start.title')}</span>
|
||||||
<span style={{ fontSize: 15, color: '#aab4c0', maxWidth: 420, textAlign: 'center' }}>{t('kds.start.body')}</span>
|
<span style={{ fontSize: 15, color: KDS.ink2, maxWidth: 420, textAlign: 'center' }}>{t('kds.start.body')}</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Toasts toasts={toasts} />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
import { Ban, BellRing, Check, Flame, Printer, Undo2, X } from 'lucide-react'
|
import { Ban, BellRing, Check, Flame, Printer, Undo2, X } from 'lucide-react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { CARD_FOOT_H_BASE, CARD_HEAD_H_BASE, CARD_SUB_H_BASE } from '../logic/layout'
|
import { CARD_FOOT_H_BASE, CARD_HEAD_H_BASE, CARD_SUB_H_BASE } from '../logic/layout'
|
||||||
import { KDS } from '../theme'
|
import { KDS, alpha } from '../theme'
|
||||||
|
|
||||||
function Bar({ fs, z, children }) {
|
function Bar({ fs, z, children }) {
|
||||||
const pad = Math.round(6 * fs)
|
const pad = Math.round(6 * fs)
|
||||||
return (
|
return (
|
||||||
<div onClick={e => e.stopPropagation()} style={{
|
<div onClick={e => e.stopPropagation()} style={{
|
||||||
position: 'absolute', left: 0, right: 0, top: 0, height: Math.round((CARD_HEAD_H_BASE + CARD_SUB_H_BASE) * fs), zIndex: z,
|
position: 'absolute', left: 0, right: 0, top: 0, height: Math.round((CARD_HEAD_H_BASE + CARD_SUB_H_BASE) * fs), zIndex: z,
|
||||||
background: '#0a0e13', borderRadius: '10px 10px 0 0', display: 'flex', alignItems: 'stretch', padding: pad, gap: pad,
|
background: KDS.deep, borderRadius: `${KDS.radiusCard} ${KDS.radiusCard} 0 0`, display: 'flex', alignItems: 'stretch', padding: pad, gap: pad,
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
@@ -25,7 +25,7 @@ function BarButton({ bg, label, title, onClick, fs, children, testId }) {
|
|||||||
onClick={e => { e.stopPropagation(); onClick() }}
|
onClick={e => { e.stopPropagation(); onClick() }}
|
||||||
style={{
|
style={{
|
||||||
flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: Math.round(3 * fs),
|
flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: Math.round(3 * fs),
|
||||||
background: bg, color: '#fff', border: 'none', cursor: 'pointer', fontFamily: 'inherit', borderRadius: Math.round(9 * fs),
|
background: bg, color: KDS.onStatus, border: 'none', cursor: 'pointer', fontFamily: 'inherit', borderRadius: Math.round(9 * fs),
|
||||||
fontSize: Math.round(10 * fs), fontWeight: 700, letterSpacing: '.06em', textTransform: 'uppercase',
|
fontSize: Math.round(10 * fs), fontWeight: 700, letterSpacing: '.06em', textTransform: 'uppercase',
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
@@ -43,14 +43,14 @@ export function ActionBar({ order, onStatus, onPrint, onCallWaiter, fs = 1, hasW
|
|||||||
<>
|
<>
|
||||||
<Bar fs={fs} z={4}>
|
<Bar fs={fs} z={4}>
|
||||||
<BarButton fs={fs} testId="card-prepare" title={isPreparing ? t('kds.actions.reset') : t('kds.actions.prepare')}
|
<BarButton fs={fs} testId="card-prepare" title={isPreparing ? t('kds.actions.reset') : t('kds.actions.prepare')}
|
||||||
bg={isPreparing ? '#3d4757' : KDS.accent} onClick={() => onStatus(order.id, isPreparing ? 'pending' : 'preparing')}>
|
bg={isPreparing ? KDS.done : KDS.progress} onClick={() => onStatus(order.id, isPreparing ? 'pending' : 'preparing')}>
|
||||||
{isPreparing ? <Undo2 style={icon} /> : <Flame style={icon} />}
|
{isPreparing ? <Undo2 style={icon} /> : <Flame style={icon} />}
|
||||||
</BarButton>
|
</BarButton>
|
||||||
<BarButton fs={fs} testId="card-complete" title={isDone ? t('kds.actions.reset') : t('kds.actions.complete')}
|
<BarButton fs={fs} testId="card-complete" title={isDone ? t('kds.actions.reset') : t('kds.actions.complete')}
|
||||||
bg={isDone ? '#3d4757' : KDS.greenD} onClick={() => onStatus(order.id, isDone ? 'pending' : 'done')}>
|
bg={isDone ? KDS.done : KDS.freshDeep} onClick={() => onStatus(order.id, isDone ? 'pending' : 'done')}>
|
||||||
{isDone ? <Undo2 style={icon} /> : <Check style={icon} />}
|
{isDone ? <Undo2 style={icon} /> : <Check style={icon} />}
|
||||||
</BarButton>
|
</BarButton>
|
||||||
<BarButton fs={fs} testId="card-print" title={t('kds.actions.print')} bg="rgba(255,255,255,.12)" onClick={() => onPrint(order.id)}>
|
<BarButton fs={fs} testId="card-print" title={t('kds.actions.print')} bg={alpha('on-status', 0.12)} onClick={() => onPrint(order.id)}>
|
||||||
<Printer style={icon} />
|
<Printer style={icon} />
|
||||||
</BarButton>
|
</BarButton>
|
||||||
</Bar>
|
</Bar>
|
||||||
@@ -58,7 +58,7 @@ export function ActionBar({ order, onStatus, onPrint, onCallWaiter, fs = 1, hasW
|
|||||||
<button type="button" data-testid="card-call-waiter" onClick={e => { e.stopPropagation(); onCallWaiter(order.id) }} style={{
|
<button type="button" data-testid="card-call-waiter" onClick={e => { e.stopPropagation(); onCallWaiter(order.id) }} style={{
|
||||||
position: 'absolute', left: 0, right: 0, bottom: 0, height: Math.round(CARD_FOOT_H_BASE * fs), zIndex: 4,
|
position: 'absolute', left: 0, right: 0, bottom: 0, height: Math.round(CARD_FOOT_H_BASE * fs), zIndex: 4,
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: Math.round(7 * fs),
|
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: Math.round(7 * fs),
|
||||||
background: KDS.amberD, color: '#fff', border: 'none', cursor: 'pointer', fontFamily: 'inherit',
|
background: KDS.warningDeep, color: KDS.onStatus, border: 'none', cursor: 'pointer', fontFamily: 'inherit',
|
||||||
fontSize: Math.round(13 * fs), fontWeight: 700,
|
fontSize: Math.round(13 * fs), fontWeight: 700,
|
||||||
}}>
|
}}>
|
||||||
<BellRing style={{ width: Math.round(14 * fs), height: Math.round(14 * fs) }} />
|
<BellRing style={{ width: Math.round(14 * fs), height: Math.round(14 * fs) }} />
|
||||||
@@ -76,18 +76,18 @@ export function QuickActionBar({ order, onStatus, onDecline, onDismiss, fs = 1 }
|
|||||||
const icon = { width: Math.round(20 * fs), height: Math.round(20 * fs) }
|
const icon = { width: Math.round(20 * fs), height: Math.round(20 * fs) }
|
||||||
return (
|
return (
|
||||||
<Bar fs={fs} z={5}>
|
<Bar fs={fs} z={5}>
|
||||||
<BarButton fs={fs} testId="quick-prepare" bg={isPreparing ? '#3d4757' : KDS.accent} label={isPreparing ? t('kds.quick.undo') : t('kds.quick.prep')}
|
<BarButton fs={fs} testId="quick-prepare" bg={isPreparing ? KDS.done : KDS.progress} label={isPreparing ? t('kds.quick.undo') : t('kds.quick.prep')}
|
||||||
onClick={() => { onStatus(order.id, isPreparing ? 'pending' : 'preparing'); onDismiss() }}>
|
onClick={() => { onStatus(order.id, isPreparing ? 'pending' : 'preparing'); onDismiss() }}>
|
||||||
{isPreparing ? <Undo2 style={icon} /> : <Flame style={icon} />}
|
{isPreparing ? <Undo2 style={icon} /> : <Flame style={icon} />}
|
||||||
</BarButton>
|
</BarButton>
|
||||||
<BarButton fs={fs} testId="quick-ready" bg={isDone ? '#3d4757' : KDS.greenD} label={isDone ? t('kds.quick.undo') : t('kds.quick.ready')}
|
<BarButton fs={fs} testId="quick-ready" bg={isDone ? KDS.done : KDS.freshDeep} label={isDone ? t('kds.quick.undo') : t('kds.quick.ready')}
|
||||||
onClick={() => { onStatus(order.id, isDone ? 'pending' : 'done'); onDismiss() }}>
|
onClick={() => { onStatus(order.id, isDone ? 'pending' : 'done'); onDismiss() }}>
|
||||||
{isDone ? <Undo2 style={icon} /> : <Check style={icon} />}
|
{isDone ? <Undo2 style={icon} /> : <Check style={icon} />}
|
||||||
</BarButton>
|
</BarButton>
|
||||||
<BarButton fs={fs} testId="quick-decline" bg={KDS.redD} label={t('kds.quick.decline')} onClick={() => { onDecline(order.id); onDismiss() }}>
|
<BarButton fs={fs} testId="quick-decline" bg={KDS.lateDeep} label={t('kds.quick.decline')} onClick={() => { onDecline(order.id); onDismiss() }}>
|
||||||
<Ban style={icon} />
|
<Ban style={icon} />
|
||||||
</BarButton>
|
</BarButton>
|
||||||
<BarButton fs={fs} testId="quick-close" bg="rgba(255,255,255,.10)" label={t('kds.quick.close')} onClick={onDismiss}>
|
<BarButton fs={fs} testId="quick-close" bg={alpha('on-status', 0.10)} label={t('kds.quick.close')} onClick={onDismiss}>
|
||||||
<X style={icon} />
|
<X style={icon} />
|
||||||
</BarButton>
|
</BarButton>
|
||||||
</Bar>
|
</Bar>
|
||||||
|
|||||||
@@ -1,41 +1,31 @@
|
|||||||
// The kitchen board's dialogs (plan step 3.2b, from KdsPage.jsx), dark like the board:
|
// The kitchen board's dialogs (plan steps 3.2b, 3.2b-2): decline an order or an item (with a
|
||||||
// decline an order or an item (with a reason), call waiters on shift, and the small toasts.
|
// reason) and call waiters on shift. Shared @xenia/ui dialogs and buttons; the KDS runs in
|
||||||
|
// the dark theme (apps/registry.js), so they match the board.
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { Ban, BellRing, Check, X } from 'lucide-react'
|
import { Ban, BellRing, Check } from 'lucide-react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, Dialog, Input, Spinner } from '@xenia/ui'
|
||||||
import client from '../../../api/client'
|
import client from '../../../api/client'
|
||||||
import { KDS, secondaryButton } from '../theme'
|
|
||||||
|
|
||||||
export function KdsModal({ width, onClose, children, testId, z = 200 }) {
|
const REASONS = ['out_of_stock', 'too_many_orders', 'other']
|
||||||
return (
|
|
||||||
<div onClick={onClose} style={{ position: 'absolute', inset: 0, zIndex: z, background: 'rgba(10,13,17,.78)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
||||||
<div role="dialog" data-testid={testId} onClick={e => e.stopPropagation()} style={{
|
|
||||||
width, maxWidth: 'calc(100vw - 32px)', maxHeight: 'calc(100vh - 32px)', background: KDS.panel, border: `1px solid ${KDS.panelLine}`, borderRadius: 18,
|
|
||||||
boxShadow: '0 32px 80px rgba(0,0,0,.6)', color: KDS.panelInk, display: 'flex', flexDirection: 'column', overflow: 'hidden',
|
|
||||||
}}>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CloseButton({ onClick, label }) {
|
/** A big selectable row (reasons, waiters). tone: 'danger' | 'accent' when selected. */
|
||||||
|
function Choice({ on, tone = 'accent', onClick, children, ...rest }) {
|
||||||
|
const selected = tone === 'danger' ? 'border-danger bg-danger-soft text-danger-ink' : 'border-accent bg-accent-soft text-accent-ink'
|
||||||
return (
|
return (
|
||||||
<button type="button" aria-label={label} onClick={onClick} style={{ width: 40, height: 40, borderRadius: 10, display: 'flex', alignItems: 'center',
|
<button type="button" onClick={onClick} {...rest}
|
||||||
justifyContent: 'center', color: KDS.panelInk2, background: 'none', border: 'none', cursor: 'pointer', flexShrink: 0 }}>
|
className={`w-full min-h-[var(--x-control-lg)] rounded-control border-2 px-4 text-left text-body font-medium flex items-center gap-3 transition-colors duration-fast
|
||||||
<X style={{ width: 20, height: 20 }} />
|
${on ? selected : 'border-line bg-surface-2 text-ink-2 hover:bg-surface-3'}`}>
|
||||||
|
{children}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const REASONS = ['out_of_stock', 'too_many_orders', 'other']
|
|
||||||
|
|
||||||
export function DeclineDialog({ itemId, itemName, onConfirm, onClose }) {
|
export function DeclineDialog({ itemId, itemName, onConfirm, onClose }) {
|
||||||
const { t } = useTranslation('terminal')
|
const { t } = useTranslation('terminal')
|
||||||
const [reason, setReason] = useState(null)
|
const [reason, setReason] = useState(null)
|
||||||
const [note, setNote] = useState('')
|
const [note, setNote] = useState('')
|
||||||
const isItem = itemId != null
|
const title = itemId != null ? t('kds.decline.item') : t('kds.decline.order')
|
||||||
const title = isItem ? t('kds.decline.item') : t('kds.decline.order')
|
|
||||||
const confirm = () => {
|
const confirm = () => {
|
||||||
if (!reason) return
|
if (!reason) return
|
||||||
// the waiter app shows this text as it is: the reason in the screen's language, or the note
|
// the waiter app shows this text as it is: the reason in the screen's language, or the note
|
||||||
@@ -43,43 +33,20 @@ export function DeclineDialog({ itemId, itemName, onConfirm, onClose }) {
|
|||||||
onClose()
|
onClose()
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<KdsModal width={380} onClose={onClose} testId="decline-dialog" z={300}>
|
<Dialog open onClose={onClose} size="sm" title={title} description={itemId != null ? itemName : undefined}
|
||||||
<div style={{ padding: '18px 20px 14px', borderBottom: `1px solid ${KDS.panelLine2}` }}>
|
footer={<>
|
||||||
<div style={{ fontSize: 17, fontWeight: 700 }}>{title}</div>
|
<Button variant="secondary" size="lg" onClick={onClose}>{t('kds.cancel')}</Button>
|
||||||
{isItem && itemName && <div style={{ fontSize: 13, color: KDS.panelInk2, marginTop: 4 }}>{itemName}</div>}
|
<Button variant="danger" size="lg" icon={<Ban size={16} />} disabled={!reason} onClick={confirm} data-testid="decline-confirm">{title}</Button>
|
||||||
</div>
|
</>}>
|
||||||
<div style={{ padding: '14px 20px', display: 'flex', flexDirection: 'column', gap: 8 }}>
|
<div className="grid gap-2" data-testid="decline-dialog">
|
||||||
{REASONS.map(r => {
|
{REASONS.map(r => (
|
||||||
const on = reason === r
|
<Choice key={r} tone="danger" on={reason === r} onClick={() => setReason(r)} data-reason={r}>{t(`kds.decline.reasons.${r}`)}</Choice>
|
||||||
return (
|
))}
|
||||||
<button key={r} type="button" data-reason={r} onClick={() => setReason(r)} style={{
|
|
||||||
width: '100%', padding: '12px 14px', borderRadius: 10, textAlign: 'left', fontFamily: 'inherit', cursor: 'pointer',
|
|
||||||
background: on ? 'rgba(232,81,63,.15)' : KDS.field, border: `2px solid ${on ? KDS.red : KDS.panelLine}`,
|
|
||||||
color: on ? '#f5a7a0' : '#9ca8b6', fontSize: 14, fontWeight: on ? 600 : 400,
|
|
||||||
}}>
|
|
||||||
{t(`kds.decline.reasons.${r}`)}
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
{reason === 'other' && (
|
{reason === 'other' && (
|
||||||
<input value={note} onChange={e => setNote(e.target.value)} placeholder={t('kds.decline.notePlaceholder')} autoFocus style={{
|
<Input value={note} onChange={e => setNote(e.target.value)} placeholder={t('kds.decline.notePlaceholder')} autoFocus />
|
||||||
width: '100%', height: 44, borderRadius: 10, padding: '0 12px', background: '#232d38', border: '1px solid #3d4f5e',
|
|
||||||
color: KDS.panelInk, fontSize: 14, fontFamily: 'inherit', outline: 'none', boxSizing: 'border-box',
|
|
||||||
}} />
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', gap: 10, padding: '12px 20px 18px' }}>
|
</Dialog>
|
||||||
<button type="button" onClick={onClose} style={secondaryButton}>{t('kds.cancel')}</button>
|
|
||||||
<button type="button" data-testid="decline-confirm" onClick={confirm} disabled={!reason} style={{
|
|
||||||
flex: 2, height: 48, borderRadius: 11, background: reason ? KDS.redD : KDS.panelLine, color: reason ? '#fff' : '#5e6772',
|
|
||||||
fontSize: 15, fontWeight: 700, border: 'none', cursor: reason ? 'pointer' : 'default', fontFamily: 'inherit',
|
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
|
||||||
}}>
|
|
||||||
<Ban style={{ width: 16, height: 16 }} />
|
|
||||||
{title}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</KdsModal>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,73 +75,38 @@ export function CallWaiterDialog({ zoneName, onSend, onClose }) {
|
|||||||
setSending(true)
|
setSending(true)
|
||||||
try { await onSend([...selected]); onClose() } finally { setSending(false) }
|
try { await onSend([...selected]); onClose() } finally { setSending(false) }
|
||||||
}
|
}
|
||||||
const chip = on => ({
|
|
||||||
width: '100%', borderRadius: 12, marginBottom: 8, cursor: 'pointer', fontFamily: 'inherit', display: 'flex', alignItems: 'center',
|
|
||||||
background: on ? 'rgba(47,127,240,.18)' : KDS.field, border: `2px solid ${on ? KDS.accent : KDS.panelLine}`,
|
|
||||||
})
|
|
||||||
const ready = selected.size > 0 && !sending
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<KdsModal width={420} onClose={onClose} testId="call-dialog">
|
<Dialog open onClose={onClose} title={t('kds.call.title')} description={zoneName ? t('kds.call.needsHelp', { zone: zoneName }) : undefined}
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 20px 14px' }}>
|
footer={<>
|
||||||
<div>
|
<Button variant="secondary" size="lg" onClick={onClose}>{t('kds.cancel')}</Button>
|
||||||
<div style={{ fontSize: 18, fontWeight: 700 }}>{t('kds.call.title')}</div>
|
<Button size="lg" icon={<BellRing size={18} />} loading={sending} disabled={!selected.size} onClick={send} data-testid="call-send">
|
||||||
{zoneName && <div style={{ fontSize: 12.5, color: KDS.panelInk2, marginTop: 2 }}>{t('kds.call.needsHelp', { zone: zoneName })}</div>}
|
{selected.size ? t('kds.call.sendCount', { count: selected.size }) : t('kds.call.send')}
|
||||||
</div>
|
</Button>
|
||||||
<CloseButton onClick={onClose} label={t('kds.close')} />
|
</>}>
|
||||||
</div>
|
<div className="grid gap-2" data-testid="call-dialog">
|
||||||
<div style={{ padding: '0 14px', maxHeight: 320, overflowY: 'auto' }}>
|
{waiters === null && <div className="flex justify-center py-8"><Spinner /></div>}
|
||||||
{waiters === null && <div style={{ textAlign: 'center', padding: '32px 0', color: '#5e6772', fontSize: 14 }}>{t('kds.loading')}</div>}
|
{waiters?.length === 0 && <p className="text-center py-8 text-body text-ink-3">{t('kds.call.none')}</p>}
|
||||||
{waiters?.length === 0 && <div style={{ textAlign: 'center', padding: '32px 0', color: '#5e6772', fontSize: 14 }}>{t('kds.call.none')}</div>}
|
|
||||||
{waiters?.length > 0 && (
|
{waiters?.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<button type="button" onClick={() => setSelected(all ? new Set() : new Set(waiters.map(w => w.id)))}
|
<Choice on={all} onClick={() => setSelected(all ? new Set() : new Set(waiters.map(w => w.id)))}>
|
||||||
style={{ ...chip(all), height: 52, justifyContent: 'center', gap: 8, color: all ? KDS.accent : '#7b8694', fontSize: 14, fontWeight: 700 }}>
|
{all && <Check size={16} />}<span className="flex-1 text-center font-semibold">{t('kds.call.all')}</span>
|
||||||
{all ? <Check style={{ width: 16, height: 16 }} /> : null}
|
</Choice>
|
||||||
{t('kds.call.all')}
|
|
||||||
</button>
|
|
||||||
{waiters.map(w => {
|
{waiters.map(w => {
|
||||||
const on = selected.has(w.id)
|
const on = selected.has(w.id)
|
||||||
const name = w.nickname || w.username
|
const name = w.nickname || w.username
|
||||||
return (
|
return (
|
||||||
<button key={w.id} type="button" data-waiter={w.id} onClick={() => toggle(w.id)}
|
<Choice key={w.id} on={on} onClick={() => toggle(w.id)} data-waiter={w.id}>
|
||||||
style={{ ...chip(on), height: 60, gap: 14, padding: '0 16px', color: KDS.panelInk, fontSize: 15, fontWeight: 600 }}>
|
<span className={`size-9 shrink-0 rounded-full flex items-center justify-center font-bold ${on ? 'bg-accent text-accent-fg' : 'bg-surface-3 text-ink'}`}>
|
||||||
<span style={{ width: 36, height: 36, borderRadius: '50%', flexShrink: 0, background: on ? KDS.accent : KDS.panelLine,
|
{on ? <Check size={18} /> : name?.[0]?.toUpperCase()}
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 16, fontWeight: 700 }}>
|
|
||||||
{on ? <Check style={{ width: 18, height: 18 }} /> : name?.[0]?.toUpperCase()}
|
|
||||||
</span>
|
</span>
|
||||||
<span style={{ flex: 1, textAlign: 'left' }}>{name}</span>
|
<span className="flex-1 text-ink">{name}</span>
|
||||||
</button>
|
</Choice>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', gap: 10, padding: '14px 20px', borderTop: `1px solid ${KDS.panelLine2}` }}>
|
</Dialog>
|
||||||
<button type="button" onClick={onClose} style={{ ...secondaryButton, height: 52 }}>{t('kds.cancel')}</button>
|
|
||||||
<button type="button" data-testid="call-send" onClick={send} disabled={!ready} style={{
|
|
||||||
flex: 2, height: 52, borderRadius: 11, background: ready ? KDS.amber : KDS.panelLine, color: ready ? '#0e1217' : '#5e6772',
|
|
||||||
fontSize: 15, fontWeight: 700, border: 'none', cursor: ready ? 'pointer' : 'default', fontFamily: 'inherit',
|
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
|
|
||||||
}}>
|
|
||||||
<BellRing style={{ width: 18, height: 18 }} />
|
|
||||||
{sending ? t('kds.call.sending') : selected.size ? t('kds.call.sendCount', { count: selected.size }) : t('kds.call.send')}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</KdsModal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Toasts({ toasts }) {
|
|
||||||
return (
|
|
||||||
<div style={{ position: 'absolute', bottom: 18, left: '50%', transform: 'translateX(-50%)', zIndex: 300, display: 'flex',
|
|
||||||
flexDirection: 'column', gap: 8, alignItems: 'center', pointerEvents: 'none' }}>
|
|
||||||
{toasts.map(x => (
|
|
||||||
<div key={x.id} data-testid="kds-toast" style={{ background: '#2b333d', color: '#eef2f6', border: '1px solid #3a4450', padding: '11px 18px',
|
|
||||||
borderRadius: 10, fontSize: 14, fontWeight: 600, boxShadow: '0 8px 22px rgba(0,0,0,.4)' }}>
|
|
||||||
{x.msg}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const MOD_ICON_SZ = 13
|
|||||||
const HOLD_MS = 500
|
const HOLD_MS = 500
|
||||||
|
|
||||||
export function ModRow({ Icon, color, text, done, fs }) {
|
export function ModRow({ Icon, color, text, done, fs }) {
|
||||||
const col = done ? KDS.doneInk : color
|
const col = done ? KDS.cardMuted : color
|
||||||
const fontSize = Math.round(12 * fs)
|
const fontSize = Math.round(12 * fs)
|
||||||
const lineH = Math.round(fontSize * 1.4)
|
const lineH = Math.round(fontSize * 1.4)
|
||||||
const iconSz = Math.round(MOD_ICON_SZ * fs)
|
const iconSz = Math.round(MOD_ICON_SZ * fs)
|
||||||
@@ -57,13 +57,13 @@ export default function ItemBlock({ item, focused, onBump, onDecline, fontScale
|
|||||||
flexShrink: 0, minWidth: badgeH, height: badgeH,
|
flexShrink: 0, minWidth: badgeH, height: badgeH,
|
||||||
paddingLeft: hasUnit(item.unit_type) ? Math.round(4 * fs) : 0, paddingRight: hasUnit(item.unit_type) ? Math.round(4 * fs) : 0,
|
paddingLeft: hasUnit(item.unit_type) ? Math.round(4 * fs) : 0, paddingRight: hasUnit(item.unit_type) ? Math.round(4 * fs) : 0,
|
||||||
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
||||||
background: done ? '#f1f2f4' : KDS.qtyBg, color: done ? KDS.doneInk : KDS.qtyInk,
|
background: KDS.cardSoft, color: done ? KDS.cardMuted : KDS.cardInk,
|
||||||
borderRadius: Math.round(5 * fs), fontFamily: 'ui-monospace, monospace', fontWeight: 700, fontSize: Math.round(12 * fs), lineHeight: 1,
|
borderRadius: Math.round(5 * fs), fontFamily: KDS.fontMono, fontWeight: 700, fontSize: Math.round(12 * fs), lineHeight: 1,
|
||||||
}}>
|
}}>
|
||||||
{formatQty(item.quantity, item.unit_type)}
|
{formatQty(item.quantity, item.unit_type)}
|
||||||
</span>
|
</span>
|
||||||
<span style={{
|
<span style={{
|
||||||
color: done ? KDS.doneInk : KDS.ink, fontSize: nameFontSize, fontWeight, lineHeight: `${nameLineH}px`,
|
color: done ? KDS.cardMuted : KDS.cardInk, fontSize: nameFontSize, fontWeight, lineHeight: `${nameLineH}px`,
|
||||||
textDecoration: done ? 'line-through' : 'none', textDecorationThickness: 2, flex: '1 1 auto', minWidth: 0,
|
textDecoration: done ? 'line-through' : 'none', textDecorationThickness: 2, flex: '1 1 auto', minWidth: 0,
|
||||||
}}>
|
}}>
|
||||||
{item.product_name}
|
{item.product_name}
|
||||||
@@ -71,8 +71,8 @@ export default function ItemBlock({ item, focused, onBump, onDecline, fontScale
|
|||||||
{focused && (
|
{focused && (
|
||||||
<span style={{
|
<span style={{
|
||||||
flexShrink: 0, width: 8, height: 8, borderRadius: 4, display: 'inline-block', marginTop: Math.round((badgeH - 8) / 2),
|
flexShrink: 0, width: 8, height: 8, borderRadius: 4, display: 'inline-block', marginTop: Math.round((badgeH - 8) / 2),
|
||||||
background: done ? KDS.green : preparing ? KDS.accent : KDS.qtyBg,
|
background: done ? KDS.fresh : preparing ? KDS.progress : KDS.cardSoft,
|
||||||
border: `1px solid ${done ? KDS.greenD : preparing ? KDS.accent : '#ccc'}`,
|
border: `1px solid ${done ? KDS.freshDeep : preparing ? KDS.progress : KDS.cardMuted}`,
|
||||||
}} />
|
}} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -80,18 +80,18 @@ export default function ItemBlock({ item, focused, onBump, onDecline, fontScale
|
|||||||
<div style={{ marginTop: 3, paddingLeft: badgeH + 7, display: 'flex', flexDirection: 'column', gap: 3 }}>
|
<div style={{ marginTop: 3, paddingLeft: badgeH + 7, display: 'flex', flexDirection: 'column', gap: 3 }}>
|
||||||
{combineModifiers ? (
|
{combineModifiers ? (
|
||||||
<>
|
<>
|
||||||
{removed.length > 0 && <ModRow Icon={Minus} color={KDS.redD} text={removed.join(' · ')} done={done} fs={fs} />}
|
{removed.length > 0 && <ModRow Icon={Minus} color={KDS.lateDeep} text={removed.join(' · ')} done={done} fs={fs} />}
|
||||||
{extras.length > 0 && <ModRow Icon={Plus} color={KDS.greenD} text={extras.join(' · ')} done={done} fs={fs} />}
|
{extras.length > 0 && <ModRow Icon={Plus} color={KDS.freshDeep} text={extras.join(' · ')} done={done} fs={fs} />}
|
||||||
{prefs.length > 0 && <ModRow Icon={ArrowRight} color={KDS.amberD} text={prefs.join(' · ')} done={done} fs={fs} />}
|
{prefs.length > 0 && <ModRow Icon={ArrowRight} color={KDS.warningDeep} text={prefs.join(' · ')} done={done} fs={fs} />}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{removed.map((r, i) => <ModRow key={`r${i}`} Icon={Minus} color={KDS.redD} text={r} done={done} fs={fs} />)}
|
{removed.map((r, i) => <ModRow key={`r${i}`} Icon={Minus} color={KDS.lateDeep} text={r} done={done} fs={fs} />)}
|
||||||
{extras.map((x, i) => <ModRow key={`e${i}`} Icon={Plus} color={KDS.greenD} text={x} done={done} fs={fs} />)}
|
{extras.map((x, i) => <ModRow key={`e${i}`} Icon={Plus} color={KDS.freshDeep} text={x} done={done} fs={fs} />)}
|
||||||
{prefs.map((p, i) => <ModRow key={`p${i}`} Icon={ArrowRight} color={KDS.amberD} text={p} done={done} fs={fs} />)}
|
{prefs.map((p, i) => <ModRow key={`p${i}`} Icon={ArrowRight} color={KDS.warningDeep} text={p} done={done} fs={fs} />)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{item.notes && <ModRow Icon={Info} color="#3b82f6" text={item.notes} done={done} fs={fs} />}
|
{item.notes && <ModRow Icon={Info} color={KDS.progress} text={item.notes} done={done} fs={fs} />}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Bike, Info, ShoppingBag, User, Utensils } from 'lucide-react'
|
|||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { courseGroups, minutesSince } from '../logic/board'
|
import { courseGroups, minutesSince } from '../logic/board'
|
||||||
import { BLOCK_GAP, BODY_PAD_B, BODY_PAD_H, BODY_PAD_T, CARD_FOOT_H_BASE, CARD_HEAD_H_BASE, CARD_SUB_H_BASE } from '../logic/layout'
|
import { BLOCK_GAP, BODY_PAD_B, BODY_PAD_H, BODY_PAD_T, CARD_FOOT_H_BASE, CARD_HEAD_H_BASE, CARD_SUB_H_BASE } from '../logic/layout'
|
||||||
import { KDS } from '../theme'
|
import { KDS, alpha } from '../theme'
|
||||||
import { ActionBar, QuickActionBar } from './ActionBars'
|
import { ActionBar, QuickActionBar } from './ActionBars'
|
||||||
import ItemBlock from './ItemBlock'
|
import ItemBlock from './ItemBlock'
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ function ChannelBadge({ orderType, tableName, fs }) {
|
|||||||
const Icon = CHANNEL_ICONS[type]
|
const Icon = CHANNEL_ICONS[type]
|
||||||
const iconSz = Math.round(17 * fs)
|
const iconSz = Math.round(17 * fs)
|
||||||
return (
|
return (
|
||||||
<span style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: Math.round(15 * fs), fontWeight: 700, whiteSpace: 'nowrap', color: 'rgba(255,255,255,0.60)', flexShrink: 0 }}>
|
<span style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: Math.round(15 * fs), fontWeight: 700, whiteSpace: 'nowrap', color: alpha('on-status', 0.6), flexShrink: 0 }}>
|
||||||
<Icon style={{ width: iconSz, height: iconSz, opacity: 0.65 }} />
|
<Icon style={{ width: iconSz, height: iconSz, opacity: 0.65 }} />
|
||||||
{type === 'here' && tableName ? tableName : t(`kds.channel.${type}`)}
|
{type === 'here' && tableName ? tableName : t(`kds.channel.${type}`)}
|
||||||
</span>
|
</span>
|
||||||
@@ -30,17 +30,18 @@ function ChannelBadge({ orderType, tableName, fs }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function headColours(age, colours) {
|
function headColours(age, colours) {
|
||||||
if (age === 'done') return [colours.done, KDS.doneSub]
|
if (age === 'done') return [colours.done, KDS.doneDeep]
|
||||||
if (age === 'future') return [KDS.futureHead, KDS.futureSubBg]
|
if (age === 'future') return [KDS.future, KDS.futureDeep]
|
||||||
if (age === 'green') return [colours.fresh, KDS.greenD]
|
if (age === 'green') return [colours.fresh, KDS.freshDeep]
|
||||||
if (age === 'amber') return [colours.warning, KDS.amberD]
|
if (age === 'amber') return [colours.warning, KDS.warningDeep]
|
||||||
return [colours.late, KDS.redD]
|
return [colours.late, KDS.lateDeep]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The board token a card glows in when several status filters are on. */
|
||||||
function glowFor(order, age) {
|
function glowFor(order, age) {
|
||||||
if (age === 'done') return KDS.glowDone
|
if (age === 'done') return 'ink'
|
||||||
if (age === 'future') return KDS.glowFuture
|
if (age === 'future') return 'future-glow'
|
||||||
return order.kds_status === 'preparing' ? KDS.glowPreparing : KDS.glowPending
|
return order.kds_status === 'preparing' ? 'progress' : 'warning'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function OrderCard({ order, age, ageText, layout, focused, dimmed, settings, multiFilter, courses, now,
|
export default function OrderCard({ order, age, ageText, layout, focused, dimmed, settings, multiFilter, courses, now,
|
||||||
@@ -94,13 +95,13 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
return (
|
return (
|
||||||
<Fragment key={bi}>
|
<Fragment key={bi}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 10 * fs, fontWeight: 700, textTransform: 'uppercase',
|
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 10 * fs, fontWeight: 700, textTransform: 'uppercase',
|
||||||
letterSpacing: '.1em', color: '#7b8694', padding: bi === 0 ? '0 0 2px' : '4px 0 2px' }}>
|
letterSpacing: '.1em', color: KDS.cardMuted, padding: bi === 0 ? '0 0 2px' : '4px 0 2px' }}>
|
||||||
<div style={{ flex: 1, height: 1, background: '#e0e5eb' }} />
|
<div style={{ flex: 1, height: 1, background: KDS.cardLine }} />
|
||||||
<span>{t('kds.card.batch', { n: bi + 1 })}</span>
|
<span>{t('kds.card.batch', { n: bi + 1 })}</span>
|
||||||
<span style={{ background: '#f0f2f5', color: '#5b6370', borderRadius: 5, padding: '1px 6px', fontFamily: 'ui-monospace, monospace' }}>
|
<span style={{ background: KDS.cardSoft, color: KDS.cardInk2, borderRadius: 5, padding: '1px 6px', fontFamily: KDS.fontMono }}>
|
||||||
{t('kds.age.minutes', { m: Math.max(0, minutesSince(batch.opened_at, now)) })}
|
{t('kds.age.minutes', { m: Math.max(0, minutesSince(batch.opened_at, now)) })}
|
||||||
</span>
|
</span>
|
||||||
<div style={{ flex: 1, height: 1, background: '#e0e5eb' }} />
|
<div style={{ flex: 1, height: 1, background: KDS.cardLine }} />
|
||||||
</div>
|
</div>
|
||||||
{items.map(item)}
|
{items.map(item)}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
@@ -113,7 +114,7 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
return column(ci, courseGroups(colItems, courses).map((g, gi) => (
|
return column(ci, courseGroups(colItems, courses).map((g, gi) => (
|
||||||
<div key={gi}>
|
<div key={gi}>
|
||||||
<div style={{ fontSize: 10, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.08em',
|
<div style={{ fontSize: 10, fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.08em',
|
||||||
color: g.course ? g.course.color : '#6b7a8d', padding: '4px 10px 2px' }}>
|
color: g.course ? g.course.color : KDS.cardMuted, padding: '4px 10px 2px' }}>
|
||||||
{g.course ? g.course.name : t('kds.card.noCourse')}
|
{g.course ? g.course.name : t('kds.card.noCourse')}
|
||||||
</div>
|
</div>
|
||||||
{g.items.map(item)}
|
{g.items.map(item)}
|
||||||
@@ -131,11 +132,11 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
onPointerDown={onPointerDown} onPointerUp={cancelHold} onPointerLeave={cancelHold} onPointerCancel={cancelHold}
|
onPointerDown={onPointerDown} onPointerUp={cancelHold} onPointerLeave={cancelHold} onPointerCancel={cancelHold}
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute', left: layout.x, top: layout.y, width: layout.w, height: layout.h,
|
position: 'absolute', left: layout.x, top: layout.y, width: layout.w, height: layout.h,
|
||||||
background: headBg, borderRadius: 10, overflow: 'hidden',
|
background: headBg, borderRadius: KDS.radiusCard, overflow: 'hidden',
|
||||||
boxShadow: focused
|
boxShadow: focused
|
||||||
? `0 10px 24px rgba(0,0,0,.4), 0 0 0 4px rgba(47,127,240,.25)${glow ? `, 0 0 0 2px ${glow}40` : ''}`
|
? `${KDS.shadowFocus}${glow ? `, 0 0 0 2px ${alpha(glow, 0.25)}` : ''}`
|
||||||
: `0 1px 2px rgba(0,0,0,.25), 0 6px 16px rgba(0,0,0,.22)${glow ? `, 0 0 12px 2px ${glow}55, 0 0 0 2px ${glow}44` : ''}`,
|
: `${KDS.shadowCard}${glow ? `, 0 0 12px 2px ${alpha(glow, 0.33)}, 0 0 0 2px ${alpha(glow, 0.27)}` : ''}`,
|
||||||
outline: focused ? `2px solid ${KDS.accent}` : '2px solid transparent', outlineOffset: 2,
|
outline: focused ? `2px solid ${KDS.progress}` : '2px solid transparent', outlineOffset: 2,
|
||||||
display: 'flex', flexDirection: 'column',
|
display: 'flex', flexDirection: 'column',
|
||||||
transform: focused ? 'scale(1.012)' : 'none', transition: 'box-shadow .15s, transform .15s, outline-color .15s',
|
transform: focused ? 'scale(1.012)' : 'none', transition: 'box-shadow .15s, transform .15s, outline-color .15s',
|
||||||
opacity: dimmed ? 0.42 : 1, filter: dimmed ? 'saturate(.7)' : 'none', zIndex: focused ? 60 : 1,
|
opacity: dimmed ? 0.42 : 1, filter: dimmed ? 'saturate(.7)' : 'none', zIndex: focused ? 60 : 1,
|
||||||
@@ -143,13 +144,13 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={age.flash && settings.flashLate ? 'kds-flash' : undefined} style={{
|
<div className={age.flash && settings.flashLate ? 'kds-flash' : undefined} style={{
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '0 11px', color: '#fff',
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '0 11px', color: KDS.onStatus,
|
||||||
height: Math.round(CARD_HEAD_H_BASE * fs), flexShrink: 0, background: headBg, gap: 8,
|
height: Math.round(CARD_HEAD_H_BASE * fs), flexShrink: 0, background: headBg, gap: 8,
|
||||||
}}>
|
}}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 }}>
|
||||||
<span data-testid="card-age" style={{
|
<span data-testid="card-age" style={{
|
||||||
background: 'rgba(255,255,255,0.92)', color: '#0a0c0f', borderRadius: 7, padding: `0 ${Math.round(9 * fs)}px`,
|
background: alpha('on-status', 0.92), color: KDS.deep, borderRadius: 7, padding: `0 ${Math.round(9 * fs)}px`,
|
||||||
height: Math.round(30 * fs), fontSize: Math.round(17 * fs), fontWeight: 800, fontVariantNumeric: 'tabular-nums',
|
height: Math.round(30 * fs), fontSize: Math.round(17 * fs), fontWeight: 800, fontFamily: KDS.fontNumber, fontVariantNumeric: 'tabular-nums',
|
||||||
letterSpacing: '-0.02em', flexShrink: 0, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
letterSpacing: '-0.02em', flexShrink: 0, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
||||||
}}>
|
}}>
|
||||||
{ageText}
|
{ageText}
|
||||||
@@ -162,7 +163,7 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{
|
<div style={{
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'space-between', background: subBg, color: 'rgba(255,255,255,0.88)',
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between', background: subBg, color: alpha('on-status', 0.88),
|
||||||
padding: '0 11px', height: Math.round(CARD_SUB_H_BASE * fs), flexShrink: 0, fontSize: 12.5 * fs, fontWeight: 600,
|
padding: '0 11px', height: Math.round(CARD_SUB_H_BASE * fs), flexShrink: 0, fontSize: 12.5 * fs, fontWeight: 600,
|
||||||
}}>
|
}}>
|
||||||
<span style={{ fontFamily: 'ui-monospace, monospace', letterSpacing: '.02em', opacity: 0.85, lineHeight: 1 }}>#{order.id}</span>
|
<span style={{ fontFamily: 'ui-monospace, monospace', letterSpacing: '.02em', opacity: 0.85, lineHeight: 1 }}>#{order.id}</span>
|
||||||
@@ -172,7 +173,7 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{
|
<div style={{
|
||||||
background: isFuture ? '#f0f2f5' : order.kds_status === 'done' ? '#f4f7f4' : order.kds_status === 'preparing' ? '#f3f8ff' : '#ffffff',
|
background: isFuture ? KDS.cardSoft : order.kds_status === 'done' ? KDS.cardDone : order.kds_status === 'preparing' ? KDS.cardProgress : KDS.card,
|
||||||
paddingTop: BODY_PAD_T, paddingBottom: BODY_PAD_B, paddingLeft: BODY_PAD_H, paddingRight: BODY_PAD_H,
|
paddingTop: BODY_PAD_T, paddingBottom: BODY_PAD_B, paddingLeft: BODY_PAD_H, paddingRight: BODY_PAD_H,
|
||||||
display: 'flex', gap: 12, flex: '1 1 auto', overflow: 'hidden',
|
display: 'flex', gap: 12, flex: '1 1 auto', overflow: 'hidden',
|
||||||
}}>
|
}}>
|
||||||
@@ -180,13 +181,13 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{order.notes && (
|
{order.notes && (
|
||||||
<div style={{ background: '#fffbeb', borderTop: `1px solid ${KDS.line}`, flexShrink: 0 }}>
|
<div style={{ background: KDS.note, borderTop: `1px solid ${KDS.cardLine}`, flexShrink: 0 }}>
|
||||||
<div style={{ height: Math.round(6 * fs) }} />
|
<div style={{ height: Math.round(6 * fs) }} />
|
||||||
<div style={{
|
<div style={{
|
||||||
padding: `0 ${Math.round(BODY_PAD_H * fs)}px ${Math.round(8 * fs)}px`, fontSize: Math.round(12.5 * fs), fontWeight: 600,
|
padding: `0 ${Math.round(BODY_PAD_H * fs)}px ${Math.round(8 * fs)}px`, fontSize: Math.round(12.5 * fs), fontWeight: 600,
|
||||||
color: '#b45309', fontStyle: 'italic', lineHeight: 1.45, display: 'flex', alignItems: 'flex-start', gap: Math.round(5 * fs),
|
color: KDS.noteInk, fontStyle: 'italic', lineHeight: 1.45, display: 'flex', alignItems: 'flex-start', gap: Math.round(5 * fs),
|
||||||
}}>
|
}}>
|
||||||
<Info style={{ width: Math.round(13 * fs), height: Math.round(13 * fs), flexShrink: 0, marginTop: Math.round(2 * fs), color: '#d97706' }} />
|
<Info style={{ width: Math.round(13 * fs), height: Math.round(13 * fs), flexShrink: 0, marginTop: Math.round(2 * fs), color: KDS.noteInk }} />
|
||||||
<span>{order.notes}</span>
|
<span>{order.notes}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -194,8 +195,8 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
|
|||||||
|
|
||||||
{waiter && (
|
{waiter && (
|
||||||
<div style={{
|
<div style={{
|
||||||
background: KDS.cardFoot, color: KDS.cardFootInk, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 7,
|
background: KDS.cardSoft, color: KDS.cardInk2, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 7,
|
||||||
height: Math.round(CARD_FOOT_H_BASE * fs), flexShrink: 0, fontSize: 13 * fs, fontWeight: 700, borderTop: `1px solid ${KDS.line}`,
|
height: Math.round(CARD_FOOT_H_BASE * fs), flexShrink: 0, fontSize: 13 * fs, fontWeight: 700, borderTop: `1px solid ${KDS.cardLine}`,
|
||||||
}}>
|
}}>
|
||||||
<User style={{ width: 13, height: 13, opacity: 0.7 }} />
|
<User style={{ width: 13, height: 13, opacity: 0.7 }} />
|
||||||
{waiter}
|
{waiter}
|
||||||
|
|||||||
@@ -3,22 +3,22 @@
|
|||||||
// Plan step 3.2b, from KdsPage.jsx.
|
// Plan step 3.2b, from KdsPage.jsx.
|
||||||
import { BellRing, CheckCheck, Clock, CookingPot, Flame, Redo2, Settings, Timer, Undo2, Volume2, VolumeX, ZoomIn, ZoomOut } from 'lucide-react'
|
import { BellRing, CheckCheck, Clock, CookingPot, Flame, Redo2, Settings, Timer, Undo2, Volume2, VolumeX, ZoomIn, ZoomOut } from 'lucide-react'
|
||||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||||
import { KDS } from '../theme'
|
import { KDS, alpha } from '../theme'
|
||||||
|
|
||||||
const STATUSES = [
|
const STATUSES = [
|
||||||
{ key: 'future', Icon: Clock, colour: KDS.green },
|
{ key: 'future', Icon: Clock, colour: KDS.fresh },
|
||||||
{ key: 'pending', Icon: Timer, colour: KDS.amber },
|
{ key: 'pending', Icon: Timer, colour: KDS.warning },
|
||||||
{ key: 'preparing', Icon: Flame, colour: KDS.accent },
|
{ key: 'preparing', Icon: Flame, colour: KDS.progress },
|
||||||
{ key: 'done', Icon: CheckCheck, colour: '#cdd6e0' },
|
{ key: 'done', Icon: CheckCheck, colour: KDS.ink },
|
||||||
]
|
]
|
||||||
|
|
||||||
function RailButton({ active, colour, onClick, disabled, fs, children, testId }) {
|
function RailButton({ active, colour = KDS.ink, onClick, disabled, fs, children, testId }) {
|
||||||
return (
|
return (
|
||||||
<button type="button" data-testid={testId} data-active={active ? 'true' : 'false'} onClick={onClick} disabled={disabled} style={{
|
<button type="button" data-testid={testId} data-active={active ? 'true' : 'false'} onClick={onClick} disabled={disabled} style={{
|
||||||
position: 'relative', width: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center',
|
position: 'relative', width: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center',
|
||||||
gap: Math.round(4 * fs), padding: `${Math.round(9 * fs)}px ${Math.round(4 * fs)}px`, borderRadius: Math.round(10 * fs),
|
gap: Math.round(4 * fs), padding: `${Math.round(9 * fs)}px ${Math.round(4 * fs)}px`, borderRadius: Math.round(10 * fs),
|
||||||
color: active ? colour : '#8b95a1', background: active ? 'rgba(255,255,255,0.06)' : 'none',
|
color: active ? colour : KDS.ink3, background: active ? alpha('ink', 0.06) : 'none',
|
||||||
border: active ? '1px solid rgba(255,255,255,0.08)' : '1px solid transparent',
|
border: active ? `1px solid ${alpha('ink', 0.08)}` : '1px solid transparent',
|
||||||
cursor: disabled ? 'default' : 'pointer', fontFamily: 'inherit', opacity: disabled ? 0.32 : 1, transition: 'background .12s, color .12s, opacity .15s',
|
cursor: disabled ? 'default' : 'pointer', fontFamily: 'inherit', opacity: disabled ? 0.32 : 1, transition: 'background .12s, color .12s, opacity .15s',
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
@@ -35,7 +35,7 @@ export function SideRail({ filters, counts, onToggleFilter, soundOn, onToggleSou
|
|||||||
const badgeH = Math.round(22 * fs)
|
const badgeH = Math.round(22 * fs)
|
||||||
const group = { display: 'flex', flexDirection: 'column', gap: 2, padding: `2px ${Math.round(8 * fs)}px` }
|
const group = { display: 'flex', flexDirection: 'column', gap: 2, padding: `2px ${Math.round(8 * fs)}px` }
|
||||||
return (
|
return (
|
||||||
<nav data-testid="kds-rail" style={{ width: Math.round(KDS.railW * fs), flexShrink: 0, background: KDS.rail, borderRight: `1px solid ${KDS.railLine}`,
|
<nav data-testid="kds-rail" style={{ width: Math.round(KDS.railW * fs), flexShrink: 0, background: KDS.rail, borderRight: `1px solid ${KDS.line}`,
|
||||||
display: 'flex', flexDirection: 'column', alignItems: 'stretch', padding: `${Math.round(10 * fs)}px 0`, gap: 2, overflowY: 'auto' }}>
|
display: 'flex', flexDirection: 'column', alignItems: 'stretch', padding: `${Math.round(10 * fs)}px 0`, gap: 2, overflowY: 'auto' }}>
|
||||||
<div style={group}>
|
<div style={group}>
|
||||||
{STATUSES.map(({ key, Icon, colour }) => {
|
{STATUSES.map(({ key, Icon, colour }) => {
|
||||||
@@ -46,23 +46,23 @@ export function SideRail({ filters, counts, onToggleFilter, soundOn, onToggleSou
|
|||||||
{label(t(`kds.rail.${key}`))}
|
{label(t(`kds.rail.${key}`))}
|
||||||
<span data-testid={`count-${key}`} style={{ minWidth: badgeH, height: badgeH, padding: `0 ${Math.round(6 * fs)}px`, display: 'inline-flex',
|
<span data-testid={`count-${key}`} style={{ minWidth: badgeH, height: badgeH, padding: `0 ${Math.round(6 * fs)}px`, display: 'inline-flex',
|
||||||
alignItems: 'center', justifyContent: 'center', borderRadius: Math.round(11 * fs), fontSize: Math.round(12 * fs), fontWeight: 700,
|
alignItems: 'center', justifyContent: 'center', borderRadius: Math.round(11 * fs), fontSize: Math.round(12 * fs), fontWeight: 700,
|
||||||
background: active ? colour : '#2b333d', color: active ? '#0e1217' : '#cfd6df' }}>
|
background: active ? colour : KDS.line, color: active ? KDS.deep : KDS.ink2 }}>
|
||||||
{counts[key] || 0}
|
{counts[key] || 0}
|
||||||
</span>
|
</span>
|
||||||
</RailButton>
|
</RailButton>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
<div style={{ height: 1, background: KDS.railLine, margin: `${Math.round(6 * fs)}px` }} />
|
<div style={{ height: 1, background: KDS.line, margin: `${Math.round(6 * fs)}px` }} />
|
||||||
<RailButton testId="kds-undo" active={false} colour="#fff" onClick={onUndo} disabled={!canUndo} fs={fs}><Undo2 style={sm} />{label(t('kds.rail.undo'))}</RailButton>
|
<RailButton testId="kds-undo" active={false} onClick={onUndo} disabled={!canUndo} fs={fs}><Undo2 style={sm} />{label(t('kds.rail.undo'))}</RailButton>
|
||||||
<RailButton testId="kds-redo" active={false} colour="#fff" onClick={onRedo} disabled={!canRedo} fs={fs}><Redo2 style={sm} />{label(t('kds.rail.redo'))}</RailButton>
|
<RailButton testId="kds-redo" active={false} onClick={onRedo} disabled={!canRedo} fs={fs}><Redo2 style={sm} />{label(t('kds.rail.redo'))}</RailButton>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flex: '1 1 auto' }} />
|
<div style={{ flex: '1 1 auto' }} />
|
||||||
<div style={group}>
|
<div style={group}>
|
||||||
<RailButton testId="kds-call" active={false} colour="#fff" onClick={onCall} fs={fs}><BellRing style={sm} />{label(t('kds.rail.call'))}</RailButton>
|
<RailButton testId="kds-call" active={false} onClick={onCall} fs={fs}><BellRing style={sm} />{label(t('kds.rail.call'))}</RailButton>
|
||||||
<RailButton testId="kds-sound" active={false} colour="#fff" onClick={onToggleSound} fs={fs}>
|
<RailButton testId="kds-sound" active={false} onClick={onToggleSound} fs={fs}>
|
||||||
{soundOn ? <Volume2 style={sm} /> : <VolumeX style={sm} />}{label(soundOn ? t('kds.rail.sound') : t('kds.rail.muted'))}
|
{soundOn ? <Volume2 style={sm} /> : <VolumeX style={sm} />}{label(soundOn ? t('kds.rail.sound') : t('kds.rail.muted'))}
|
||||||
</RailButton>
|
</RailButton>
|
||||||
<RailButton testId="kds-settings" active={false} colour="#fff" onClick={onSettings} fs={fs}><Settings style={sm} />{label(t('kds.rail.settings'))}</RailButton>
|
<RailButton testId="kds-settings" active={false} onClick={onSettings} fs={fs}><Settings style={sm} />{label(t('kds.rail.settings'))}</RailButton>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
)
|
)
|
||||||
@@ -76,12 +76,12 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
|
|||||||
const fs = fontScale
|
const fs = fontScale
|
||||||
const tabH = Math.round(36 * fs)
|
const tabH = Math.round(36 * fs)
|
||||||
const tabR = Math.round(9 * fs)
|
const tabR = Math.round(9 * fs)
|
||||||
const clockFont = { fontSize: Math.round(14 * fs), fontFamily: 'Arial, "Helvetica Neue", sans-serif' }
|
const clockFont = { fontSize: Math.round(14 * fs), fontFamily: KDS.fontNumber }
|
||||||
const zoomButton = { width: tabH, height: tabH, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'none', border: 'none',
|
const zoomButton = { width: tabH, height: tabH, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'none', border: 'none',
|
||||||
cursor: 'pointer', color: KDS.tabInk, borderRadius: Math.round(7 * fs) }
|
cursor: 'pointer', color: KDS.ink2, borderRadius: Math.round(7 * fs) }
|
||||||
const zi = { width: Math.round(15 * fs), height: Math.round(15 * fs) }
|
const zi = { width: Math.round(15 * fs), height: Math.round(15 * fs) }
|
||||||
return (
|
return (
|
||||||
<div data-testid="kds-topbar" style={{ height: Math.round(KDS.topbarH * fs), flexShrink: 0, background: KDS.topbar, borderBottom: `1px solid ${KDS.railLine}`,
|
<div data-testid="kds-topbar" style={{ height: Math.round(KDS.topbarH * fs), flexShrink: 0, background: KDS.topbar, borderBottom: `1px solid ${KDS.line}`,
|
||||||
display: 'flex', alignItems: 'center', gap: 8, padding: '0 12px' }}>
|
display: 'flex', alignItems: 'center', gap: 8, padding: '0 12px' }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, flexShrink: 0, overflowX: 'auto' }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 6, flexShrink: 0, overflowX: 'auto' }}>
|
||||||
{TABS.map(key => {
|
{TABS.map(key => {
|
||||||
@@ -89,13 +89,13 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
|
|||||||
return (
|
return (
|
||||||
<button key={key} type="button" data-testid={`tab-${key}`} onClick={() => onTab(key)} style={{
|
<button key={key} type="button" data-testid={`tab-${key}`} onClick={() => onTab(key)} style={{
|
||||||
flexShrink: 0, display: 'flex', alignItems: 'center', gap: Math.round(7 * fs), height: tabH, padding: `0 ${Math.round(14 * fs)}px`,
|
flexShrink: 0, display: 'flex', alignItems: 'center', gap: Math.round(7 * fs), height: tabH, padding: `0 ${Math.round(14 * fs)}px`,
|
||||||
borderRadius: tabR, background: active ? KDS.tabActiveBg : KDS.tab, color: active ? KDS.tabActiveInk : KDS.tabInk,
|
borderRadius: tabR, background: active ? KDS.tabActive : KDS.line, color: active ? KDS.bg : KDS.ink2,
|
||||||
fontSize: Math.round(13 * fs), fontWeight: 600, whiteSpace: 'nowrap', border: 'none', cursor: 'pointer', fontFamily: 'inherit',
|
fontSize: Math.round(13 * fs), fontWeight: 600, whiteSpace: 'nowrap', border: 'none', cursor: 'pointer', fontFamily: 'inherit',
|
||||||
}}>
|
}}>
|
||||||
{key === 'all' ? t('kds.tabs.all') : t(`kds.channel.${key}`)}
|
{key === 'all' ? t('kds.tabs.all') : t(`kds.channel.${key}`)}
|
||||||
<span style={{ minWidth: Math.round(20 * fs), height: Math.round(20 * fs), padding: `0 ${Math.round(5 * fs)}px`, display: 'inline-flex',
|
<span style={{ minWidth: Math.round(20 * fs), height: Math.round(20 * fs), padding: `0 ${Math.round(5 * fs)}px`, display: 'inline-flex',
|
||||||
alignItems: 'center', justifyContent: 'center', borderRadius: Math.round(6 * fs), fontSize: Math.round(11 * fs), fontWeight: 700,
|
alignItems: 'center', justifyContent: 'center', borderRadius: Math.round(6 * fs), fontSize: Math.round(11 * fs), fontWeight: 700,
|
||||||
background: active ? 'rgba(0,0,0,.10)' : 'rgba(255,255,255,.08)', color: active ? '#41474f' : KDS.tabInk }}>
|
background: active ? alpha('deep', 0.10) : alpha('ink', 0.08), color: active ? KDS.cardInk2 : KDS.ink2 }}>
|
||||||
{counts[key] ?? 0}
|
{counts[key] ?? 0}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -106,7 +106,7 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
|
|||||||
{showSummaryButton && (
|
{showSummaryButton && (
|
||||||
<button type="button" data-testid="summary-button" onClick={onToggleSummary} style={{
|
<button type="button" data-testid="summary-button" onClick={onToggleSummary} style={{
|
||||||
flexShrink: 0, display: 'flex', alignItems: 'center', gap: Math.round(6 * fs), height: tabH, padding: `0 ${Math.round(14 * fs)}px`,
|
flexShrink: 0, display: 'flex', alignItems: 'center', gap: Math.round(6 * fs), height: tabH, padding: `0 ${Math.round(14 * fs)}px`,
|
||||||
borderRadius: tabR, background: summaryOpen ? KDS.tabActiveBg : KDS.tab, color: summaryOpen ? KDS.tabActiveInk : KDS.tabInk,
|
borderRadius: tabR, background: summaryOpen ? KDS.tabActive : KDS.line, color: summaryOpen ? KDS.bg : KDS.ink2,
|
||||||
fontSize: Math.round(13 * fs), fontWeight: 600, border: 'none', cursor: 'pointer', fontFamily: 'inherit',
|
fontSize: Math.round(13 * fs), fontWeight: 600, border: 'none', cursor: 'pointer', fontFamily: 'inherit',
|
||||||
}}>
|
}}>
|
||||||
<CookingPot style={zi} />
|
<CookingPot style={zi} />
|
||||||
@@ -115,13 +115,13 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
|
|||||||
)}
|
)}
|
||||||
<div style={{ flex: '1 1 0' }} />
|
<div style={{ flex: '1 1 0' }} />
|
||||||
<div data-testid="kds-clock" style={{ display: 'flex', alignItems: 'center', gap: Math.round(6 * fs), flexShrink: 0, whiteSpace: 'nowrap' }}>
|
<div data-testid="kds-clock" style={{ display: 'flex', alignItems: 'center', gap: Math.round(6 * fs), flexShrink: 0, whiteSpace: 'nowrap' }}>
|
||||||
<span style={{ ...clockFont, fontWeight: 600, color: '#c8d0db' }}>{formatDate(now, 'dateLong')}</span>
|
<span style={{ ...clockFont, fontWeight: 600, color: KDS.ink2 }}>{formatDate(now, 'dateLong')}</span>
|
||||||
<span style={{ ...clockFont, fontWeight: 700, color: '#f1f4f8' }}>{formatTime(now)}</span>
|
<span style={{ ...clockFont, fontWeight: 700, color: KDS.ink }}>{formatTime(now)}</span>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ width: 1, height: Math.round(24 * fs), background: KDS.railLine, flexShrink: 0 }} />
|
<div style={{ width: 1, height: Math.round(24 * fs), background: KDS.line, flexShrink: 0 }} />
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: 2, background: KDS.tab, borderRadius: tabR, padding: `0 ${Math.round(4 * fs)}px`, flexShrink: 0, height: tabH }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: 2, background: KDS.line, borderRadius: tabR, padding: `0 ${Math.round(4 * fs)}px`, flexShrink: 0, height: tabH }}>
|
||||||
<button type="button" data-testid="zoom-out" aria-label={t('kds.zoom.smaller')} title={t('kds.zoom.smaller')} onClick={() => onZoom(-1)} style={zoomButton}><ZoomOut style={zi} /></button>
|
<button type="button" data-testid="zoom-out" aria-label={t('kds.zoom.smaller')} title={t('kds.zoom.smaller')} onClick={() => onZoom(-1)} style={zoomButton}><ZoomOut style={zi} /></button>
|
||||||
<span data-testid="zoom-level" style={{ fontSize: Math.round(11 * fs), fontWeight: 700, color: KDS.tabInk, minWidth: Math.round(34 * fs), textAlign: 'center', fontFamily: 'ui-monospace, monospace' }}>
|
<span data-testid="zoom-level" style={{ fontSize: Math.round(11 * fs), fontWeight: 700, color: KDS.ink2, minWidth: Math.round(34 * fs), textAlign: 'center', fontFamily: KDS.fontMono }}>
|
||||||
{zoomPercent}%
|
{zoomPercent}%
|
||||||
</span>
|
</span>
|
||||||
<button type="button" data-testid="zoom-in" aria-label={t('kds.zoom.larger')} title={t('kds.zoom.larger')} onClick={() => onZoom(1)} style={zoomButton}><ZoomIn style={zi} /></button>
|
<button type="button" data-testid="zoom-in" aria-label={t('kds.zoom.larger')} title={t('kds.zoom.larger')} onClick={() => onZoom(1)} style={zoomButton}><ZoomIn style={zi} /></button>
|
||||||
|
|||||||
@@ -1,66 +1,36 @@
|
|||||||
// This screen's settings, changed on the screen itself (plan step 3.2b): the device config of
|
// This screen's settings, changed on the screen itself (plan steps 3.2b, 3.2b-2): the device
|
||||||
// 3.2a, saved with PATCH /api/devices/me/config (only someone holding core.devices.manage;
|
// config of 3.2a, saved with PATCH /api/devices/me/config (only someone holding
|
||||||
// others see the settings and a note). The texts are the Devices page's
|
// core.devices.manage; others see the settings and a note). Texts are the Devices page's
|
||||||
// (modules:kds.config.*), so both places say the same thing. The saved settings come back
|
// (modules:kds.config.*), so both places say the same thing. Shared @xenia/ui components
|
||||||
// through device.updated → GET /api/devices/me, like an edit on the Devices page.
|
// (dark theme on the KDS). The saved settings come back through device.updated → GET
|
||||||
|
// /api/devices/me, like an edit on the Devices page.
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Check } from 'lucide-react'
|
import { Check } from 'lucide-react'
|
||||||
import { useCan } from '@xenia/access'
|
import { useCan } from '@xenia/access'
|
||||||
import { errorMessage } from '@xenia/api'
|
import { errorMessage } from '@xenia/api'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
|
import { Button, Dialog, Select, Stepper, Switch } from '@xenia/ui'
|
||||||
import client from '../../../api/client'
|
import client from '../../../api/client'
|
||||||
import { DEFAULT_CONFIG, FONT_SCALE_MAX, FONT_SCALE_MIN, FONT_SCALE_STEP } from '../logic/settings'
|
import { DEFAULT_CONFIG, FONT_SCALE_MAX, FONT_SCALE_MIN, FONT_SCALE_STEP } from '../logic/settings'
|
||||||
import { KDS, secondaryButton } from '../theme'
|
|
||||||
import { CloseButton, KdsModal } from './Dialogs'
|
|
||||||
|
|
||||||
const CARD_WIDTHS = [200, 220, 240, 260, 272, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 540, 580, 620, 660, 700, 750, 800]
|
const CARD_WIDTHS = [200, 220, 240, 260, 272, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 540, 580, 620, 660, 700, 750, 800]
|
||||||
const WEIGHTS = [300, 400, 500, 600, 700, 800]
|
const WEIGHTS = [300, 400, 500, 600, 700, 800]
|
||||||
const REFRESH = [10, 15, 20, 30, 45, 60, 90, 120]
|
const REFRESH = [10, 15, 20, 30, 45, 60, 90, 120]
|
||||||
const SIGN_OUT = [0, 2, 5, 10, 30, 60]
|
const SIGN_OUT = [0, 2, 5, 10, 30, 60]
|
||||||
const FONT_SCALES = Array.from({ length: (FONT_SCALE_MAX - FONT_SCALE_MIN) / FONT_SCALE_STEP + 1 }, (_, i) => FONT_SCALE_MIN + i * FONT_SCALE_STEP)
|
const FONT_SCALES = Array.from({ length: (FONT_SCALE_MAX - FONT_SCALE_MIN) / FONT_SCALE_STEP + 1 }, (_, i) => FONT_SCALE_MIN + i * FONT_SCALE_STEP)
|
||||||
const PRESETS = ['#34b56a', '#7ec828', '#f5c518', '#f07d2a', '#e8513f', '#e84f9a', '#9b5de5', '#2f7ff0', '#1fabbe', '#e7ecf2', '#3d4757']
|
// Colours offered for the age states: the board's own (--x-board-*) first, then a few more.
|
||||||
|
// They are stored as values in the device config, so they are data here, not styling.
|
||||||
|
const PRESETS = ['#34b56a', '#7ec828', '#f5c518', '#f0a52a', '#f07d2a', '#e8513f', '#e84f9a', '#9b5de5', '#2f7ff0', '#1fabbe', '#e7ecf2', '#3d4757']
|
||||||
const TABS = ['zone', 'behaviour', 'board', 'age', 'notifications']
|
const TABS = ['zone', 'behaviour', 'board', 'age', 'notifications']
|
||||||
|
|
||||||
const nearest = (steps, v) => steps.reduce((a, b) => (Math.abs(b - v) < Math.abs(a - v) ? b : a))
|
|
||||||
|
|
||||||
function Stepper({ value, steps, display, onChange, min = -Infinity, max = Infinity, testId }) {
|
|
||||||
const options = steps.filter(s => s >= min && s <= max)
|
|
||||||
const cur = nearest(options, value)
|
|
||||||
const i = options.indexOf(cur)
|
|
||||||
const btn = on => ({
|
|
||||||
width: 44, height: 44, borderRadius: 10, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
||||||
background: on ? '#2e3a47' : '#232d38', color: on ? KDS.panelInk : '#4a5568', border: `1px solid ${on ? '#3d4f5e' : '#2a3542'}`,
|
|
||||||
cursor: on ? 'pointer' : 'default', fontFamily: 'inherit', fontSize: 22, fontWeight: 300, userSelect: 'none',
|
|
||||||
})
|
|
||||||
return (
|
|
||||||
<div data-testid={testId} style={{ display: 'flex', alignItems: 'center', gap: 6, flexShrink: 0 }}>
|
|
||||||
<button type="button" aria-label="-" style={btn(i > 0)} onClick={() => i > 0 && onChange(options[i - 1])}>−</button>
|
|
||||||
<span style={{ minWidth: 64, textAlign: 'center', fontSize: 16, fontWeight: 700, fontFamily: 'ui-monospace, monospace' }}>{display(cur)}</span>
|
|
||||||
<button type="button" aria-label="+" style={btn(i < options.length - 1)} onClick={() => i < options.length - 1 && onChange(options[i + 1])}>+</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Toggle({ on, onToggle, testId }) {
|
|
||||||
return (
|
|
||||||
<button type="button" role="switch" aria-checked={on} data-testid={testId} onClick={onToggle} style={{
|
|
||||||
width: 56, height: 32, borderRadius: 16, flexShrink: 0, background: on ? KDS.accent : '#3a4450', position: 'relative', border: 'none', cursor: 'pointer',
|
|
||||||
}}>
|
|
||||||
<span style={{ position: 'absolute', top: 4, left: 4, width: 24, height: 24, borderRadius: '50%', background: '#fff',
|
|
||||||
transform: on ? 'translateX(24px)' : 'none', transition: 'transform .15s' }} />
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function Swatches({ value, onChange, testId }) {
|
function Swatches({ value, onChange, testId }) {
|
||||||
return (
|
return (
|
||||||
<div data-testid={testId} style={{ display: 'flex', flexWrap: 'wrap', gap: 6, maxWidth: 260, justifyContent: 'flex-end' }}>
|
<div data-testid={testId} className="flex flex-wrap gap-1.5 max-w-[260px] justify-end">
|
||||||
{PRESETS.map(p => (
|
{PRESETS.map(p => (
|
||||||
<button key={p} type="button" aria-label={p} data-colour={p} onClick={() => onChange(p)} style={{
|
<button key={p} type="button" aria-label={p} aria-pressed={value === p} data-colour={p} onClick={() => onChange(p)}
|
||||||
width: 30, height: 30, borderRadius: 8, background: p, cursor: 'pointer', border: value === p ? '2px solid #fff' : '2px solid transparent',
|
className={`size-8 rounded-[var(--x-radius-sm)] border-2 ${value === p ? 'border-ink' : 'border-transparent'}`} style={{ background: p }} />
|
||||||
}} />
|
|
||||||
))}
|
))}
|
||||||
{!PRESETS.includes(value) && <span style={{ width: 30, height: 30, borderRadius: 8, background: value, border: '2px solid #fff' }} />}
|
{!PRESETS.includes(value) && <span className="size-8 rounded-[var(--x-radius-sm)] border-2 border-ink" style={{ background: value }} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -77,39 +47,35 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
|
|||||||
const choice = (key, v) => t(`modules:kds.config.${key}.choices.${v}`, { defaultValue: String(v) })
|
const choice = (key, v) => t(`modules:kds.config.${key}.choices.${v}`, { defaultValue: String(v) })
|
||||||
|
|
||||||
const row = (key, control) => (
|
const row = (key, control) => (
|
||||||
<div key={key} data-setting={key} style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16, padding: '10px 0', borderBottom: `1px solid ${KDS.panelLine2}` }}>
|
<div key={key} data-setting={key} className="flex items-center justify-between gap-4 py-3 border-b border-line">
|
||||||
<div style={{ flex: '1 1 auto', minWidth: 0 }}>
|
<div className="flex-1 min-w-0">
|
||||||
<div style={{ fontSize: 15, fontWeight: 500 }}>{L(key)}</div>
|
<div className="text-body-lg font-medium text-ink">{L(key)}</div>
|
||||||
{L(key, 'hint') && <div style={{ fontSize: 12.5, color: KDS.panelInk2, marginTop: 3, lineHeight: 1.4 }}>{L(key, 'hint')}</div>}
|
{L(key, 'hint') && <div className="text-label text-ink-2 mt-0.5">{L(key, 'hint')}</div>}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flexShrink: 0 }}>{control}</div>
|
<div className="shrink-0">{control}</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
const toggle = key => (
|
||||||
|
<div key={key} data-setting={key} className="py-3 border-b border-line">
|
||||||
|
<Switch checked={!!local[key]} onChange={on => set(key, on)} label={L(key)} description={L(key, 'hint') || undefined} data-testid={`set-${key}`} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
const toggle = key => row(key, <Toggle testId={`set-${key}`} on={!!local[key]} onToggle={() => set(key, !local[key])} />)
|
|
||||||
const select = (key, options) => row(key, (
|
const select = (key, options) => row(key, (
|
||||||
<select data-testid={`set-${key}`} value={String(local[key])} onChange={e => set(key, options.find(o => String(o) === e.target.value))} style={{
|
<Select data-testid={`set-${key}`} value={String(local[key])} onChange={e => set(key, options.find(o => String(o) === e.target.value))}
|
||||||
height: 44, padding: '0 10px', borderRadius: 10, background: '#232d38', border: '1px solid #3d4f5e', color: KDS.panelInk,
|
options={options.map(o => ({ value: String(o), label: choice(key, o) }))} className="min-w-[200px]" />
|
||||||
fontSize: 13, fontWeight: 600, fontFamily: 'inherit', maxWidth: 240,
|
|
||||||
}}>
|
|
||||||
{options.map(o => <option key={o} value={String(o)}>{choice(key, o)}</option>)}
|
|
||||||
</select>
|
|
||||||
))
|
|
||||||
const minutes = (key, min, max) => row(key, (
|
|
||||||
<Stepper testId={`set-${key}`} value={local[key]} steps={Array.from({ length: 120 }, (_, i) => i + 1)} min={min} max={max}
|
|
||||||
display={v => t('kds.age.minutes', { m: v })} onChange={v => set(key, v)} />
|
|
||||||
))
|
))
|
||||||
|
const stepper = (key, props) => row(key, <Stepper data-testid={`set-${key}`} label={L(key)} value={local[key]} onChange={v => set(key, v)} {...props} />)
|
||||||
|
const minutes = v => t('kds.age.minutes', { m: v })
|
||||||
|
|
||||||
const zones = context?.prep_zones ?? []
|
const zones = context?.prep_zones ?? []
|
||||||
const zoneButton = (id, name) => {
|
const zoneButton = (id, name) => {
|
||||||
const on = (local.prep_zone_id ?? null) === id
|
const on = (local.prep_zone_id ?? null) === id
|
||||||
return (
|
return (
|
||||||
<button key={id ?? 'all'} type="button" data-zone={id ?? 'all'} onClick={() => set('prep_zone_id', id)} style={{
|
<button key={id ?? 'all'} type="button" data-zone={id ?? 'all'} aria-pressed={on} onClick={() => set('prep_zone_id', id)}
|
||||||
padding: '12px 8px', borderRadius: 10, minHeight: 64, fontFamily: 'inherit', cursor: 'pointer', fontSize: 12, fontWeight: on ? 700 : 500,
|
className={`min-h-16 px-2 py-3 rounded-control border-2 flex flex-col items-center justify-center gap-1 text-label transition-colors duration-fast
|
||||||
background: on ? 'rgba(47,127,240,.15)' : KDS.field, border: `2px solid ${on ? KDS.accent : KDS.panelLine}`, color: on ? KDS.panelInk : '#9ca8b6',
|
${on ? 'border-accent bg-accent-soft text-accent-ink font-semibold' : 'border-line bg-surface-2 text-ink-2 hover:bg-surface-3'}`}>
|
||||||
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4,
|
{on && <Check size={14} />}
|
||||||
}}>
|
<span>{name}</span>
|
||||||
{on && <Check style={{ width: 14, height: 14, color: KDS.accent }} />}
|
|
||||||
<span style={{ lineHeight: 1.3 }}>{name}</span>
|
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -117,8 +83,8 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
|
|||||||
const content = {
|
const content = {
|
||||||
zone: (
|
zone: (
|
||||||
<div>
|
<div>
|
||||||
<div style={{ fontSize: 12.5, color: KDS.panelInk2, padding: '12px 0 14px', lineHeight: 1.5 }}>{L('prep_zone_id', 'hint')}</div>
|
<p className="text-label text-ink-2 py-3">{L('prep_zone_id', 'hint')}</p>
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>
|
<div className="grid grid-cols-3 gap-2">
|
||||||
{zoneButton(null, t('modules:kds.config.prep_zone_id.none'))}
|
{zoneButton(null, t('modules:kds.config.prep_zone_id.none'))}
|
||||||
{zones.map(z => zoneButton(z.id, z.name))}
|
{zones.map(z => zoneButton(z.id, z.name))}
|
||||||
</div>
|
</div>
|
||||||
@@ -126,7 +92,7 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
|
|||||||
),
|
),
|
||||||
behaviour: (
|
behaviour: (
|
||||||
<div>
|
<div>
|
||||||
{row('refresh_seconds', <Stepper testId="set-refresh_seconds" value={local.refresh_seconds} steps={REFRESH} display={v => t('kds.settings.seconds', { s: v })} onChange={v => set('refresh_seconds', v)} />)}
|
{stepper('refresh_seconds', { steps: REFRESH, format: s => t('kds.settings.seconds', { s }) })}
|
||||||
{toggle('triple_state')}
|
{toggle('triple_state')}
|
||||||
{toggle('categories_as_filters')}
|
{toggle('categories_as_filters')}
|
||||||
{toggle('group_by_course')}
|
{toggle('group_by_course')}
|
||||||
@@ -137,8 +103,8 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
|
|||||||
),
|
),
|
||||||
board: (
|
board: (
|
||||||
<div>
|
<div>
|
||||||
{row('card_width', <Stepper testId="set-card_width" value={local.card_width} steps={CARD_WIDTHS} display={v => `${v}px`} onChange={v => set('card_width', v)} />)}
|
{stepper('card_width', { steps: CARD_WIDTHS, format: v => `${v}px` })}
|
||||||
{row('font_scale', <Stepper testId="set-font_scale" value={local.font_scale} steps={FONT_SCALES} display={v => `${v}%`} onChange={v => set('font_scale', v)} />)}
|
{stepper('font_scale', { steps: FONT_SCALES, format: v => `${v}%` })}
|
||||||
{select('font_weight', WEIGHTS)}
|
{select('font_weight', WEIGHTS)}
|
||||||
{toggle('flash_late')}
|
{toggle('flash_late')}
|
||||||
{toggle('combine_modifiers')}
|
{toggle('combine_modifiers')}
|
||||||
@@ -146,9 +112,9 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
|
|||||||
),
|
),
|
||||||
age: (
|
age: (
|
||||||
<div>
|
<div>
|
||||||
{minutes('age_warning_minutes', 1, local.age_late_minutes - 1)}
|
{stepper('age_warning_minutes', { min: 1, max: local.age_late_minutes - 1, format: minutes })}
|
||||||
{minutes('age_late_minutes', local.age_warning_minutes + 1, local.age_flash_minutes - 1)}
|
{stepper('age_late_minutes', { min: local.age_warning_minutes + 1, max: local.age_flash_minutes - 1, format: minutes })}
|
||||||
{minutes('age_flash_minutes', local.age_late_minutes + 1, 120)}
|
{stepper('age_flash_minutes', { min: local.age_late_minutes + 1, max: 120, format: minutes })}
|
||||||
{['colour_fresh', 'colour_warning', 'colour_late', 'colour_done'].map(k => row(k, <Swatches testId={`set-${k}`} value={local[k]} onChange={v => set(k, v)} />))}
|
{['colour_fresh', 'colour_warning', 'colour_late', 'colour_done'].map(k => row(k, <Swatches testId={`set-${k}`} value={local[k]} onChange={v => set(k, v)} />))}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@@ -177,38 +143,25 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<KdsModal width={680} onClose={onClose} testId="kds-settings-panel">
|
<Dialog open onClose={onClose} size="lg" title={t('kds.settings.title')}
|
||||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 22px 0' }}>
|
footer={<>
|
||||||
<h2 style={{ margin: 0, fontSize: 20, fontWeight: 700 }}>{t('kds.settings.title')}</h2>
|
<Button variant="secondary" size="lg" onClick={onClose}>{t('kds.cancel')}</Button>
|
||||||
<CloseButton onClick={onClose} label={t('kds.close')} />
|
<Button size="lg" icon={<Check size={18} />} loading={busy} disabled={!canEdit} onClick={save} data-testid="settings-save">{t('kds.settings.save')}</Button>
|
||||||
</div>
|
</>}>
|
||||||
<div style={{ display: 'flex', gap: 4, padding: '14px 22px 0', borderBottom: `1px solid ${KDS.panelLine2}`, overflowX: 'auto' }}>
|
<div data-testid="kds-settings-panel">
|
||||||
{TABS.map(k => (
|
<div role="tablist" className="flex gap-1 border-b border-line overflow-x-auto">
|
||||||
<button key={k} type="button" data-testid={`settings-tab-${k}`} onClick={() => setTab(k)} style={{
|
{TABS.map(k => (
|
||||||
height: 40, padding: '0 18px', borderRadius: '9px 9px 0 0', background: tab === k ? KDS.panelLine2 : 'none',
|
<button key={k} type="button" role="tab" aria-selected={tab === k} data-testid={`settings-tab-${k}`} onClick={() => setTab(k)}
|
||||||
color: tab === k ? '#f1f4f8' : KDS.panelInk2, border: 'none', cursor: 'pointer', fontFamily: 'inherit', fontSize: 14,
|
className={`h-10 px-4 whitespace-nowrap text-body rounded-t-[var(--x-radius-sm)] border-b-2 -mb-px transition-colors duration-fast focus-visible:outline-none focus-visible:shadow-focus
|
||||||
fontWeight: tab === k ? 700 : 500, borderBottom: tab === k ? `2px solid ${KDS.accent}` : '2px solid transparent', whiteSpace: 'nowrap',
|
${tab === k ? 'border-accent bg-accent-soft text-accent-ink font-semibold' : 'border-transparent text-ink-2 hover:text-ink'}`}>
|
||||||
}}>
|
{t(`kds.settings.tabs.${k}`)}
|
||||||
{t(`kds.settings.tabs.${k}`)}
|
</button>
|
||||||
</button>
|
))}
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div style={{ height: 470, maxHeight: '60vh', overflowY: 'auto', padding: '6px 22px 12px' }}>{content[tab]}</div>
|
|
||||||
{!canEdit && (
|
|
||||||
<div data-testid="settings-no-permission" style={{ padding: '10px 22px', fontSize: 13, color: '#fcd34d', borderTop: `1px solid ${KDS.panelLine2}` }}>
|
|
||||||
{t('kds.settings.noPermission')}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className="h-[420px] max-h-[55vh] overflow-y-auto">{content[tab]}</div>
|
||||||
{error && <div role="alert" style={{ padding: '10px 22px', fontSize: 13, color: '#fca5a5' }}>{error}</div>}
|
{!canEdit && <p data-testid="settings-no-permission" className="mt-3 text-label text-warning-ink">{t('kds.settings.noPermission')}</p>}
|
||||||
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 10, padding: '14px 22px', borderTop: `1px solid ${KDS.panelLine2}` }}>
|
{error && <p role="alert" className="mt-3 text-label text-danger-ink">{error}</p>}
|
||||||
<button type="button" onClick={onClose} style={{ ...secondaryButton, flex: '0 0 auto', padding: '0 22px' }}>{t('kds.cancel')}</button>
|
|
||||||
<button type="button" data-testid="settings-save" onClick={save} disabled={!canEdit || busy} style={{
|
|
||||||
height: 48, padding: '0 24px', borderRadius: 11, background: canEdit ? KDS.accent : KDS.panelLine, color: canEdit ? '#fff' : '#5e6772',
|
|
||||||
fontSize: 15, fontWeight: 700, border: 'none', cursor: canEdit && !busy ? 'pointer' : 'default', display: 'flex', alignItems: 'center', gap: 8, fontFamily: 'inherit',
|
|
||||||
}}>
|
|
||||||
<Check style={{ width: 18, height: 18 }} /> {t('kds.settings.save')}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</KdsModal>
|
</Dialog>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useMemo } from 'react'
|
|||||||
import { ArrowRight, Info, Minus, Plus, X } from 'lucide-react'
|
import { ArrowRight, Info, Minus, Plus, X } from 'lucide-react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { buildItemGroups } from '../logic/board'
|
import { buildItemGroups } from '../logic/board'
|
||||||
|
import { KDS } from '../theme'
|
||||||
|
|
||||||
const MOD_ICON_SZ = 13
|
const MOD_ICON_SZ = 13
|
||||||
|
|
||||||
@@ -27,19 +28,19 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
|
|||||||
const nameFontSize = Math.round(15 * fs)
|
const nameFontSize = Math.round(15 * fs)
|
||||||
const nameLineH = Math.round(nameFontSize * 1.4)
|
const nameLineH = Math.round(nameFontSize * 1.4)
|
||||||
const isModal = mode === 'floating' || mode === 'topbar_button'
|
const isModal = mode === 'floating' || mode === 'topbar_button'
|
||||||
const panel = { background: '#161b21', border: '1px solid #2b3540', borderRadius: isModal ? 14 : 0, color: '#e7ecf2',
|
const panel = { background: KDS.rail, border: `1px solid ${KDS.line}`, borderRadius: isModal ? 14 : 0, color: KDS.ink,
|
||||||
display: 'flex', flexDirection: 'column', overflow: 'hidden' }
|
display: 'flex', flexDirection: 'column', overflow: 'hidden' }
|
||||||
|
|
||||||
const header = (
|
const header = (
|
||||||
<div style={{ padding: `${Math.round(10 * fs)}px ${Math.round(14 * fs)}px`, borderBottom: '1px solid #252e38', flexShrink: 0,
|
<div style={{ padding: `${Math.round(10 * fs)}px ${Math.round(14 * fs)}px`, borderBottom: `1px solid ${KDS.line}`, flexShrink: 0,
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<div>
|
<div>
|
||||||
<div style={{ fontSize: Math.round(13 * fs), fontWeight: 700, letterSpacing: '.02em' }}>{t('kds.summary.title')}</div>
|
<div style={{ fontSize: Math.round(13 * fs), fontWeight: 700, letterSpacing: '.02em' }}>{t('kds.summary.title')}</div>
|
||||||
<div style={{ fontSize: Math.round(11 * fs), color: '#6b7a8d', marginTop: 1 }}>{t('kds.summary.subtitle', { count: groups.length })}</div>
|
<div style={{ fontSize: Math.round(11 * fs), color: KDS.ink3, marginTop: 1 }}>{t('kds.summary.subtitle', { count: groups.length })}</div>
|
||||||
</div>
|
</div>
|
||||||
{mode === 'topbar_button' && (
|
{mode === 'topbar_button' && (
|
||||||
<button type="button" aria-label={t('kds.close')} onClick={onClose} style={{ width: Math.round(28 * fs), height: Math.round(28 * fs), borderRadius: 8,
|
<button type="button" aria-label={t('kds.close')} onClick={onClose} style={{ width: Math.round(28 * fs), height: Math.round(28 * fs), borderRadius: 8,
|
||||||
display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'none', border: 'none', cursor: 'pointer', color: '#6b7a8d' }}>
|
display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'none', border: 'none', cursor: 'pointer', color: KDS.ink3 }}>
|
||||||
<X style={{ width: Math.round(13 * fs), height: Math.round(13 * fs) }} />
|
<X style={{ width: Math.round(13 * fs), height: Math.round(13 * fs) }} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
@@ -49,12 +50,12 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
|
|||||||
const list = (
|
const list = (
|
||||||
<div style={{ overflowY: 'auto', flex: '1 1 auto', padding: `${Math.round(6 * fs)}px 0` }}>
|
<div style={{ overflowY: 'auto', flex: '1 1 auto', padding: `${Math.round(6 * fs)}px 0` }}>
|
||||||
{groups.length === 0 ? (
|
{groups.length === 0 ? (
|
||||||
<div style={{ textAlign: 'center', padding: `${Math.round(24 * fs)}px 0`, color: '#4a5568', fontSize: nameFontSize }}>{t('kds.summary.empty')}</div>
|
<div style={{ textAlign: 'center', padding: `${Math.round(24 * fs)}px 0`, color: KDS.ink4, fontSize: nameFontSize }}>{t('kds.summary.empty')}</div>
|
||||||
) : groups.map(g => (
|
) : groups.map(g => (
|
||||||
<div key={g.key} data-testid="summary-row" style={{ padding: `${Math.round(4 * fs)}px ${Math.round(14 * fs)}px` }}>
|
<div key={g.key} data-testid="summary-row" style={{ padding: `${Math.round(4 * fs)}px ${Math.round(14 * fs)}px` }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 7 }}>
|
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 7 }}>
|
||||||
<span style={{ flexShrink: 0, minWidth: nameLineH, height: nameLineH, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
<span style={{ flexShrink: 0, minWidth: nameLineH, height: nameLineH, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
||||||
background: '#2b3540', color: '#f1f5f9', borderRadius: Math.round(5 * fs), fontFamily: 'ui-monospace, monospace', fontWeight: 700,
|
background: KDS.line, color: KDS.ink, borderRadius: Math.round(5 * fs), fontFamily: KDS.fontMono, fontWeight: 700,
|
||||||
fontSize: Math.round(12 * fs), lineHeight: 1 }}>
|
fontSize: Math.round(12 * fs), lineHeight: 1 }}>
|
||||||
{g.count}
|
{g.count}
|
||||||
</span>
|
</span>
|
||||||
@@ -62,10 +63,10 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
|
|||||||
</div>
|
</div>
|
||||||
{(g.removed.length || g.extras.length || g.prefs.length || g.notes) ? (
|
{(g.removed.length || g.extras.length || g.prefs.length || g.notes) ? (
|
||||||
<div style={{ marginTop: 3, paddingLeft: nameLineH + 7, display: 'flex', flexDirection: 'column', gap: 3 }}>
|
<div style={{ marginTop: 3, paddingLeft: nameLineH + 7, display: 'flex', flexDirection: 'column', gap: 3 }}>
|
||||||
{g.removed.length > 0 && <Mod Icon={Minus} color="#fca5a5" text={g.removed.join(' · ')} fs={fs} />}
|
{g.removed.length > 0 && <Mod Icon={Minus} color={KDS.lateSoft} text={g.removed.join(' · ')} fs={fs} />}
|
||||||
{g.extras.length > 0 && <Mod Icon={Plus} color="#86efac" text={g.extras.join(' · ')} fs={fs} />}
|
{g.extras.length > 0 && <Mod Icon={Plus} color={KDS.freshSoft} text={g.extras.join(' · ')} fs={fs} />}
|
||||||
{g.prefs.length > 0 && <Mod Icon={ArrowRight} color="#fcd34d" text={g.prefs.join(' · ')} fs={fs} />}
|
{g.prefs.length > 0 && <Mod Icon={ArrowRight} color={KDS.warningSoft} text={g.prefs.join(' · ')} fs={fs} />}
|
||||||
{g.notes && <Mod Icon={Info} color="#93c5fd" text={g.notes} fs={fs} />}
|
{g.notes && <Mod Icon={Info} color={KDS.progressSoft} text={g.notes} fs={fs} />}
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
@@ -75,8 +76,8 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
|
|||||||
|
|
||||||
if (mode === 'right_sidebar' || mode === 'left_sidebar') {
|
if (mode === 'right_sidebar' || mode === 'left_sidebar') {
|
||||||
return (
|
return (
|
||||||
<div data-testid="summary-panel" style={{ ...panel, height: '100%', borderLeft: mode === 'right_sidebar' ? '1px solid #2b3540' : 'none',
|
<div data-testid="summary-panel" style={{ ...panel, height: '100%', borderLeft: mode === 'right_sidebar' ? `1px solid ${KDS.line}` : 'none',
|
||||||
borderRight: mode === 'left_sidebar' ? '1px solid #2b3540' : 'none' }}>
|
borderRight: mode === 'left_sidebar' ? `1px solid ${KDS.line}` : 'none' }}>
|
||||||
{header}{list}
|
{header}{list}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -85,16 +86,16 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
|
|||||||
return (
|
return (
|
||||||
<div data-testid="summary-panel" style={{ position: 'absolute', right: 18, zIndex: 50, top: '50%', transform: 'translateY(-50%)',
|
<div data-testid="summary-panel" style={{ position: 'absolute', right: 18, zIndex: 50, top: '50%', transform: 'translateY(-50%)',
|
||||||
width: `${Math.round(20 * fs)}vw`, minWidth: 200, maxHeight: '90%', pointerEvents: 'auto', ...panel,
|
width: `${Math.round(20 * fs)}vw`, minWidth: 200, maxHeight: '90%', pointerEvents: 'auto', ...panel,
|
||||||
boxShadow: '0 8px 40px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.06)' }}>
|
boxShadow: 'var(--x-shadow-overlay)' }}>
|
||||||
{header}{list}
|
{header}{list}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (mode === 'topbar_button' && open) {
|
if (mode === 'topbar_button' && open) {
|
||||||
return (
|
return (
|
||||||
<div onClick={onClose} style={{ position: 'absolute', inset: 0, zIndex: 150, background: 'rgba(10,13,17,.6)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
<div onClick={onClose} style={{ position: 'absolute', inset: 0, zIndex: 150, background: 'rgb(var(--x-board-deep-rgb) / 0.6)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<div data-testid="summary-panel" onClick={e => e.stopPropagation()} style={{ ...panel, width: `${Math.round(20 * fs)}vw`, minWidth: 220, maxHeight: '80vh',
|
<div data-testid="summary-panel" onClick={e => e.stopPropagation()} style={{ ...panel, width: `${Math.round(20 * fs)}vw`, minWidth: 220, maxHeight: '80vh',
|
||||||
boxShadow: '0 24px 80px rgba(0,0,0,.7)' }}>
|
boxShadow: 'var(--x-shadow-overlay)' }}>
|
||||||
{header}{list}
|
{header}{list}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,50 +1,62 @@
|
|||||||
// The kitchen board's palette (ported from the manager's KdsPage.jsx, plan step 3.2b). The
|
// The kitchen board's colours and shapes: the board design language of @xenia/ui
|
||||||
// board is always dark, whatever the terminal's theme: these values are what cooks are used
|
// (--x-board-* in packages/ui/src/tokens.css, plan step 3.2b-2). Change them there, not here.
|
||||||
// to, so they stay as they were (the age colours themselves are device settings).
|
// Inline styles use these names; `alpha(name, a)` gives a see-through version.
|
||||||
|
// The age colours a screen shows come from its own settings (device config).
|
||||||
|
|
||||||
|
const v = name => `var(--x-board-${name})`
|
||||||
|
|
||||||
export const KDS = {
|
export const KDS = {
|
||||||
bg: '#1d232b',
|
bg: v('bg'),
|
||||||
rail: '#161b21',
|
rail: v('rail'),
|
||||||
railLine: '#2b333d',
|
topbar: v('topbar'),
|
||||||
topbar: '#20272f',
|
line: v('line'),
|
||||||
tab: '#2b333d',
|
deep: v('deep'),
|
||||||
tabInk: '#aab4c0',
|
ink: v('ink'),
|
||||||
tabActiveBg: '#f3f6f9',
|
ink2: v('ink-2'),
|
||||||
tabActiveInk: '#1d232b',
|
ink3: v('ink-3'),
|
||||||
cardFoot: '#eef1f5',
|
ink4: v('ink-4'),
|
||||||
cardFootInk: '#41474f',
|
tabActive: v('tab-active'),
|
||||||
ink: '#1f242b',
|
onStatus: v('on-status'),
|
||||||
qtyBg: '#f0f2f5',
|
card: v('card'),
|
||||||
qtyInk: '#2b3038',
|
cardInk: v('card-ink'),
|
||||||
line: '#e8ebef',
|
cardInk2: v('card-ink-2'),
|
||||||
doneInk: '#aeb4bc',
|
cardMuted: v('card-muted'),
|
||||||
green: '#34b56a',
|
cardSoft: v('card-soft'),
|
||||||
greenD: '#1e8048',
|
cardLine: v('card-line'),
|
||||||
amber: '#f0a52a',
|
cardProgress: v('card-progress'),
|
||||||
amberD: '#b87310',
|
cardDone: v('card-done'),
|
||||||
red: '#e8513f',
|
note: v('note'),
|
||||||
redD: '#a02d1e',
|
noteInk: v('note-ink'),
|
||||||
futureHead: '#4a5568',
|
fresh: v('fresh'),
|
||||||
futureSubBg: '#374151',
|
freshDeep: v('fresh-deep'),
|
||||||
doneSub: '#2a3140',
|
warning: v('warning'),
|
||||||
accent: '#2f7ff0',
|
warningDeep: v('warning-deep'),
|
||||||
|
late: v('late'),
|
||||||
|
lateDeep: v('late-deep'),
|
||||||
|
done: v('done'),
|
||||||
|
doneDeep: v('done-deep'),
|
||||||
|
future: v('future'),
|
||||||
|
futureDeep: v('future-deep'),
|
||||||
|
futureGlow: v('future-glow'),
|
||||||
|
progress: v('progress'),
|
||||||
|
freshSoft: v('fresh-soft'),
|
||||||
|
warningSoft: v('warning-soft'),
|
||||||
|
lateSoft: v('late-soft'),
|
||||||
|
progressSoft: v('progress-soft'),
|
||||||
|
radiusCard: 'var(--x-board-radius-card)',
|
||||||
|
radiusSmall: 'var(--x-radius-sm)',
|
||||||
|
shadowCard: 'var(--x-board-shadow-card)',
|
||||||
|
shadowFocus: 'var(--x-board-shadow-focus)',
|
||||||
|
fontNumber: 'var(--x-board-font-number)',
|
||||||
|
fontMono: 'var(--x-font-mono)',
|
||||||
railW: 104,
|
railW: 104,
|
||||||
topbarH: 54,
|
topbarH: 54,
|
||||||
glowFuture: '#6dd08a',
|
|
||||||
glowPending: '#f0a52a',
|
|
||||||
glowPreparing: '#2f7ff0',
|
|
||||||
glowDone: '#e7ecf2',
|
|
||||||
// dialogs
|
|
||||||
panel: '#1a2029',
|
|
||||||
panelLine: '#2c3744',
|
|
||||||
panelLine2: '#252e38',
|
|
||||||
panelInk: '#e7ecf2',
|
|
||||||
panelInk2: '#6b7a8d',
|
|
||||||
field: '#1e2832',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const secondaryButton = { flex: 1, height: 48, borderRadius: 11, background: KDS.panelLine2, color: '#aab8c8', fontSize: 15, fontWeight: 600, border: 'none', cursor: 'pointer', fontFamily: 'inherit' }
|
/** A board colour, see-through: alpha('ink', 0.6) → rgb(var(--x-board-ink-rgb) / 0.6). */
|
||||||
|
export const alpha = (name, a) => `rgb(var(--x-board-${name}-rgb) / ${a})`
|
||||||
|
|
||||||
export const KEYFRAMES = `
|
export const KEYFRAMES = `
|
||||||
@keyframes kds-redflash { 0%,100% { background: #e8513f; } 50% { background: #0a0c0f; } }
|
@keyframes kds-redflash { 0%,100% { background: var(--x-board-late); } 50% { background: var(--x-board-deep); } }
|
||||||
.kds-flash { animation: kds-redflash 1.4s ease-in-out infinite; }
|
.kds-flash { animation: kds-redflash 1.4s ease-in-out infinite; }
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -12,3 +12,12 @@ export const APPS = {
|
|||||||
export function appLoader(appKey) {
|
export function appLoader(appKey) {
|
||||||
return Object.hasOwn(APPS, appKey) ? APPS[appKey] : null
|
return Object.hasOwn(APPS, appKey) ? APPS[appKey] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The colour theme a screen uses while it runs an app (plan step 3.2b-2). The kitchen board is
|
||||||
|
// always dark (its board tokens), so the shared dialogs and toasts on it are dark too. Apps not
|
||||||
|
// listed follow the screen's saved theme.
|
||||||
|
export const APP_THEMES = { kds: 'dark' }
|
||||||
|
|
||||||
|
export function appTheme(appKey) {
|
||||||
|
return Object.hasOwn(APP_THEMES, appKey) ? APP_THEMES[appKey] : null
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import { useEffect, useRef } from 'react'
|
|||||||
import { LogOut } from 'lucide-react'
|
import { LogOut } from 'lucide-react'
|
||||||
import { useAccess } from '@xenia/access'
|
import { useAccess } from '@xenia/access'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { Button } from '@xenia/ui'
|
import { Button, applyTheme, getStoredTheme } from '@xenia/ui'
|
||||||
import AppHost from '../apps/AppHost'
|
import AppHost from '../apps/AppHost'
|
||||||
|
import { appTheme } from '../apps/registry'
|
||||||
import { useDevice } from '../device/context'
|
import { useDevice } from '../device/context'
|
||||||
import { idleExpired } from '../device/flow'
|
import { idleExpired } from '../device/flow'
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ export default function AppScreen() {
|
|||||||
const { me, signOut } = useDevice()
|
const { me, signOut } = useDevice()
|
||||||
const withUser = me.login_mode !== 'none'
|
const withUser = me.login_mode !== 'none'
|
||||||
useIdleSignOut(withUser ? me.config?.auto_sign_out_minutes : 0, signOut)
|
useIdleSignOut(withUser ? me.config?.auto_sign_out_minutes : 0, signOut)
|
||||||
|
useAppTheme(me.app_key)
|
||||||
return (
|
return (
|
||||||
<div className="h-screen flex flex-col" data-testid="app-screen" data-app={me.app_key}>
|
<div className="h-screen flex flex-col" data-testid="app-screen" data-app={me.app_key}>
|
||||||
{withUser && <TerminalBar onSignOut={signOut} />}
|
{withUser && <TerminalBar onSignOut={signOut} />}
|
||||||
@@ -55,3 +57,14 @@ function useIdleSignOut(minutes, signOut) {
|
|||||||
}
|
}
|
||||||
}, [minutes])
|
}, [minutes])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The app's own theme (registry APP_THEMES, e.g. the KDS is dark) while it runs; on <html>,
|
||||||
|
* because dialogs and toasts render in <body>. The saved theme comes back when it stops. */
|
||||||
|
function useAppTheme(appKey) {
|
||||||
|
useEffect(() => {
|
||||||
|
const theme = appTheme(appKey)
|
||||||
|
if (!theme) return undefined
|
||||||
|
applyTheme(theme)
|
||||||
|
return () => { applyTheme(getStoredTheme()) }
|
||||||
|
}, [appKey])
|
||||||
|
}
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ try {
|
|||||||
r.check('3.2b: a long press shows the quick actions', await shown(page, 'quick-decline', 3000))
|
r.check('3.2b: a long press shows the quick actions', await shown(page, 'quick-decline', 3000))
|
||||||
await page.getByTestId('quick-decline').click()
|
await page.getByTestId('quick-decline').click()
|
||||||
await page.locator('[data-reason="out_of_stock"]').click()
|
await page.locator('[data-reason="out_of_stock"]').click()
|
||||||
|
await sleep(400) // let colour transitions finish
|
||||||
|
await page.screenshot({ path: path.join(OUT, 'terminal-kds-decline.png') })
|
||||||
await page.getByTestId('decline-confirm').click()
|
await page.getByTestId('decline-confirm').click()
|
||||||
await sleep(800)
|
await sleep(800)
|
||||||
const declined = (await api('GET', `/api/kds/orders?zone_id=${grill.id}`, { token: boss })).orders.find(o => o.id === opened.id)
|
const declined = (await api('GET', `/api/kds/orders?zone_id=${grill.id}`, { token: boss })).orders.find(o => o.id === opened.id)
|
||||||
@@ -209,8 +211,11 @@ try {
|
|||||||
await page.getByTestId('kds-settings').click()
|
await page.getByTestId('kds-settings').click()
|
||||||
r.check('3.2b: the screen\'s settings: a chef sees them, with "only a manager"', await shown(page, 'kds-settings-panel', 3000)
|
r.check('3.2b: the screen\'s settings: a chef sees them, with "only a manager"', await shown(page, 'kds-settings-panel', 3000)
|
||||||
&& await page.getByTestId('settings-no-permission').count() === 1 && await page.getByTestId('settings-save').isDisabled())
|
&& await page.getByTestId('settings-no-permission').count() === 1 && await page.getByTestId('settings-save').isDisabled())
|
||||||
await page.keyboard.press('Escape').catch(() => {})
|
await page.getByTestId('settings-tab-age').click()
|
||||||
await page.getByTestId('kds-settings-panel').getByRole('button', { name: 'Close' }).click()
|
await sleep(400) // let colour transitions finish
|
||||||
|
await page.screenshot({ path: path.join(OUT, 'terminal-kds-settings.png') })
|
||||||
|
await page.keyboard.press('Escape')
|
||||||
|
r.check('3.2b-2: the settings are a shared dialog (Escape closes it)', await page.getByTestId('kds-settings-panel').waitFor({ state: 'detached', timeout: 3000 }).then(() => true).catch(() => false))
|
||||||
|
|
||||||
// a change made elsewhere (another screen, the waiter) reaches this screen live
|
// a change made elsewhere (another screen, the waiter) reaches this screen live
|
||||||
await api('PUT', `/api/kds/orders/${second.id}/kds_status`, { token: boss, body: { status: 'pending' } })
|
await api('PUT', `/api/kds/orders/${second.id}/kds_status`, { token: boss, body: { status: 'pending' } })
|
||||||
|
|||||||
@@ -88,6 +88,13 @@ try {
|
|||||||
await p.getByText('Print kitchen tickets').click()
|
await p.getByText('Print kitchen tickets').click()
|
||||||
r.check('switch: the label toggles it', await p.getByRole('switch', { name: 'Print kitchen tickets' }).getAttribute('aria-checked') === 'false')
|
r.check('switch: the label toggles it', await p.getByRole('switch', { name: 'Print kitchen tickets' }).getAttribute('aria-checked') === 'false')
|
||||||
|
|
||||||
|
// Stepper (3.2b-2): steps, ends disabled
|
||||||
|
const stepper = p.getByRole('group', { name: 'Check every' })
|
||||||
|
await stepper.getByRole('button', { name: 'More' }).click()
|
||||||
|
r.check('stepper: + moves to the next step', (await stepper.textContent()).includes('45s'))
|
||||||
|
await stepper.getByRole('button', { name: 'More' }).click()
|
||||||
|
r.check('stepper: + is disabled at the last step', (await stepper.textContent()).includes('60s') && await stepper.getByRole('button', { name: 'More' }).isDisabled())
|
||||||
|
|
||||||
// InfoTip
|
// InfoTip
|
||||||
const tip = p.getByRole('button', { name: 'More info' }).first()
|
const tip = p.getByRole('button', { name: 'More info' }).first()
|
||||||
await tip.click()
|
await tip.click()
|
||||||
|
|||||||
Reference in New Issue
Block a user