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
+41
View File
@@ -0,0 +1,41 @@
// Plan step 4.6 (CS-16): the waiter's colours are @xenia/ui tokens (var(--x-…) or the app's
// --bg / --text / --accent… made of them), so light / dark and the venue's colour reach every
// screen. No colour value may be written in the app's code; a colour that isn't a token yet
// becomes one in packages/ui/src/tokens.css. Colours the venue stores are data, not styling:
// the table-card palette's defaults (store/tableColourStore.js) are the one exception.
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readdirSync, readFileSync, statSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'src')
const DATA = new Set(['store/tableColourStore.js'])
const COLOUR = [
/(^|[^\w&])#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?(?:[0-9a-fA-F]{2})?\b/, // #fff, #f59e0b, #f59e0b40
/\brgba?\(\s*\d/, // rgb(245, 158, 11)
/\bhsla?\(\s*\d/,
/['"](white|black)['"]/, // named colours as values
/var\(--[\w-]+\)[0-9a-fA-F]{2}\b/, // 'var(--accent)18': invalid CSS
]
function walk(dir, out = []) {
for (const name of readdirSync(dir)) {
const p = path.join(dir, name)
if (statSync(p).isDirectory()) walk(p, out)
else if (/\.(jsx?|css)$/.test(name)) out.push(p)
}
return out
}
test('no colour literal in the waiter app (tokens only)', () => {
const hits = []
for (const file of walk(SRC)) {
const rel = path.relative(SRC, file).split(path.sep).join('/')
if (DATA.has(rel)) continue
readFileSync(file, 'utf8').split('\n').forEach((line, i) => {
if (COLOUR.some(re => re.test(line))) hits.push(`${rel}:${i + 1}: ${line.trim().slice(0, 90)}`)
})
}
assert.deepEqual(hits, [], `colour values in app code — use a token (var(--x-…)):\n${hits.join('\n')}`)
})