feat: the venue's identity in every app: its colour as the accent of the waiters' phones and every terminal screen, customer display looks on the identity, the signage logo widget falls back to the venue's logo

Settings -> Venue -> accent "The venue's identity" (venue.theme = identity): bootstrap
carries the identity's first colour and logos; @xenia/ui applyVenueTheme makes the
accent tokens (light and dark, readable foregrounds) from it. A display look's
"Colours and logo" can be the venue's identity. Plan 6R.20, F-117.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:30:14 +02:00
co-authored by Claude Opus 5.5
parent 0bd32d9171
commit 1b111c0e27
20 changed files with 229 additions and 28 deletions
+13 -4
View File
@@ -418,14 +418,16 @@
"timezone": "Ζώνη ώρας",
"timezoneHint": "Όλες οι ώρες εμφανίζονται σε αυτή. Η ώρα εκεί τώρα: {{time}}.",
"theme": "Χρώμα",
"themeHint": "Το χρώμα έμφασης στα κινητά των σερβιτόρων.",
"themeHint": "Το χρώμα έμφασης στα κινητά των σερβιτόρων· η «Ταυτότητα του καταστήματος» χρωματίζει και το ταμείο, τις οθόνες κουζίνας και τα tablet μενού.",
"themes": {
"amber": "Πορτοκαλί",
"teal": "Πετρόλ",
"blue": "Μπλε",
"violet": "Μωβ",
"rose": "Ροζ"
}
"rose": "Ροζ",
"identity": "Η ταυτότητα του καταστήματος (το πρώτο χρώμα της)"
},
"identityNoColour": "Η ταυτότητα του καταστήματος δεν έχει χρώματα ακόμη (Ρυθμίσεις → Ταυτότητα): τα κινητά μένουν πορτοκαλί και οι οθόνες κρατούν το δικό τους χρώμα μέχρι να αποκτήσει."
},
"print": {
"title": "Ειδοποιήσεις εκτύπωσης",
@@ -1138,6 +1140,12 @@
"deleteTitle": "Διαγραφή «{{name}}»;",
"deleteBody": "Οι οθόνες που τη δείχνουν επιστρέφουν στην προεπιλεγμένη εμφάνιση ({{name}}). Οι εικόνες της μένουν στη βιβλιοθήκη πολυμέσων.",
"deleted": "Η εμφάνιση διαγράφηκε."
},
"brand": "Χρώματα και λογότυπο",
"brandHint": "Η «Ταυτότητα του καταστήματος» χρησιμοποιεί το πρώτο της χρώμα και, όταν αυτή η εμφάνιση δεν έχει δικό της λογότυπο, το λογότυπό της.",
"brands": {
"own": "Της εμφάνισης",
"identity": "Η ταυτότητα του καταστήματος"
}
},
"calls": {
@@ -1732,7 +1740,8 @@
},
"weatherHours": "Ώρες",
"weatherPlace": "Η τοποθεσία",
"weatherPlaceLabel": "Δείχνει το όνομά της"
"weatherPlaceLabel": "Δείχνει το όνομά της",
"logoFromIdentity": "Χωρίς εικόνα: εμφανίζεται το λογότυπο του καταστήματος (Ρυθμίσεις → Ταυτότητα)."
},
"tabs": {
"playlists": "Λίστες",
+13 -4
View File
@@ -418,14 +418,16 @@
"timezone": "Time zone",
"timezoneHint": "Every time is shown in it. The time there now: {{time}}.",
"theme": "Colour",
"themeHint": "The accent colour of the waiters' phones.",
"themeHint": "The accent colour of the waiters' phones; \"The venue's identity\" also colours the counter, kitchen screens and menu tablets.",
"themes": {
"amber": "Amber",
"teal": "Teal",
"blue": "Blue",
"violet": "Violet",
"rose": "Rose"
}
"rose": "Rose",
"identity": "The venue's identity (its first colour)"
},
"identityNoColour": "The venue's identity has no colours yet (Settings → Identity): the phones stay amber and the screens keep their own colour until it has one."
},
"print": {
"title": "Print alerts",
@@ -1138,6 +1140,12 @@
"deleteTitle": "Delete \"{{name}}\"?",
"deleteBody": "Displays showing it go back to the default look ({{name}}). Its pictures stay in the media library.",
"deleted": "Look deleted."
},
"brand": "Colours and logo",
"brandHint": "\"The venue's identity\" uses its first colour and, when this look has no logo of its own, its logo.",
"brands": {
"own": "This look's own",
"identity": "The venue's identity"
}
},
"calls": {
@@ -1732,7 +1740,8 @@
},
"weatherHours": "Hours",
"weatherPlace": "The place",
"weatherPlaceLabel": "Show its name"
"weatherPlaceLabel": "Show its name",
"logoFromIdentity": "No picture chosen: the venue's logo (Settings → Identity) shows."
},
"tabs": {
"playlists": "Playlists",
+4 -1
View File
@@ -311,7 +311,10 @@ function widgetBody(w, ctx, fit, path) {
<div style={{ width: cq(BOXED[kind][0] * s), height: cq(BOXED[kind][1] * s), containerType: 'size' }} {...CQ_BOX}>{body}</div>
))
if (w.kind === 'logo') {
const m = media(w.media_id)
// its own picture; none chosen: the venue's logo (its identity, 6R.20)
const own = w.media_id ? media(w.media_id) : null
const brand = venue?.identity?.logos?.main
const m = own || (brand ? { src: brand.card } : null)
if (!m) return null
if (fit === 'tight') return <img src={m.src} alt="" style={{ height: cq(+(w.box.h * ts).toFixed(4), 'h'), width: 'auto', display: 'block' }} data-testid="signage-w-logo" />
return fit
+2
View File
@@ -165,6 +165,8 @@ export function mediaUrls(data) {
if (m.poster) out.add(m.poster) // a video's still frame (5.4e), shown while it loads
}
}
// the venue's logos (its identity, 6R.20): a logo widget without its own picture shows the main one
for (const l of Object.values(data.venue?.identity?.logos || {})) if (l?.card) out.add(l.card)
return [...out]
}
+1
View File
@@ -38,4 +38,5 @@ export { Stepper } from './components/Stepper.jsx'
export { ReasonPicker, reasonText } from './components/ReasonPicker.jsx'
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
export { cx } from './internal/cx.js'
export { accentCss, accentTokens, applyVenueTheme } from './venueAccent.js'
export { THEMES, PALETTES, STYLES, THEME_STORAGE_KEY, PALETTE_STORAGE_KEY, STYLE_STORAGE_KEY, applyLook, applyTheme, getStoredLook, getStoredTheme, resolveMode } from './theme.js'
+68
View File
@@ -0,0 +1,68 @@
// The staff apps' accent from the venue's own colour (6R.20): Settings → Venue → "The venue's
// identity" makes the accent tokens (accent, strong, fg, soft, ink; light and dark) from the first
// colour of the venue's identity instead of a ready-made accent (data-venue-theme="teal"…). The
// tokens come from a <style> the page gets once; data-venue-theme="identity" turns them on. No React.
//
// applyVenueTheme('identity', '#1e3a8a') the identity's colour
// applyVenueTheme('amber') a ready-made accent (tokens.css)
const STYLE_ID = 'x-venue-accent'
const rgb = hex => {
const h = String(hex || '').replace('#', '').slice(0, 6)
return /^[0-9a-fA-F]{6}$/.test(h) ? [0, 2, 4].map(i => parseInt(h.slice(i, i + 2), 16)) : null
}
const mix = (a, b, t) => a.map((v, i) => Math.round(v + (b[i] - v) * t))
const lum = c => {
const [r, g, b] = c.map(v => { const s = v / 255; return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4 })
return 0.2126 * r + 0.7152 * g + 0.0722 * b
}
const WHITE = [255, 255, 255]
const BLACK = [0, 0, 0]
const ratio = (a, b) => { const [x, y] = [lum(a), lum(b)].sort((m, n) => n - m); return (x + 0.05) / (y + 0.05) }
/** White or a near-black of the colour, whichever reads better on it. */
const fgOn = c => { const dark = mix(c, BLACK, 0.85); return ratio(c, WHITE) >= ratio(c, dark) ? WHITE : dark }
/** Darker until it reads on white (text, buttons on a light page). */
const deepen = c => { let x = c; for (let i = 0; i < 12 && ratio(x, WHITE) < 4.5; i++) x = mix(x, BLACK, 0.12); return x }
const str = c => c.join(' ')
/** The accent tokens for a colour: { light: {name: "r g b"}, dark: {…} }, or null for a bad colour. */
export function accentTokens(hex) {
const c = rgb(hex)
if (!c) return null
// light: the colour, kept dark enough to read on white
const base = deepen(c)
const light = { accent: base, 'accent-strong': mix(base, BLACK, 0.2), 'accent-soft': mix(c, WHITE, 0.85), 'accent-ink': mix(base, BLACK, 0.3) }
light['accent-fg'] = fgOn(light.accent)
// dark: lighter, to read on the dark surfaces
const up = lum(c) < 0.25 ? mix(c, WHITE, 0.45) : c
const dark = { accent: up, 'accent-strong': mix(up, WHITE, 0.25), 'accent-soft': mix(c, BLACK, 0.65), 'accent-ink': mix(up, WHITE, 0.55) }
dark['accent-fg'] = fgOn(dark.accent)
const out = m => Object.fromEntries(Object.entries(m).map(([k, v]) => [k, str(v)]))
return { light: out(light), dark: out(dark) }
}
/** The CSS that turns the tokens on under data-venue-theme="identity". */
export function accentCss(hex) {
const t = accentTokens(hex)
if (!t) return ''
const block = m => Object.entries(m).map(([k, v]) => `--x-${k}-rgb: ${v};`).join(' ')
return `[data-venue-theme="identity"] { ${block(t.light)} }\n`
+ `[data-theme="dark"][data-venue-theme="identity"], [data-theme="dark"] [data-venue-theme="identity"] { ${block(t.dark)} }\n`
}
/** The venue's accent on <html>: a ready-made one, or "identity" with its colour (no colour: as before). */
export function applyVenueTheme(theme, colour, { root = globalThis.document?.documentElement } = {}) {
if (!root) return
const doc = root.ownerDocument
let el = doc.getElementById(STYLE_ID)
const css = theme === 'identity' ? accentCss(colour) : ''
if (css) {
if (!el) { el = doc.createElement('style'); el.id = STYLE_ID; doc.head.appendChild(el) }
if (el.textContent !== css) el.textContent = css
root.setAttribute('data-venue-theme', 'identity')
} else {
if (theme && theme !== 'identity') root.setAttribute('data-venue-theme', theme)
else root.removeAttribute('data-venue-theme')
}
}
+19
View File
@@ -0,0 +1,19 @@
// The accent from the venue's identity colour (6R.20).
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { accentCss, accentTokens } from '../src/venueAccent.js'
const lum = s => { const [r, g, b] = s.split(' ').map(Number).map(v => { const x = v / 255; return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4 }); return 0.2126 * r + 0.7152 * g + 0.0722 * b }
const contrast = (a, b) => { const [x, y] = [lum(a), lum(b)].sort((m, n) => n - m); return (x + 0.05) / (y + 0.05) }
test('tokens from a colour: text on the accent reads, light and dark', () => {
for (const hex of ['#1e3a8a', '#f59e0b', '#ffffff', '#000000', '#22c55e', '#e63946']) {
const t = accentTokens(hex)
assert.ok(contrast(t.light.accent, t.light['accent-fg']) >= 3, `${hex} light ${JSON.stringify(t.light)}`)
assert.ok(contrast(t.dark.accent, t.dark['accent-fg']) >= 3, `${hex} dark ${JSON.stringify(t.dark)}`)
assert.ok(contrast(t.light['accent-ink'], '255 255 255') >= 3, `${hex} ink on white`)
}
assert.equal(accentTokens('red'), null)
assert.equal(accentCss('nope'), '')
assert.match(accentCss('#1e3a8a'), /\[data-venue-theme="identity"\] \{ --x-accent-rgb: 30 58 138;/)
})