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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user