feat(waiter): the look on the shared tokens; the venue's colour (platform-v2 step 4.6)

- The waiter's --bg/--text/--accent… are made of @xenia/ui tokens: light / dark (user
  menu) and the venue's accent reach every screen; the 751 colour literals in
  waiter_pwa/src became tokens (by hue family and lightness), hex-alpha suffixes became
  fade() (color-mix), fixing 'var(--accent)18' tints that never showed.
- @xenia/ui: new `special` (violet: offers, discounts, deals; contrast-tested) and
  `on-colour` tokens.
- Setting venue.theme (teal | amber | blue | violet | rose, default amber), bootstrap
  venue.theme, manager Settings → Venue → Colour; the waiter sets data-venue-theme and
  the theme before the first render.
- Guard tests/no-colours.test.mjs; tests/e2e/waiter_look.mjs (every page light + dark,
  side-by-side compare page); waiter e2e +3; backend test_venue_theme.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 09:08:39 +02:00
co-authored by Claude Opus 5.5
parent d8c3a6c57c
commit beb53c65bb
41 changed files with 798 additions and 585 deletions
+42 -41
View File
@@ -16,6 +16,7 @@ import { assetUrl } from '../config/server'
import { money } from '../i18n'
import { LineError, estimate, wireLine } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { fade } from '../logic/colour'
// A cart item whose option is not on the menu any more (4.4: lines go by id)
const lineErrorText = (err, t) => t('add.optionGone', { product: err.product, what: err.what })
@@ -40,7 +41,7 @@ function GlobalCourseModal({ courses, selected, onSelect, onClose }) {
style={{
display: 'flex', alignItems: 'center', gap: 12,
padding: '12px 16px',
background: c.id === selected ? `${c.color}22` : 'var(--bg3)',
background: c.id === selected ? `${fade(c.color, 0.13)}` : 'var(--bg3)',
border: `2px solid ${c.id === selected ? c.color : 'var(--border)'}`,
borderRadius: 12, cursor: 'pointer', textAlign: 'left',
}}
@@ -558,7 +559,7 @@ export default function AddItemsPage() {
<span style={{
position: 'absolute', top: -2, right: -2,
minWidth: 18, height: 18, borderRadius: 9,
background: '#38bdf8', color: '#000',
background: 'var(--x-info)', color: 'rgb(var(--x-scrim-rgb) / 1)',
fontSize: 10, fontWeight: 800,
display: 'flex', alignItems: 'center', justifyContent: 'center',
padding: '0 4px',
@@ -583,7 +584,7 @@ export default function AddItemsPage() {
<span style={{
position: 'absolute', top: -2, right: -2,
minWidth: 18, height: 18, borderRadius: 9,
background: c.color, color: '#fff',
background: c.color, color: 'var(--x-on-colour)',
fontSize: 10, fontWeight: 800,
display: 'flex', alignItems: 'center', justifyContent: 'center',
padding: '0 4px',
@@ -679,7 +680,7 @@ export default function AddItemsPage() {
return (
<div key={item._key} style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span style={{ fontSize: 12, color: 'var(--text)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1 }}>{p?.name ?? `#${item.product_id}`}</span>
<span style={{ fontSize: 12, fontWeight: 700, color: '#f59e0b', fontVariantNumeric: 'tabular-nums', flexShrink: 0 }}>{fmtDraftQty(item.quantity, p?.unit_type)}</span>
<span style={{ fontSize: 12, fontWeight: 700, color: 'var(--x-warning)', fontVariantNumeric: 'tabular-nums', flexShrink: 0 }}>{fmtDraftQty(item.quantity, p?.unit_type)}</span>
</div>
)
})}
@@ -711,7 +712,7 @@ export default function AddItemsPage() {
onClick={() => setCartOpen(false)}
style={{
position: 'fixed', inset: 0,
background: 'rgba(0,0,0,0.55)',
background: 'rgb(var(--x-scrim-rgb) / 0.55)',
opacity: cartOpen ? 1 : 0,
pointerEvents: cartOpen ? 'auto' : 'none',
transition: 'opacity 240ms ease',
@@ -728,7 +729,7 @@ export default function AddItemsPage() {
transition: 'transform 280ms cubic-bezier(0.32, 0.72, 0, 1)',
zIndex: 51,
display: 'flex', flexDirection: 'column',
boxShadow: cartOpen ? '-8px 0 32px rgba(0,0,0,0.4)' : 'none',
boxShadow: cartOpen ? '-8px 0 32px rgb(var(--x-scrim-rgb) / 0.4)' : 'none',
}}>
{/* Drawer header */}
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '14px 16px', borderBottom: '1px solid var(--border)', flexShrink: 0 }}>
@@ -831,7 +832,7 @@ export default function AddItemsPage() {
rows={3}
style={{
width: '100%', resize: 'none', padding: '10px 12px',
background: 'rgba(245,158,11,0.07)', border: '1.5px solid rgba(245,158,11,0.35)',
background: 'rgb(var(--x-warning-rgb) / 0.07)', border: '1.5px solid rgb(var(--x-warning-rgb) / 0.35)',
borderRadius: 10, fontSize: 14, color: 'var(--text)', lineHeight: 1.5,
outline: 'none', boxSizing: 'border-box', fontFamily: 'inherit',
}}
@@ -846,11 +847,11 @@ export default function AddItemsPage() {
) : orderNote ? (
<div
onClick={() => setOrderNoteEditing(true)}
style={{ cursor: 'pointer', padding: '9px 12px', background: 'rgba(245,158,11,0.09)', border: '1.5px solid rgba(245,158,11,0.3)', borderRadius: 10, fontSize: 13, color: 'var(--text)', lineHeight: 1.5, whiteSpace: 'pre-wrap', position: 'relative' }}
style={{ cursor: 'pointer', padding: '9px 12px', background: 'rgb(var(--x-warning-rgb) / 0.09)', border: '1.5px solid rgb(var(--x-warning-rgb) / 0.3)', borderRadius: 10, fontSize: 13, color: 'var(--text)', lineHeight: 1.5, whiteSpace: 'pre-wrap', position: 'relative' }}
>
<span style={{ fontSize: 10, fontWeight: 700, color: '#f59e0b', textTransform: 'uppercase', letterSpacing: 0.6, display: 'block', marginBottom: 3 }}>{t('add.note.title')}</span>
<span style={{ fontSize: 10, fontWeight: 700, color: 'var(--x-warning)', textTransform: 'uppercase', letterSpacing: 0.6, display: 'block', marginBottom: 3 }}>{t('add.note.title')}</span>
{orderNote}
<span style={{ position: 'absolute', top: 8, right: 10, fontSize: 11, color: '#f59e0b', fontWeight: 700 }}>✎</span>
<span style={{ position: 'absolute', top: 8, right: 10, fontSize: 11, color: 'var(--x-warning)', fontWeight: 700 }}>✎</span>
</div>
) : (
<button
@@ -994,25 +995,25 @@ export default function AddItemsPage() {
<div style={{
position: 'fixed', inset: 0, zIndex: 9999,
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
background: 'rgba(0,0,0,0.72)',
background: 'rgb(var(--x-scrim-rgb) / 0.72)',
animation: 'fadeInOverlay 180ms ease',
}}>
<div style={{
background: printAck._offline ? '#451a03' : printAck._pending ? '#1c1917' : '#14532d',
border: `2px solid ${printAck._offline ? '#f59e0b' : printAck._pending ? '#f59e0b' : '#22c55e'}`,
background: printAck._offline ? 'var(--x-warning-soft)' : printAck._pending ? 'var(--x-canvas)' : 'var(--x-success-soft)',
border: `2px solid ${printAck._offline ? 'var(--x-warning)' : printAck._pending ? 'var(--x-warning)' : 'var(--x-success)'}`,
borderRadius: 20, padding: '36px 48px',
display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16,
animation: 'popIn 220ms cubic-bezier(0.34,1.56,0.64,1)',
}}>
<svg width="56" height="56" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="11" stroke={printAck._offline || printAck._pending ? '#f59e0b' : '#22c55e'} strokeWidth="2"/>
<circle cx="12" cy="12" r="11" stroke={printAck._offline || printAck._pending ? 'var(--x-warning)' : 'var(--x-success)'} strokeWidth="2"/>
{printAck._offline || printAck._pending ? (
<path d="M12 8v5M12 16h.01" stroke="#f59e0b" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M12 8v5M12 16h.01" stroke="var(--x-warning)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
) : (
<path d="M7 12.5l3.5 3.5 6.5-7" stroke="#22c55e" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M7 12.5l3.5 3.5 6.5-7" stroke="var(--x-success)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/>
)}
</svg>
<span style={{ color: printAck._offline || printAck._pending ? '#fcd34d' : '#86efac', fontWeight: 700, fontSize: 18, letterSpacing: 0.3 }}>
<span style={{ color: printAck._offline || printAck._pending ? 'var(--x-warning)' : 'var(--x-success-ink)', fontWeight: 700, fontSize: 18, letterSpacing: 0.3 }}>
{printAck._offline ? t('add.ack.offline') : printAck._pending ? t('add.ack.printing') : t('add.ack.printed')}
</span>
</div>
@@ -1068,14 +1069,14 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
<div style={{
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
width: 48, height: 48, borderRadius: '50%',
background: 'rgba(167,139,250,0.15)', marginBottom: 10,
background: 'rgb(var(--x-special-rgb) / 0.15)', marginBottom: 10,
}}>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
<path d="M20 12v10H4V12M22 7H2v5h20V7zM12 22V7M12 7H7.5a2.5 2.5 0 010-5C11 2 12 7 12 7zM12 7h4.5a2.5 2.5 0 000-5C13 2 12 7 12 7z"
stroke="#a78bfa" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
stroke="var(--x-special-ink)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
</div>
<h2 style={{ margin: 0, fontSize: 17, fontWeight: 700, color: '#a78bfa' }}>{t('add.deal.title')}</h2>
<h2 style={{ margin: 0, fontSize: 17, fontWeight: 700, color: 'var(--x-special-ink)' }}>{t('add.deal.title')}</h2>
<p style={{ margin: '6px 0 0', fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{offer.deal_name}</p>
</div>
@@ -1083,13 +1084,13 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
{isFreeItem && offer.free_item_name && (
<div style={{
margin: '0 0 16px', padding: '14px 16px',
background: 'rgba(34,197,94,0.08)', border: '1.5px solid rgba(34,197,94,0.3)',
background: 'rgb(var(--x-success-rgb) / 0.08)', border: '1.5px solid rgb(var(--x-success-rgb) / 0.3)',
borderRadius: 12,
}}>
<p style={{ margin: 0, fontSize: 13, color: 'var(--muted)', marginBottom: 4 }}>{t('add.deal.freeProduct')}</p>
<p style={{ margin: 0, fontSize: 15, fontWeight: 700, color: '#4ade80' }}>
<p style={{ margin: 0, fontSize: 15, fontWeight: 700, color: 'var(--x-success)' }}>
{offer.free_item_name}
{offer.free_quantity > 1 && <span style={{ color: '#f59e0b', marginLeft: 6 }}>×{offer.free_quantity}</span>}
{offer.free_quantity > 1 && <span style={{ color: 'var(--x-warning)', marginLeft: 6 }}>×{offer.free_quantity}</span>}
</p>
</div>
)}
@@ -1099,7 +1100,7 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
<div style={{ marginBottom: 16 }}>
<p style={{ fontSize: 12, color: 'var(--muted)', marginBottom: 8 }}>
{t('add.deal.pickFree', { count: offer.free_quantity ?? 1 })}
{remaining > 0 && <span style={{ color: '#a78bfa', marginLeft: 4 }}>{t('add.deal.remaining', { count: remaining })}</span>}
{remaining > 0 && <span style={{ color: 'var(--x-special-ink)', marginLeft: 4 }}>{t('add.deal.remaining', { count: remaining })}</span>}
</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, maxHeight: 220, overflowY: 'auto' }}>
{offer.free_choices.map(choice => {
@@ -1110,15 +1111,15 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
style={{
display: 'flex', alignItems: 'center', gap: 10,
padding: '10px 12px', borderRadius: 10, border: 'none', cursor: disabled ? 'not-allowed' : 'pointer',
background: checked ? 'rgba(167,139,250,0.15)' : 'var(--bg3)',
background: checked ? 'rgb(var(--x-special-rgb) / 0.15)' : 'var(--bg3)',
opacity: disabled ? 0.4 : 1, textAlign: 'left',
}}>
<div style={{
width: 20, height: 20, borderRadius: 5, flexShrink: 0,
background: checked ? '#a78bfa' : 'var(--border)',
background: checked ? 'var(--x-special-ink)' : 'var(--border)',
display: 'flex', alignItems: 'center', justifyContent: 'center',
}}>
{checked && <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="white" strokeWidth="3" strokeLinecap="round"><path d="M20 6L9 17l-5-5"/></svg>}
{checked && <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="var(--x-on-colour)" strokeWidth="3" strokeLinecap="round"><path d="M20 6L9 17l-5-5"/></svg>}
</div>
<span style={{ fontSize: 14, fontWeight: 600, color: 'var(--text)' }}>{choice.name}</span>
</button>
@@ -1132,13 +1133,13 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
{isDiscount && offer.price_before != null && offer.price_after != null && (
<div style={{
margin: '0 0 16px', padding: '14px 16px',
background: 'rgba(34,197,94,0.08)', border: '1.5px solid rgba(34,197,94,0.3)',
background: 'rgb(var(--x-success-rgb) / 0.08)', border: '1.5px solid rgb(var(--x-success-rgb) / 0.3)',
borderRadius: 12, textAlign: 'center',
}}>
<span style={{ fontSize: 14, color: 'var(--muted)', textDecoration: 'line-through' }}>
{money(offer.price_before)}
</span>
<span style={{ fontSize: 22, fontWeight: 800, color: '#4ade80', margin: '0 12px' }}>
<span style={{ fontSize: 22, fontWeight: 800, color: 'var(--x-success)', margin: '0 12px' }}>
{money(offer.price_after)}
</span>
</div>
@@ -1148,7 +1149,7 @@ function DealOfferModal({ offer, _products, onAccept, onDismiss }) {
<button className="btn btn--secondary" style={{ flex: 1 }} onClick={onDismiss}>
{t('add.deal.skip')}
</button>
<button className="btn btn--primary" style={{ flex: 1, background: '#7c3aed', borderColor: '#7c3aed' }}
<button className="btn btn--primary" style={{ flex: 1, background: 'var(--x-special)', borderColor: 'var(--x-special)' }}
onClick={handleAccept} disabled={!canConfirm}>
{isFreeItem ? t('add.deal.addFree') : isFreeChoice ? t('common.confirm') : t('common.apply')}
</button>
@@ -1171,7 +1172,7 @@ function QuickAddToast({ product, count }) {
background: 'var(--bg)',
border: '1px solid var(--border)',
borderRadius: 14,
boxShadow: '0 8px 32px rgba(0,0,0,0.35)',
boxShadow: '0 8px 32px rgb(var(--x-scrim-rgb) / 0.35)',
display: 'flex', alignItems: 'center', gap: 12,
padding: '10px 16px 10px 10px',
minWidth: 220, maxWidth: 'min(88vw, 340px)',
@@ -1227,11 +1228,11 @@ const SECTION_META = {
function SectionIcon({ type }) {
const icons = {
prefs: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="4" fill="#f59e0b"/><circle cx="12" cy="12" r="9" stroke="#f59e0b" strokeWidth="2"/></svg>,
quick: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M5 12h14M13 6l6 6-6 6" stroke="#a3e635" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
extras: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="#60a5fa" strokeWidth="2.5" strokeLinecap="round"/></svg>,
removed: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M5 12h14" stroke="#ef4444" strokeWidth="2.5" strokeLinecap="round"/></svg>,
note: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="1.5" fill="#94a3b8"/><path d="M12 7v1M12 16v1" stroke="#94a3b8" strokeWidth="2" strokeLinecap="round"/><circle cx="12" cy="12" r="9" stroke="#94a3b8" strokeWidth="1.5"/></svg>,
prefs: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="4" fill="var(--x-warning)"/><circle cx="12" cy="12" r="9" stroke="var(--x-warning)" strokeWidth="2"/></svg>,
quick: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M5 12h14M13 6l6 6-6 6" stroke="var(--x-success)" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"/></svg>,
extras: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M12 5v14M5 12h14" stroke="var(--x-info)" strokeWidth="2.5" strokeLinecap="round"/></svg>,
removed: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><path d="M5 12h14" stroke="var(--x-danger)" strokeWidth="2.5" strokeLinecap="round"/></svg>,
note: <svg width="13" height="13" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="1.5" fill="var(--x-ink-2)"/><path d="M12 7v1M12 16v1" stroke="var(--x-ink-2)" strokeWidth="2" strokeLinecap="round"/><circle cx="12" cy="12" r="9" stroke="var(--x-ink-2)" strokeWidth="1.5"/></svg>,
}
return <span style={{ display: 'inline-flex', alignItems: 'center', flexShrink: 0 }}>{icons[type] ?? null}</span>
}
@@ -1266,7 +1267,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
</div>
{/* Quantity on the right */}
<span style={{ color: '#f59e0b', fontSize: 13, fontWeight: 700, fontVariantNumeric: 'tabular-nums', flexShrink: 0 }}>{fmtDraftQty(item.quantity, product?.unit_type)}</span>
<span style={{ color: 'var(--x-warning)', fontSize: 13, fontWeight: 700, fontVariantNumeric: 'tabular-nums', flexShrink: 0 }}>{fmtDraftQty(item.quantity, product?.unit_type)}</span>
{/* Edit — stop propagation so it doesn't toggle expand */}
<button onClick={e => { e.stopPropagation(); onEdit() }} style={{ background: 'none', border: '1px solid var(--border)', borderRadius: 7, color: 'var(--muted)', cursor: 'pointer', padding: '3px 9px', fontSize: 12, fontWeight: 500, flexShrink: 0 }}>
@@ -1298,7 +1299,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
<SectionIcon type="quick" />
<span style={{ fontSize: 12, color: 'var(--text)', flex: 1 }}>
{line.name}
{line._qty > 1 && <span style={{ color: '#f59e0b', marginLeft: 4, fontWeight: 700 }}>×{line._qty}</span>}
{line._qty > 1 && <span style={{ color: 'var(--x-warning)', marginLeft: 4, fontWeight: 700 }}>×{line._qty}</span>}
</span>
</div>
))}
@@ -1308,7 +1309,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
<span style={{ fontSize: 12, color: 'var(--text)', flex: 1 }}>
{line.name}
{line.subName && <span> · {line.subName}</span>}
{line.qty > 1 && <span style={{ color: '#f59e0b', marginLeft: 4, fontWeight: 700 }}>×{line.qty}</span>}
{line.qty > 1 && <span style={{ color: 'var(--x-warning)', marginLeft: 4, fontWeight: 700 }}>×{line.qty}</span>}
</span>
</div>
))}
@@ -1357,7 +1358,7 @@ function CartItem({ item, product, summaryLines, sections, onEdit, onRemove, onC
style={{
width: 36, height: 36, borderRadius: '50%',
background: 'var(--bg3)', border: '1px solid var(--border)',
color: '#22c55e',
color: 'var(--x-success)',
fontSize: 20, fontWeight: 700, cursor: 'pointer',
display: 'flex', alignItems: 'center', justifyContent: 'center',
}}
@@ -1397,7 +1398,7 @@ function SearchModal({ products, query, setQuery, onClose, onAdd, courses = [],
return (
<>
{/* Dim backdrop — tap to close */}
<div onClick={onClose} style={{ position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.5)', zIndex: 200 }} />
<div onClick={onClose} style={{ position: 'fixed', inset: 0, background: 'rgb(var(--x-scrim-rgb) / 0.5)', zIndex: 200 }} />
{/* Panel: fixed to bottom, grows upward, capped at 60vh so results don't
push the input off screen on short viewports */}