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:
@@ -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',
|
||||
notifications: 'Notifications',
|
||||
backspace: 'Delete',
|
||||
decrease: 'Less',
|
||||
increase: 'More',
|
||||
submit: 'OK',
|
||||
pinProgress: (n, total) => `${n} of ${total} digits entered`,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user