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:
@@ -2,6 +2,7 @@ import { useRef, useState } from 'react'
|
||||
import useTableViewStore from '../store/tableViewStore'
|
||||
import { money } from '../i18n'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { fade } from '../logic/colour'
|
||||
|
||||
const fmtPrice = money
|
||||
|
||||
@@ -25,11 +26,11 @@ function fmtDateTime(iso) {
|
||||
|
||||
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>
|
||||
}
|
||||
@@ -112,9 +113,9 @@ function buildSections(item) {
|
||||
// ── KDS colour strip ──────────────────────────────────────────────────────────
|
||||
|
||||
const KDS_COLORS = {
|
||||
pending: { textColor: '#f59e0b', label: 'kds.pending', icon: '⏳', dot: '#f59e0b' },
|
||||
preparing: { textColor: '#60a5fa', label: 'kds.preparing', icon: '🔥', dot: '#60a5fa' },
|
||||
done: { textColor: '#4ade80', label: 'kds.ready', icon: '✓', dot: '#4ade80' },
|
||||
pending: { textColor: 'var(--x-warning)', label: 'kds.pending', icon: '⏳', dot: 'var(--x-warning)' },
|
||||
preparing: { textColor: 'var(--x-info)', label: 'kds.preparing', icon: '🔥', dot: 'var(--x-info)' },
|
||||
done: { textColor: 'var(--x-success)', label: 'kds.ready', icon: '✓', dot: 'var(--x-success)' },
|
||||
served: { textColor: null, label: null, icon: null, dot: null },
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ function OptionsPanel({ sections }) {
|
||||
<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>
|
||||
))}
|
||||
@@ -154,7 +155,7 @@ function OptionsPanel({ sections }) {
|
||||
<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>
|
||||
))}
|
||||
@@ -195,7 +196,7 @@ function KdsBadge({ kdsColor, kdsDisplayStyle }) {
|
||||
fontSize: 9, fontWeight: 800, letterSpacing: 0.4,
|
||||
color: kdsColor.textColor,
|
||||
borderRadius: 3, padding: '1px 5px',
|
||||
border: `1px solid ${kdsColor.textColor}60`,
|
||||
border: `1px solid ${fade(kdsColor.textColor, 0.38)}`,
|
||||
flexShrink: 0,
|
||||
}}>{t(kdsColor.label)}</span>
|
||||
)
|
||||
@@ -204,10 +205,10 @@ function KdsBadge({ kdsColor, kdsDisplayStyle }) {
|
||||
// ── Price event label helpers ─────────────────────────────────────────────────
|
||||
|
||||
const PRICING_EVENT_STYLE = {
|
||||
modifier_applied: { color: '#60a5fa', label: null }, // label comes from modifier_name
|
||||
waiter_discount: { color: '#c084fc', label: 'summary.discount' },
|
||||
free_item_added: { color: '#4ade80', label: 'summary.free' },
|
||||
deal_offer_accepted: { color: '#4ade80', label: null }, // label from deal_name
|
||||
modifier_applied: { color: 'var(--x-info)', label: null }, // label comes from modifier_name
|
||||
waiter_discount: { color: 'var(--x-special-ink)', label: 'summary.discount' },
|
||||
free_item_added: { color: 'var(--x-success)', label: 'summary.free' },
|
||||
deal_offer_accepted: { color: 'var(--x-success)', label: null }, // label from deal_name
|
||||
}
|
||||
|
||||
function PricingRows({ events, _layout, nameIndent = 12 }) {
|
||||
@@ -225,7 +226,7 @@ function PricingRows({ events, _layout, nameIndent = 12 }) {
|
||||
<div style={{ margin: `0 12px`, height: 1, background: 'var(--border)' }} />
|
||||
<div style={{ padding: `4px 12px 4px ${nameIndent}px`, display: 'flex', flexDirection: 'column', gap: 3 }}>
|
||||
{rows.map((ev, i) => {
|
||||
const evStyle = PRICING_EVENT_STYLE[ev.event_type] || { color: '#94a3b8', label: ev.event_type }
|
||||
const evStyle = PRICING_EVENT_STYLE[ev.event_type] || { color: 'var(--x-ink-2)', label: ev.event_type }
|
||||
const label = ev.modifier_name || ev.deal_name || (evStyle.label && t(evStyle.label)) || ev.event_type
|
||||
const delta = ev.delta_amount
|
||||
|
||||
@@ -263,19 +264,19 @@ function PricingBadge({ events }) {
|
||||
const icons = []
|
||||
if (hasModifier) icons.push(
|
||||
<svg key="mod" width="10" height="10" viewBox="0 0 24 24" fill="none" title={t('summary.modifier')}>
|
||||
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" stroke="#60a5fa" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
||||
<path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5" stroke="var(--x-info)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
||||
</svg>
|
||||
)
|
||||
if (hasDiscount) icons.push(
|
||||
<svg key="disc" width="10" height="10" viewBox="0 0 24 24" fill="none" title={t('summary.discount')}>
|
||||
<circle cx="9" cy="9" r="2" stroke="#c084fc" strokeWidth="2"/>
|
||||
<circle cx="15" cy="15" r="2" stroke="#c084fc" strokeWidth="2"/>
|
||||
<path d="M5 19L19 5" stroke="#c084fc" strokeWidth="2" strokeLinecap="round"/>
|
||||
<circle cx="9" cy="9" r="2" stroke="var(--x-special-ink)" strokeWidth="2"/>
|
||||
<circle cx="15" cy="15" r="2" stroke="var(--x-special-ink)" strokeWidth="2"/>
|
||||
<path d="M5 19L19 5" stroke="var(--x-special-ink)" strokeWidth="2" strokeLinecap="round"/>
|
||||
</svg>
|
||||
)
|
||||
if (hasFree) icons.push(
|
||||
<svg key="free" width="10" height="10" viewBox="0 0 24 24" fill="none" title={t('summary.free')}>
|
||||
<path d="M20 12v10H4V12M22 7H2v5h20V7z" stroke="#4ade80" strokeWidth="2" strokeLinecap="round"/>
|
||||
<path d="M20 12v10H4V12M22 7H2v5h20V7z" stroke="var(--x-success)" strokeWidth="2" strokeLinecap="round"/>
|
||||
</svg>
|
||||
)
|
||||
|
||||
@@ -294,8 +295,8 @@ function DealBadge({ item }) {
|
||||
return (
|
||||
<span style={{
|
||||
fontSize: 9, fontWeight: 700, padding: '1px 5px', borderRadius: 4,
|
||||
background: 'rgba(167,139,250,0.15)', color: '#a78bfa',
|
||||
border: '1px solid rgba(167,139,250,0.4)', flexShrink: 0, letterSpacing: 0.3,
|
||||
background: 'rgb(var(--x-special-rgb) / 0.15)', color: 'var(--x-special-ink)',
|
||||
border: '1px solid rgb(var(--x-special-rgb) / 0.4)', flexShrink: 0, letterSpacing: 0.3,
|
||||
}}>
|
||||
{t('summary.freeCaps')}
|
||||
</span>
|
||||
@@ -309,8 +310,8 @@ function MergedBadge({ item }) {
|
||||
return (
|
||||
<span style={{
|
||||
fontSize: 9, fontWeight: 700, padding: '1px 5px', borderRadius: 4,
|
||||
background: 'rgba(99,102,241,0.15)', color: '#a5b4fc',
|
||||
border: '1px solid rgba(99,102,241,0.35)', flexShrink: 0, letterSpacing: 0.3,
|
||||
background: 'rgb(var(--x-info-rgb) / 0.15)', color: 'var(--x-info-ink)',
|
||||
border: '1px solid rgb(var(--x-info-rgb) / 0.35)', flexShrink: 0, letterSpacing: 0.3,
|
||||
}}>
|
||||
∑{item._sourceIds?.length}
|
||||
</span>
|
||||
@@ -373,7 +374,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
<span style={{
|
||||
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
||||
width: 16, height: 16, borderRadius: '50%',
|
||||
background: course.color, color: '#fff',
|
||||
background: course.color, color: 'var(--x-on-colour)',
|
||||
fontSize: 9, fontWeight: 700, flexShrink: 0, marginLeft: 4,
|
||||
}}>
|
||||
{courses.indexOf(course) + 1}
|
||||
@@ -435,7 +436,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '7px 12px' }}>
|
||||
{selectable && !isCancelled && (
|
||||
<span style={{ color: selected ? '#f59e0b' : '#475569', flexShrink: 0, fontSize: 16 }}>
|
||||
<span style={{ color: selected ? 'var(--x-warning)' : 'var(--x-ink-3)', flexShrink: 0, fontSize: 16 }}>
|
||||
{selected ? '☑' : '☐'}
|
||||
</span>
|
||||
)}
|
||||
@@ -464,7 +465,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
|
||||
<KdsBadge kdsColor={kdsColor} kdsDisplayStyle={kdsDisplayStyle} />
|
||||
<span className="order-item__qty">{fmtQty(item.quantity, item.unit_type)}</span>
|
||||
<span className="order-item__price" style={hasPriceAdj ? { color: '#60a5fa' } : undefined}>
|
||||
<span className="order-item__price" style={hasPriceAdj ? { color: 'var(--x-info)' } : undefined}>
|
||||
{totalPrice}
|
||||
</span>
|
||||
</div>
|
||||
@@ -488,7 +489,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
{/* Row 1: checkbox · name · badges · expand arrow · KDS badge */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '8px 12px 2px' }}>
|
||||
{selectable && !isCancelled && (
|
||||
<span style={{ color: selected ? '#f59e0b' : '#475569', flexShrink: 0, fontSize: 16 }}>
|
||||
<span style={{ color: selected ? 'var(--x-warning)' : 'var(--x-ink-3)', flexShrink: 0, fontSize: 16 }}>
|
||||
{selected ? '☑' : '☐'}
|
||||
</span>
|
||||
)}
|
||||
@@ -520,14 +521,14 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
}}>
|
||||
<span style={{ fontSize: 12, color: 'var(--muted)', flex: 1 }}>
|
||||
{hasPriceAdj
|
||||
? <><span style={{ textDecoration: 'line-through', marginRight: 4, opacity: 0.6 }}>{fmtPrice(item.unit_price)}</span><span style={{ color: '#60a5fa' }}>{fmtPrice(unitPriceAdjusted)}</span></>
|
||||
? <><span style={{ textDecoration: 'line-through', marginRight: 4, opacity: 0.6 }}>{fmtPrice(item.unit_price)}</span><span style={{ color: 'var(--x-info)' }}>{fmtPrice(unitPriceAdjusted)}</span></>
|
||||
: fmtPrice(unitPriceAdjusted)
|
||||
}
|
||||
</span>
|
||||
<span className="order-item__qty" style={{ textAlign: 'center', minWidth: 48 }}>
|
||||
{fmtQty(item.quantity, item.unit_type)}
|
||||
</span>
|
||||
<span className="order-item__price" style={{ minWidth: 64, textAlign: 'right', ...(hasPriceAdj ? { color: '#60a5fa' } : {}) }}>
|
||||
<span className="order-item__price" style={{ minWidth: 64, textAlign: 'right', ...(hasPriceAdj ? { color: 'var(--x-info)' } : {}) }}>
|
||||
{totalPrice}
|
||||
</span>
|
||||
</div>
|
||||
@@ -553,7 +554,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
{/* Row 1 */}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '8px 12px 2px' }}>
|
||||
{selectable && !isCancelled && (
|
||||
<span style={{ color: selected ? '#f59e0b' : '#475569', flexShrink: 0, fontSize: 16 }}>
|
||||
<span style={{ color: selected ? 'var(--x-warning)' : 'var(--x-ink-3)', flexShrink: 0, fontSize: 16 }}>
|
||||
{selected ? '☑' : '☐'}
|
||||
</span>
|
||||
)}
|
||||
@@ -575,14 +576,14 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
}}>
|
||||
<span style={{ fontSize: 12, color: 'var(--muted)', flex: 1 }}>
|
||||
{hasPriceAdj
|
||||
? <><span style={{ textDecoration: 'line-through', marginRight: 4, opacity: 0.6 }}>{fmtPrice(item.unit_price)}</span><span style={{ color: '#60a5fa' }}>{fmtPrice(unitPriceAdjusted)}</span></>
|
||||
? <><span style={{ textDecoration: 'line-through', marginRight: 4, opacity: 0.6 }}>{fmtPrice(item.unit_price)}</span><span style={{ color: 'var(--x-info)' }}>{fmtPrice(unitPriceAdjusted)}</span></>
|
||||
: fmtPrice(unitPriceAdjusted)
|
||||
}
|
||||
</span>
|
||||
<span className="order-item__qty" style={{ textAlign: 'center', minWidth: 48 }}>
|
||||
{fmtQty(item.quantity, item.unit_type)}
|
||||
</span>
|
||||
<span className="order-item__price" style={{ minWidth: 64, textAlign: 'right', ...(hasPriceAdj ? { color: '#60a5fa' } : {}) }}>
|
||||
<span className="order-item__price" style={{ minWidth: 64, textAlign: 'right', ...(hasPriceAdj ? { color: 'var(--x-info)' } : {}) }}>
|
||||
{totalPrice}
|
||||
</span>
|
||||
</div>
|
||||
@@ -635,7 +636,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
<SectionIcon type="quick" />
|
||||
<span style={{ fontSize: 11, 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>
|
||||
))}
|
||||
@@ -645,7 +646,7 @@ function ItemRow({ item, selectable, selected, onToggle, onLongPress, isLast, kd
|
||||
<span style={{ fontSize: 11, 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>
|
||||
))}
|
||||
@@ -684,7 +685,7 @@ export default function OrderSummary({ order, selectable = false, selectedIds =
|
||||
|
||||
return (
|
||||
<div className="order-summary">
|
||||
{activeItems.length === 0 && <p style={{ color: '#64748b', textAlign: 'center' }}>{t('summary.noItems')}</p>}
|
||||
{activeItems.length === 0 && <p style={{ color: 'var(--x-ink-3)', textAlign: 'center' }}>{t('summary.noItems')}</p>}
|
||||
{activeItems.map((item, idx) => (
|
||||
<ItemRow
|
||||
key={item.id}
|
||||
@@ -706,15 +707,15 @@ export default function OrderSummary({ order, selectable = false, selectedIds =
|
||||
<span>{fmtPrice(total)}</span>
|
||||
</div>
|
||||
{paidTotal > 0 && paidTotal < total && (
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 12px 8px', fontSize: 13, color: '#64748b' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 12px 8px', fontSize: 13, color: 'var(--x-ink-3)' }}>
|
||||
<span>{t('tables.quick.paid')}</span>
|
||||
<span style={{ color: '#22c55e' }}>{fmtPrice(paidTotal)}</span>
|
||||
<span style={{ color: 'var(--x-success)' }}>{fmtPrice(paidTotal)}</span>
|
||||
</div>
|
||||
)}
|
||||
{paidTotal > 0 && paidTotal < total && (
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 12px 8px', fontSize: 13, color: '#94a3b8' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', padding: '0 12px 8px', fontSize: 13, color: 'var(--x-ink-2)' }}>
|
||||
<span>{t('summary.due')}</span>
|
||||
<span style={{ color: '#f59e0b', fontWeight: 700 }}>{fmtPrice(total - paidTotal)}</span>
|
||||
<span style={{ color: 'var(--x-warning)', fontWeight: 700 }}>{fmtPrice(total - paidTotal)}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user