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:
2026-11-14 20:02:35 +02:00
co-authored by Claude Opus 5.5
parent 5f6d4ab428
commit 77e0adbe9c
26 changed files with 485 additions and 383 deletions
+4 -2
View File
@@ -10,7 +10,7 @@ import { lazy, Suspense } from 'react'
import { BrowserRouter, Route, Routes } from 'react-router-dom'
import { AccessProvider } from '@xenia/access'
import { createI18n } from '@xenia/i18n'
import { Spinner } from '@xenia/ui'
import { Spinner, ToastProvider } from '@xenia/ui'
import client from './api/client'
import DeviceProvider from './device/DeviceProvider'
import { useDevice } from './device/context'
@@ -29,7 +29,9 @@ function Root() {
const { sessionKey } = useDevice()
return (
<AccessProvider client={client} token={sessionKey} i18n={i18n} loading={loading} autoRetryMs={AUTO_RETRY_MS}>
<Terminal />
<ToastProvider placement="bottom-center">
<Terminal />
</ToastProvider>
</AccessProvider>
)
}
+18 -20
View File
@@ -7,17 +7,20 @@
// (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
// 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.
// 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).
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { CookingPot } from 'lucide-react'
import { useLanguage, useTranslation } from '@xenia/i18n'
import { useToast } from '@xenia/ui'
import client from '../../api/client'
import { useDevice } from '../../device/context'
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 OrderCard from './components/OrderCard'
import { SideRail, TopBar } from './components/Rails'
@@ -29,7 +32,7 @@ import {
} from './logic/board'
import { layoutBoard } from './logic/layout'
import { boardSettings, senderName, zoomStep } from './logic/settings'
import { KDS, KEYFRAMES } from './theme'
import { KDS, KEYFRAMES, alpha } from './theme'
import useKdsData from './useKdsData'
const HISTORY = 10
@@ -52,7 +55,6 @@ export default function KdsApp() {
const [showSummary, setShowSummary] = useState(false)
const [soundOn, setSoundOn] = useState(true)
const [started, setStarted] = useState(() => soundUnlocked())
const [toasts, setToasts] = useState([])
const [boardH, setBoardH] = useState(0)
const [measured, setMeasured] = useState({})
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 known = useRef(null) // order ids seen so far (new-order chime)
const toast = useCallback(msg => {
const id = Math.random().toString(36).slice(2)
setToasts(ts => [...ts, { id, msg }])
setTimeout(() => setToasts(ts => ts.filter(x => x.id !== id)), TOAST_MS)
}, [])
const ui = useToast()
const toast = useCallback((msg, tone = 'neutral') => ui.show({ title: msg, tone, duration: TOAST_MS }), [ui])
// a fresh answer replaces the board; new orders chime (not the first load)
const soundRef = useRef(false)
@@ -134,7 +133,7 @@ export default function KdsApp() {
const callWaiter = useCallback(orderId => {
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])
const setOrderStatus = useCallback((orderId, status) => {
@@ -180,14 +179,14 @@ export default function KdsApp() {
toast(t('kds.toast.orderDeclined'))
}
reload()
} catch { toast(t('kds.toast.declineFailed')) }
} catch { toast(t('kds.toast.declineFailed'), 'danger') }
}, [reload, t, toast])
const print = useCallback(async orderId => {
try {
await client.post(`/api/kds/orders/${orderId}/retry-print`)
toast(t('kds.toast.printSent'))
} catch { toast(t('kds.toast.printFailed')) }
} catch { toast(t('kds.toast.printFailed'), 'danger') }
}, [t, toast])
const replay = useCallback((entry, which) => {
@@ -267,7 +266,7 @@ export default function KdsApp() {
return (
<div data-testid="app-kds" style={{
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>
<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%',
paddingRight: summary === 'floating' ? `calc(${sideWidth} + 32px)` : 0 }}>
{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')}
</div>
)}
{loaded !== null && visible.length === 0 && (
<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 }} />
<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>
)}
{visible.map(order => {
@@ -346,7 +345,7 @@ export default function KdsApp() {
{dialog === 'call' && (
<CallWaiterDialog zoneName={sender} onClose={() => setDialog(null)}
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 && (
<DeclineDialog itemId={dialog.decline.itemId} itemName={dialog.decline.itemName}
@@ -355,15 +354,14 @@ export default function KdsApp() {
{!started && settings.sound && (
<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',
}}>
<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>
)}
<Toasts toasts={toasts} />
</div>
)
}
+11 -11
View File
@@ -5,14 +5,14 @@
import { Ban, BellRing, Check, Flame, Printer, Undo2, X } from 'lucide-react'
import { useTranslation } from '@xenia/i18n'
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 }) {
const pad = Math.round(6 * fs)
return (
<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,
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}
</div>
@@ -25,7 +25,7 @@ function BarButton({ bg, label, title, onClick, fs, children, testId }) {
onClick={e => { e.stopPropagation(); onClick() }}
style={{
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',
}}>
{children}
@@ -43,14 +43,14 @@ export function ActionBar({ order, onStatus, onPrint, onCallWaiter, fs = 1, hasW
<>
<Bar fs={fs} z={4}>
<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} />}
</BarButton>
<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} />}
</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} />
</BarButton>
</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={{
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),
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,
}}>
<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) }
return (
<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() }}>
{isPreparing ? <Undo2 style={icon} /> : <Flame style={icon} />}
</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() }}>
{isDone ? <Undo2 style={icon} /> : <Check style={icon} />}
</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} />
</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} />
</BarButton>
</Bar>
+44 -112
View File
@@ -1,41 +1,31 @@
// The kitchen board's dialogs (plan step 3.2b, from KdsPage.jsx), dark like the board:
// decline an order or an item (with a reason), call waiters on shift, and the small toasts.
// The kitchen board's dialogs (plan steps 3.2b, 3.2b-2): decline an order or an item (with a
// 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 { Ban, BellRing, Check, X } from 'lucide-react'
import { Ban, BellRing, Check } from 'lucide-react'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, Input, Spinner } from '@xenia/ui'
import client from '../../../api/client'
import { KDS, secondaryButton } from '../theme'
export function KdsModal({ width, onClose, children, testId, z = 200 }) {
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>
)
}
const REASONS = ['out_of_stock', 'too_many_orders', 'other']
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 (
<button type="button" aria-label={label} onClick={onClick} style={{ width: 40, height: 40, borderRadius: 10, display: 'flex', alignItems: 'center',
justifyContent: 'center', color: KDS.panelInk2, background: 'none', border: 'none', cursor: 'pointer', flexShrink: 0 }}>
<X style={{ width: 20, height: 20 }} />
<button type="button" onClick={onClick} {...rest}
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
${on ? selected : 'border-line bg-surface-2 text-ink-2 hover:bg-surface-3'}`}>
{children}
</button>
)
}
const REASONS = ['out_of_stock', 'too_many_orders', 'other']
export function DeclineDialog({ itemId, itemName, onConfirm, onClose }) {
const { t } = useTranslation('terminal')
const [reason, setReason] = useState(null)
const [note, setNote] = useState('')
const isItem = itemId != null
const title = isItem ? t('kds.decline.item') : t('kds.decline.order')
const title = itemId != null ? t('kds.decline.item') : t('kds.decline.order')
const confirm = () => {
if (!reason) return
// 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()
}
return (
<KdsModal width={380} onClose={onClose} testId="decline-dialog" z={300}>
<div style={{ padding: '18px 20px 14px', borderBottom: `1px solid ${KDS.panelLine2}` }}>
<div style={{ fontSize: 17, fontWeight: 700 }}>{title}</div>
{isItem && itemName && <div style={{ fontSize: 13, color: KDS.panelInk2, marginTop: 4 }}>{itemName}</div>}
</div>
<div style={{ padding: '14px 20px', display: 'flex', flexDirection: 'column', gap: 8 }}>
{REASONS.map(r => {
const on = reason === r
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>
)
})}
<Dialog open onClose={onClose} size="sm" title={title} description={itemId != null ? itemName : undefined}
footer={<>
<Button variant="secondary" size="lg" onClick={onClose}>{t('kds.cancel')}</Button>
<Button variant="danger" size="lg" icon={<Ban size={16} />} disabled={!reason} onClick={confirm} data-testid="decline-confirm">{title}</Button>
</>}>
<div className="grid gap-2" data-testid="decline-dialog">
{REASONS.map(r => (
<Choice key={r} tone="danger" on={reason === r} onClick={() => setReason(r)} data-reason={r}>{t(`kds.decline.reasons.${r}`)}</Choice>
))}
{reason === 'other' && (
<input value={note} onChange={e => setNote(e.target.value)} placeholder={t('kds.decline.notePlaceholder')} autoFocus style={{
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',
}} />
<Input value={note} onChange={e => setNote(e.target.value)} placeholder={t('kds.decline.notePlaceholder')} autoFocus />
)}
</div>
<div style={{ display: 'flex', gap: 10, padding: '12px 20px 18px' }}>
<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>
</Dialog>
)
}
@@ -108,73 +75,38 @@ export function CallWaiterDialog({ zoneName, onSend, onClose }) {
setSending(true)
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 (
<KdsModal width={420} onClose={onClose} testId="call-dialog">
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 20px 14px' }}>
<div>
<div style={{ fontSize: 18, fontWeight: 700 }}>{t('kds.call.title')}</div>
{zoneName && <div style={{ fontSize: 12.5, color: KDS.panelInk2, marginTop: 2 }}>{t('kds.call.needsHelp', { zone: zoneName })}</div>}
</div>
<CloseButton onClick={onClose} label={t('kds.close')} />
</div>
<div style={{ padding: '0 14px', maxHeight: 320, overflowY: 'auto' }}>
{waiters === null && <div style={{ textAlign: 'center', padding: '32px 0', color: '#5e6772', fontSize: 14 }}>{t('kds.loading')}</div>}
{waiters?.length === 0 && <div style={{ textAlign: 'center', padding: '32px 0', color: '#5e6772', fontSize: 14 }}>{t('kds.call.none')}</div>}
<Dialog open onClose={onClose} title={t('kds.call.title')} description={zoneName ? t('kds.call.needsHelp', { zone: zoneName }) : undefined}
footer={<>
<Button variant="secondary" size="lg" onClick={onClose}>{t('kds.cancel')}</Button>
<Button size="lg" icon={<BellRing size={18} />} loading={sending} disabled={!selected.size} onClick={send} data-testid="call-send">
{selected.size ? t('kds.call.sendCount', { count: selected.size }) : t('kds.call.send')}
</Button>
</>}>
<div className="grid gap-2" data-testid="call-dialog">
{waiters === null && <div className="flex justify-center py-8"><Spinner /></div>}
{waiters?.length === 0 && <p className="text-center py-8 text-body text-ink-3">{t('kds.call.none')}</p>}
{waiters?.length > 0 && (
<>
<button type="button" 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 style={{ width: 16, height: 16 }} /> : null}
{t('kds.call.all')}
</button>
<Choice on={all} onClick={() => setSelected(all ? new Set() : new Set(waiters.map(w => w.id)))}>
{all && <Check size={16} />}<span className="flex-1 text-center font-semibold">{t('kds.call.all')}</span>
</Choice>
{waiters.map(w => {
const on = selected.has(w.id)
const name = w.nickname || w.username
return (
<button key={w.id} type="button" data-waiter={w.id} onClick={() => toggle(w.id)}
style={{ ...chip(on), height: 60, gap: 14, padding: '0 16px', color: KDS.panelInk, fontSize: 15, fontWeight: 600 }}>
<span style={{ width: 36, height: 36, borderRadius: '50%', flexShrink: 0, background: on ? KDS.accent : KDS.panelLine,
display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 16, fontWeight: 700 }}>
{on ? <Check style={{ width: 18, height: 18 }} /> : name?.[0]?.toUpperCase()}
<Choice key={w.id} on={on} onClick={() => toggle(w.id)} data-waiter={w.id}>
<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'}`}>
{on ? <Check size={18} /> : name?.[0]?.toUpperCase()}
</span>
<span style={{ flex: 1, textAlign: 'left' }}>{name}</span>
</button>
<span className="flex-1 text-ink">{name}</span>
</Choice>
)
})}
</>
)}
</div>
<div style={{ display: 'flex', gap: 10, padding: '14px 20px', borderTop: `1px solid ${KDS.panelLine2}` }}>
<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>
</Dialog>
)
}
+13 -13
View File
@@ -9,7 +9,7 @@ const MOD_ICON_SZ = 13
const HOLD_MS = 500
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 lineH = Math.round(fontSize * 1.4)
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,
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',
background: done ? '#f1f2f4' : KDS.qtyBg, color: done ? KDS.doneInk : KDS.qtyInk,
borderRadius: Math.round(5 * fs), fontFamily: 'ui-monospace, monospace', fontWeight: 700, fontSize: Math.round(12 * fs), lineHeight: 1,
background: KDS.cardSoft, color: done ? KDS.cardMuted : KDS.cardInk,
borderRadius: Math.round(5 * fs), fontFamily: KDS.fontMono, fontWeight: 700, fontSize: Math.round(12 * fs), lineHeight: 1,
}}>
{formatQty(item.quantity, item.unit_type)}
</span>
<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,
}}>
{item.product_name}
@@ -71,8 +71,8 @@ export default function ItemBlock({ item, focused, onBump, onDecline, fontScale
{focused && (
<span style={{
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,
border: `1px solid ${done ? KDS.greenD : preparing ? KDS.accent : '#ccc'}`,
background: done ? KDS.fresh : preparing ? KDS.progress : KDS.cardSoft,
border: `1px solid ${done ? KDS.freshDeep : preparing ? KDS.progress : KDS.cardMuted}`,
}} />
)}
</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 }}>
{combineModifiers ? (
<>
{removed.length > 0 && <ModRow Icon={Minus} color={KDS.redD} text={removed.join(' · ')} done={done} fs={fs} />}
{extras.length > 0 && <ModRow Icon={Plus} color={KDS.greenD} text={extras.join(' · ')} done={done} fs={fs} />}
{prefs.length > 0 && <ModRow Icon={ArrowRight} color={KDS.amberD} text={prefs.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.freshDeep} text={extras.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} />)}
{extras.map((x, i) => <ModRow key={`e${i}`} Icon={Plus} color={KDS.greenD} 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} />)}
{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.freshDeep} text={x} 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>
) : null}
</div>
+30 -29
View File
@@ -8,7 +8,7 @@ import { Bike, Info, ShoppingBag, User, Utensils } from 'lucide-react'
import { useTranslation } from '@xenia/i18n'
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 { KDS } from '../theme'
import { KDS, alpha } from '../theme'
import { ActionBar, QuickActionBar } from './ActionBars'
import ItemBlock from './ItemBlock'
@@ -22,7 +22,7 @@ function ChannelBadge({ orderType, tableName, fs }) {
const Icon = CHANNEL_ICONS[type]
const iconSz = Math.round(17 * fs)
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 }} />
{type === 'here' && tableName ? tableName : t(`kds.channel.${type}`)}
</span>
@@ -30,17 +30,18 @@ function ChannelBadge({ orderType, tableName, fs }) {
}
function headColours(age, colours) {
if (age === 'done') return [colours.done, KDS.doneSub]
if (age === 'future') return [KDS.futureHead, KDS.futureSubBg]
if (age === 'green') return [colours.fresh, KDS.greenD]
if (age === 'amber') return [colours.warning, KDS.amberD]
return [colours.late, KDS.redD]
if (age === 'done') return [colours.done, KDS.doneDeep]
if (age === 'future') return [KDS.future, KDS.futureDeep]
if (age === 'green') return [colours.fresh, KDS.freshDeep]
if (age === 'amber') return [colours.warning, KDS.warningDeep]
return [colours.late, KDS.lateDeep]
}
/** The board token a card glows in when several status filters are on. */
function glowFor(order, age) {
if (age === 'done') return KDS.glowDone
if (age === 'future') return KDS.glowFuture
return order.kds_status === 'preparing' ? KDS.glowPreparing : KDS.glowPending
if (age === 'done') return 'ink'
if (age === 'future') return 'future-glow'
return order.kds_status === 'preparing' ? 'progress' : 'warning'
}
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 (
<Fragment key={bi}>
<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' }}>
<div style={{ flex: 1, height: 1, background: '#e0e5eb' }} />
letterSpacing: '.1em', color: KDS.cardMuted, padding: bi === 0 ? '0 0 2px' : '4px 0 2px' }}>
<div style={{ flex: 1, height: 1, background: KDS.cardLine }} />
<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)) })}
</span>
<div style={{ flex: 1, height: 1, background: '#e0e5eb' }} />
<div style={{ flex: 1, height: 1, background: KDS.cardLine }} />
</div>
{items.map(item)}
</Fragment>
@@ -113,7 +114,7 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
return column(ci, courseGroups(colItems, courses).map((g, gi) => (
<div key={gi}>
<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')}
</div>
{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}
style={{
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
? `0 10px 24px rgba(0,0,0,.4), 0 0 0 4px rgba(47,127,240,.25)${glow ? `, 0 0 0 2px ${glow}40` : ''}`
: `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` : ''}`,
outline: focused ? `2px solid ${KDS.accent}` : '2px solid transparent', outlineOffset: 2,
? `${KDS.shadowFocus}${glow ? `, 0 0 0 2px ${alpha(glow, 0.25)}` : ''}`
: `${KDS.shadowCard}${glow ? `, 0 0 12px 2px ${alpha(glow, 0.33)}, 0 0 0 2px ${alpha(glow, 0.27)}` : ''}`,
outline: focused ? `2px solid ${KDS.progress}` : '2px solid transparent', outlineOffset: 2,
display: 'flex', flexDirection: 'column',
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,
@@ -143,13 +144,13 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
}}
>
<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,
}}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 }}>
<span data-testid="card-age" style={{
background: 'rgba(255,255,255,0.92)', color: '#0a0c0f', borderRadius: 7, padding: `0 ${Math.round(9 * fs)}px`,
height: Math.round(30 * fs), fontSize: Math.round(17 * fs), fontWeight: 800, fontVariantNumeric: 'tabular-nums',
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, fontFamily: KDS.fontNumber, fontVariantNumeric: 'tabular-nums',
letterSpacing: '-0.02em', flexShrink: 0, display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
}}>
{ageText}
@@ -162,7 +163,7 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
</div>
<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,
}}>
<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 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,
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>
{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={{
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>
</div>
</div>
@@ -194,8 +195,8 @@ export default function OrderCard({ order, age, ageText, layout, focused, dimmed
{waiter && (
<div style={{
background: KDS.cardFoot, color: KDS.cardFootInk, 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}`,
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.cardLine}`,
}}>
<User style={{ width: 13, height: 13, opacity: 0.7 }} />
{waiter}
+27 -27
View File
@@ -3,22 +3,22 @@
// 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 { useFormat, useTranslation } from '@xenia/i18n'
import { KDS } from '../theme'
import { KDS, alpha } from '../theme'
const STATUSES = [
{ key: 'future', Icon: Clock, colour: KDS.green },
{ key: 'pending', Icon: Timer, colour: KDS.amber },
{ key: 'preparing', Icon: Flame, colour: KDS.accent },
{ key: 'done', Icon: CheckCheck, colour: '#cdd6e0' },
{ key: 'future', Icon: Clock, colour: KDS.fresh },
{ key: 'pending', Icon: Timer, colour: KDS.warning },
{ key: 'preparing', Icon: Flame, colour: KDS.progress },
{ 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 (
<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',
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',
border: active ? '1px solid rgba(255,255,255,0.08)' : '1px solid transparent',
color: active ? colour : KDS.ink3, background: active ? alpha('ink', 0.06) : 'none',
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',
}}>
{children}
@@ -35,7 +35,7 @@ export function SideRail({ filters, counts, onToggleFilter, soundOn, onToggleSou
const badgeH = Math.round(22 * fs)
const group = { display: 'flex', flexDirection: 'column', gap: 2, padding: `2px ${Math.round(8 * fs)}px` }
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' }}>
<div style={group}>
{STATUSES.map(({ key, Icon, colour }) => {
@@ -46,23 +46,23 @@ export function SideRail({ filters, counts, onToggleFilter, soundOn, onToggleSou
{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',
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}
</span>
</RailButton>
)
})}
<div style={{ height: 1, background: KDS.railLine, 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-redo" active={false} colour="#fff" onClick={onRedo} disabled={!canRedo} fs={fs}><Redo2 style={sm} />{label(t('kds.rail.redo'))}</RailButton>
<div style={{ height: 1, background: KDS.line, margin: `${Math.round(6 * fs)}px` }} />
<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} onClick={onRedo} disabled={!canRedo} fs={fs}><Redo2 style={sm} />{label(t('kds.rail.redo'))}</RailButton>
</div>
<div style={{ flex: '1 1 auto' }} />
<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-sound" active={false} colour="#fff" onClick={onToggleSound} fs={fs}>
<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} onClick={onToggleSound} fs={fs}>
{soundOn ? <Volume2 style={sm} /> : <VolumeX style={sm} />}{label(soundOn ? t('kds.rail.sound') : t('kds.rail.muted'))}
</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>
</nav>
)
@@ -76,12 +76,12 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
const fs = fontScale
const tabH = Math.round(36 * 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',
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) }
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' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6, flexShrink: 0, overflowX: 'auto' }}>
{TABS.map(key => {
@@ -89,13 +89,13 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
return (
<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`,
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',
}}>
{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',
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}
</span>
</button>
@@ -106,7 +106,7 @@ export function TopBar({ tab, counts, onTab, now, fontScale = 1, zoomPercent, on
{showSummaryButton && (
<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`,
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',
}}>
<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 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: 700, color: '#f1f4f8' }}>{formatTime(now)}</span>
<span style={{ ...clockFont, fontWeight: 600, color: KDS.ink2 }}>{formatDate(now, 'dateLong')}</span>
<span style={{ ...clockFont, fontWeight: 700, color: KDS.ink }}>{formatTime(now)}</span>
</div>
<div style={{ width: 1, height: Math.round(24 * fs), background: KDS.railLine, 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={{ width: 1, height: Math.round(24 * fs), background: KDS.line, flexShrink: 0 }} />
<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>
<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}%
</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>
@@ -1,66 +1,36 @@
// This screen's settings, changed on the screen itself (plan step 3.2b): the device config of
// 3.2a, saved with PATCH /api/devices/me/config (only someone holding core.devices.manage;
// others see the settings and a note). The texts are the Devices page's
// (modules:kds.config.*), so both places say the same thing. The saved settings come back
// through device.updated → GET /api/devices/me, like an edit on the Devices page.
// This screen's settings, changed on the screen itself (plan steps 3.2b, 3.2b-2): the device
// config of 3.2a, saved with PATCH /api/devices/me/config (only someone holding
// 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. Shared @xenia/ui components
// (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 { Check } from 'lucide-react'
import { useCan } from '@xenia/access'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, Select, Stepper, Switch } from '@xenia/ui'
import client from '../../../api/client'
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 WEIGHTS = [300, 400, 500, 600, 700, 800]
const REFRESH = [10, 15, 20, 30, 45, 60, 90, 120]
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 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 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 }) {
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 => (
<button key={p} type="button" aria-label={p} data-colour={p} onClick={() => onChange(p)} style={{
width: 30, height: 30, borderRadius: 8, background: p, cursor: 'pointer', border: value === p ? '2px solid #fff' : '2px solid transparent',
}} />
<button key={p} type="button" aria-label={p} aria-pressed={value === p} data-colour={p} onClick={() => onChange(p)}
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>
)
}
@@ -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 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 style={{ flex: '1 1 auto', minWidth: 0 }}>
<div style={{ fontSize: 15, fontWeight: 500 }}>{L(key)}</div>
{L(key, 'hint') && <div style={{ fontSize: 12.5, color: KDS.panelInk2, marginTop: 3, lineHeight: 1.4 }}>{L(key, 'hint')}</div>}
<div key={key} data-setting={key} className="flex items-center justify-between gap-4 py-3 border-b border-line">
<div className="flex-1 min-w-0">
<div className="text-body-lg font-medium text-ink">{L(key)}</div>
{L(key, 'hint') && <div className="text-label text-ink-2 mt-0.5">{L(key, 'hint')}</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>
)
const toggle = key => row(key, <Toggle testId={`set-${key}`} on={!!local[key]} onToggle={() => set(key, !local[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={{
height: 44, padding: '0 10px', borderRadius: 10, background: '#232d38', border: '1px solid #3d4f5e', color: KDS.panelInk,
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)} />
<Select data-testid={`set-${key}`} value={String(local[key])} onChange={e => set(key, options.find(o => String(o) === e.target.value))}
options={options.map(o => ({ value: String(o), label: choice(key, o) }))} className="min-w-[200px]" />
))
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 zoneButton = (id, name) => {
const on = (local.prep_zone_id ?? null) === id
return (
<button key={id ?? 'all'} type="button" data-zone={id ?? 'all'} onClick={() => set('prep_zone_id', id)} style={{
padding: '12px 8px', borderRadius: 10, minHeight: 64, fontFamily: 'inherit', cursor: 'pointer', fontSize: 12, fontWeight: on ? 700 : 500,
background: on ? 'rgba(47,127,240,.15)' : KDS.field, border: `2px solid ${on ? KDS.accent : KDS.panelLine}`, color: on ? KDS.panelInk : '#9ca8b6',
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4,
}}>
{on && <Check style={{ width: 14, height: 14, color: KDS.accent }} />}
<span style={{ lineHeight: 1.3 }}>{name}</span>
<button key={id ?? 'all'} type="button" data-zone={id ?? 'all'} aria-pressed={on} onClick={() => set('prep_zone_id', id)}
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
${on ? 'border-accent bg-accent-soft text-accent-ink font-semibold' : 'border-line bg-surface-2 text-ink-2 hover:bg-surface-3'}`}>
{on && <Check size={14} />}
<span>{name}</span>
</button>
)
}
@@ -117,8 +83,8 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
const content = {
zone: (
<div>
<div style={{ fontSize: 12.5, color: KDS.panelInk2, padding: '12px 0 14px', lineHeight: 1.5 }}>{L('prep_zone_id', 'hint')}</div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>
<p className="text-label text-ink-2 py-3">{L('prep_zone_id', 'hint')}</p>
<div className="grid grid-cols-3 gap-2">
{zoneButton(null, t('modules:kds.config.prep_zone_id.none'))}
{zones.map(z => zoneButton(z.id, z.name))}
</div>
@@ -126,7 +92,7 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
),
behaviour: (
<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('categories_as_filters')}
{toggle('group_by_course')}
@@ -137,8 +103,8 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
),
board: (
<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)} />)}
{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('card_width', { steps: CARD_WIDTHS, format: v => `${v}px` })}
{stepper('font_scale', { steps: FONT_SCALES, format: v => `${v}%` })}
{select('font_weight', WEIGHTS)}
{toggle('flash_late')}
{toggle('combine_modifiers')}
@@ -146,9 +112,9 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
),
age: (
<div>
{minutes('age_warning_minutes', 1, local.age_late_minutes - 1)}
{minutes('age_late_minutes', local.age_warning_minutes + 1, local.age_flash_minutes - 1)}
{minutes('age_flash_minutes', local.age_late_minutes + 1, 120)}
{stepper('age_warning_minutes', { min: 1, max: local.age_late_minutes - 1, format: minutes })}
{stepper('age_late_minutes', { min: local.age_warning_minutes + 1, max: local.age_flash_minutes - 1, format: minutes })}
{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)} />))}
</div>
),
@@ -177,38 +143,25 @@ export default function SettingsPanel({ config, context, onClose, onSaved }) {
}
return (
<KdsModal width={680} onClose={onClose} testId="kds-settings-panel">
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '18px 22px 0' }}>
<h2 style={{ margin: 0, fontSize: 20, fontWeight: 700 }}>{t('kds.settings.title')}</h2>
<CloseButton onClick={onClose} label={t('kds.close')} />
</div>
<div style={{ display: 'flex', gap: 4, padding: '14px 22px 0', borderBottom: `1px solid ${KDS.panelLine2}`, overflowX: 'auto' }}>
{TABS.map(k => (
<button key={k} type="button" data-testid={`settings-tab-${k}`} onClick={() => setTab(k)} style={{
height: 40, padding: '0 18px', borderRadius: '9px 9px 0 0', background: tab === k ? KDS.panelLine2 : 'none',
color: tab === k ? '#f1f4f8' : KDS.panelInk2, border: 'none', cursor: 'pointer', fontFamily: 'inherit', fontSize: 14,
fontWeight: tab === k ? 700 : 500, borderBottom: tab === k ? `2px solid ${KDS.accent}` : '2px solid transparent', whiteSpace: 'nowrap',
}}>
{t(`kds.settings.tabs.${k}`)}
</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')}
<Dialog open onClose={onClose} size="lg" title={t('kds.settings.title')}
footer={<>
<Button variant="secondary" size="lg" onClick={onClose}>{t('kds.cancel')}</Button>
<Button size="lg" icon={<Check size={18} />} loading={busy} disabled={!canEdit} onClick={save} data-testid="settings-save">{t('kds.settings.save')}</Button>
</>}>
<div data-testid="kds-settings-panel">
<div role="tablist" className="flex gap-1 border-b border-line overflow-x-auto">
{TABS.map(k => (
<button key={k} type="button" role="tab" aria-selected={tab === k} data-testid={`settings-tab-${k}`} onClick={() => setTab(k)}
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
${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}`)}
</button>
))}
</div>
)}
{error && <div role="alert" style={{ padding: '10px 22px', fontSize: 13, color: '#fca5a5' }}>{error}</div>}
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 10, padding: '14px 22px', borderTop: `1px solid ${KDS.panelLine2}` }}>
<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 className="h-[420px] max-h-[55vh] overflow-y-auto">{content[tab]}</div>
{!canEdit && <p data-testid="settings-no-permission" className="mt-3 text-label text-warning-ink">{t('kds.settings.noPermission')}</p>}
{error && <p role="alert" className="mt-3 text-label text-danger-ink">{error}</p>}
</div>
</KdsModal>
</Dialog>
)
}
@@ -4,6 +4,7 @@ import { useMemo } from 'react'
import { ArrowRight, Info, Minus, Plus, X } from 'lucide-react'
import { useTranslation } from '@xenia/i18n'
import { buildItemGroups } from '../logic/board'
import { KDS } from '../theme'
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 nameLineH = Math.round(nameFontSize * 1.4)
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' }
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' }}>
<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>
{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,
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) }} />
</button>
)}
@@ -49,12 +50,12 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
const list = (
<div style={{ overflowY: 'auto', flex: '1 1 auto', padding: `${Math.round(6 * fs)}px 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 => (
<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 }}>
<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 }}>
{g.count}
</span>
@@ -62,10 +63,10 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
</div>
{(g.removed.length || g.extras.length || g.prefs.length || g.notes) ? (
<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.extras.length > 0 && <Mod Icon={Plus} color="#86efac" text={g.extras.join(' · ')} fs={fs} />}
{g.prefs.length > 0 && <Mod Icon={ArrowRight} color="#fcd34d" text={g.prefs.join(' · ')} fs={fs} />}
{g.notes && <Mod Icon={Info} color="#93c5fd" text={g.notes} 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={KDS.freshSoft} text={g.extras.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={KDS.progressSoft} text={g.notes} fs={fs} />}
</div>
) : null}
</div>
@@ -75,8 +76,8 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
if (mode === 'right_sidebar' || mode === 'left_sidebar') {
return (
<div data-testid="summary-panel" style={{ ...panel, height: '100%', borderLeft: mode === 'right_sidebar' ? '1px solid #2b3540' : 'none',
borderRight: mode === 'left_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 ${KDS.line}` : 'none' }}>
{header}{list}
</div>
)
@@ -85,16 +86,16 @@ export default function SummaryPanel({ orders, mode, open, onClose, fontScale =
return (
<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,
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}
</div>
)
}
if (mode === 'topbar_button' && open) {
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',
boxShadow: '0 24px 80px rgba(0,0,0,.7)' }}>
boxShadow: 'var(--x-shadow-overlay)' }}>
{header}{list}
</div>
</div>
+53 -41
View File
@@ -1,50 +1,62 @@
// The kitchen board's palette (ported from the manager's KdsPage.jsx, plan step 3.2b). The
// board is always dark, whatever the terminal's theme: these values are what cooks are used
// to, so they stay as they were (the age colours themselves are device settings).
// The kitchen board's colours and shapes: the board design language of @xenia/ui
// (--x-board-* in packages/ui/src/tokens.css, plan step 3.2b-2). Change them there, not here.
// 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 = {
bg: '#1d232b',
rail: '#161b21',
railLine: '#2b333d',
topbar: '#20272f',
tab: '#2b333d',
tabInk: '#aab4c0',
tabActiveBg: '#f3f6f9',
tabActiveInk: '#1d232b',
cardFoot: '#eef1f5',
cardFootInk: '#41474f',
ink: '#1f242b',
qtyBg: '#f0f2f5',
qtyInk: '#2b3038',
line: '#e8ebef',
doneInk: '#aeb4bc',
green: '#34b56a',
greenD: '#1e8048',
amber: '#f0a52a',
amberD: '#b87310',
red: '#e8513f',
redD: '#a02d1e',
futureHead: '#4a5568',
futureSubBg: '#374151',
doneSub: '#2a3140',
accent: '#2f7ff0',
bg: v('bg'),
rail: v('rail'),
topbar: v('topbar'),
line: v('line'),
deep: v('deep'),
ink: v('ink'),
ink2: v('ink-2'),
ink3: v('ink-3'),
ink4: v('ink-4'),
tabActive: v('tab-active'),
onStatus: v('on-status'),
card: v('card'),
cardInk: v('card-ink'),
cardInk2: v('card-ink-2'),
cardMuted: v('card-muted'),
cardSoft: v('card-soft'),
cardLine: v('card-line'),
cardProgress: v('card-progress'),
cardDone: v('card-done'),
note: v('note'),
noteInk: v('note-ink'),
fresh: v('fresh'),
freshDeep: v('fresh-deep'),
warning: v('warning'),
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,
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 = `
@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; }
`
+9
View File
@@ -12,3 +12,12 @@ export const APPS = {
export function appLoader(appKey) {
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
}
+14 -1
View File
@@ -5,8 +5,9 @@ import { useEffect, useRef } from 'react'
import { LogOut } from 'lucide-react'
import { useAccess } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import { Button } from '@xenia/ui'
import { Button, applyTheme, getStoredTheme } from '@xenia/ui'
import AppHost from '../apps/AppHost'
import { appTheme } from '../apps/registry'
import { useDevice } from '../device/context'
import { idleExpired } from '../device/flow'
@@ -16,6 +17,7 @@ export default function AppScreen() {
const { me, signOut } = useDevice()
const withUser = me.login_mode !== 'none'
useIdleSignOut(withUser ? me.config?.auto_sign_out_minutes : 0, signOut)
useAppTheme(me.app_key)
return (
<div className="h-screen flex flex-col" data-testid="app-screen" data-app={me.app_key}>
{withUser && <TerminalBar onSignOut={signOut} />}
@@ -55,3 +57,14 @@ function useIdleSignOut(minutes, signOut) {
}
}, [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])
}