From 1b111c0e279e6ac94bad8ba781f2e0bf39be471e Mon Sep 17 00:00:00 2001 From: bonamin Date: Sun, 22 Nov 2026 15:30:14 +0200 Subject: [PATCH] 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 --- docs/README.md | 2 +- local_backend/core/modules/api.py | 17 +++++ local_backend/modules/core/manifest.py | 2 +- local_backend/routers/customer_display.py | 11 ++- local_backend/tests/test_venue_theme.py | 10 +++ .../sections/CustomerDisplaySettings.jsx | 6 ++ .../pages/Settings/sections/VenueSettings.jsx | 10 ++- .../src/pages/signage/WidgetsEditor.jsx | 9 ++- packages/i18n/locales/el/manager.json | 17 +++-- packages/i18n/locales/en/manager.json | 17 +++-- packages/signage/src/Slides.jsx | 5 +- packages/signage/src/logic.js | 2 + packages/ui/src/index.js | 1 + packages/ui/src/venueAccent.js | 68 +++++++++++++++++++ packages/ui/tests/venueAccent.test.mjs | 19 ++++++ terminal/src/App.jsx | 16 ++++- .../customer-display/CustomerDisplayApp.jsx | 9 ++- terminal/src/apps/signage/SignageApp.jsx | 9 ++- tests/e2e/signage.mjs | 15 +++- waiter_pwa/src/App.jsx | 12 ++-- 20 files changed, 229 insertions(+), 28 deletions(-) create mode 100644 packages/ui/src/venueAccent.js create mode 100644 packages/ui/tests/venueAccent.test.mjs diff --git a/docs/README.md b/docs/README.md index c6af785..6414eb7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -73,7 +73,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r | `packages/ui/` | Shared design tokens, Tailwind preset and base components (CS-16). Visual check: `npm run dev:manager` → `/ui-gallery` | | `docs/DESIGN.md` | **The design language** (2026-11-20): the page rule (``: own scroll, fills 1080p, 16:9 and centred on ultrawides), toolbars, the one `Dropdown` (multi-select), tabs, type/spacing tokens, tables. Read before any UI work (CS-20) | | `packages/api/` | Shared HTTP client (`createApiClient`: session/device headers, `err.xenia` codes, the manager-approval retry) and the live WebSocket client with cursor replay (`createLiveClient`, used by the waiter's `useWebSocket`) (CS-18) | -| `routers/identity.py`; manager `pages/Settings/sections/IdentitySettings.jsx`, `shell/useIdentity.js`, `shell/VenueIdentity.jsx` | The venue's identity (6R.14): `GET/PUT /api/identity` = `venue.name` + the JSON setting `venue.identity` (slogan, up to 12 named colours, logos main / light / dark / icon as media ids — registered usage `identity` —, guest Wi-Fi, contact details). Signage gets it in `_venue()` (`identity`, plus the venue's `timezone`) and every screen is told on a change. The manager reads it once (`useIdentity`) and `VenueIdentity` feeds `VenueColoursProvider` (`@xenia/ui`): every `ColourField` offers the venue's colours first. `wifiQr()` (`@xenia/signage/logic`) writes the join-the-network QR text | +| `routers/identity.py`; manager `pages/Settings/sections/IdentitySettings.jsx`, `shell/useIdentity.js`, `shell/VenueIdentity.jsx` | The venue's identity (6R.14): `GET/PUT /api/identity` = `venue.name` + the JSON setting `venue.identity` (slogan, up to 12 named colours, logos main / light / dark / icon as media ids — registered usage `identity` —, guest Wi-Fi, contact details). Signage gets it in `_venue()` (`identity`, plus the venue's `timezone`) and every screen is told on a change. The manager reads it once (`useIdentity`) and `VenueIdentity` feeds `VenueColoursProvider` (`@xenia/ui`): every `ColourField` offers the venue's colours first. `wifiQr()` (`@xenia/signage/logic`) writes the join-the-network QR text. **In every app (6R.20):** bootstrap `venue.identity` = {colour (the first), slogan, logo, logo_light, logo_dark, icon}; `venue.theme = identity` → `applyVenueTheme('identity', colour)` (`@xenia/ui/venueAccent.js`: accent tokens for light and dark from one colour, readable foregrounds) in the waiter app and every terminal screen (else the terminal keeps its own accent); a customer display look's `brand: identity` (its accent and the identity's logo when the look has none); a signage logo widget without a picture shows the main logo (kept on the TV) | | `packages/signage/` | `@xenia/signage` (5.6a): signage slides as the TVs draw them (`SlideView`, `TextSlide`, `MenuSlide`, `Widgets`) and the player's pure logic (schedule pick, slide windows, menu pages; tests in `tests/`), shared by the terminal's player and the manager's previews. Sizes are container units (`cqmin`): a slide needs a parent with `container-type: size` (`frameStyle()`; the manager's `SlidePreview` lays it out at 1920 × 1080 and scales it down, so previews match a TV). Both apps' Tailwind `content` include it | | `packages/access/` | `` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, ``, `` (CS-18); the fixed lists every app shares with the backend: sales points (`salesPoints.js` = `core/sales_points.py`) the 14 EU allergens (`allergens.js` = `core/allergens.py`, 6.3) and the menu's languages (`menuLanguages.js` = `core/menu_languages.py`, 6.4: el + en; a product's own name is its base text, translations in `products.translations` / `categories.translations` are for customer screens only; tests compare the lists), and `` (a product's allergens, the same in every app). Plain-JS subpaths `@xenia/access/salesPoints`, `/allergens` for Node tests | | `packages/i18n/` | Translations (`locales//.json`), language resolution, venue-time / money / number formatting, the comma-or-dot number parser, and the guard `scripts/check-i18n.mjs` (CS-17). Sample: `/i18n-sample` (dev) | diff --git a/local_backend/core/modules/api.py b/local_backend/core/modules/api.py index bf36661..6bd6e7d 100644 --- a/local_backend/core/modules/api.py +++ b/local_backend/core/modules/api.py @@ -38,6 +38,22 @@ router = APIRouter() _optional_bearer = HTTPBearer(auto_error=False) +def _identity_brief(db) -> dict: + """What every app needs of the venue's identity (6R.20): its first colour (the accent when + venue.theme is "identity"), the slogan and the logos' addresses. Public, like the venue's name.""" + try: + from routers.identity import identity_out + ident = identity_out(db) + except Exception: + return {"colour": None, "slogan": None, "logo": None, "logo_light": None, "logo_dark": None, "icon": None} + logos = ident.get("logos") or {} + + def card(k): + return (logos.get(k) or {}).get("card") + return {"colour": (ident.get("colours") or [{}])[0].get("colour"), "slogan": ident.get("slogan"), + "logo": card("main"), "logo_light": card("light"), "logo_dark": card("dark"), "icon": (logos.get("icon") or {}).get("thumb")} + + def permission_keys_for(user) -> list[str]: """The keys a user holds (user_permissions; superadmin: every key).""" from core.access.check import user_keys @@ -113,6 +129,7 @@ def bootstrap( "language": i18n.venue_language(), "currency": _setting(db, "venue.currency", "EUR"), "theme": _setting(db, "venue.theme", "amber") or "amber", # the accent colour (4.6, data-venue-theme) + "identity": _identity_brief(db), # 6R.20: its colour and logos for the apps "business_day_rollover_hour": timeutil.rollover_hour(), }, "modules": [{"key": m.key, "kind": m.kind} for m in registry().values() if m.key in effective], diff --git a/local_backend/modules/core/manifest.py b/local_backend/modules/core/manifest.py index 0925071..06c80ea 100644 --- a/local_backend/modules/core/manifest.py +++ b/local_backend/modules/core/manifest.py @@ -35,7 +35,7 @@ MODULE = Module( SettingDef('venue.name', '', 'Venue name shown on screens and tickets.', type='str'), SettingDef('venue.opening_hours', '{}', 'Opening hours, Monday first (6R.15; JSON {days, note}; edited on the Schedule page, shown by signage).', type='json'), SettingDef('venue.identity', '{}', "The venue's identity (6R.14): slogan, colours, logos, Wi-Fi, contact details (JSON; Settings > Identity, routers/identity.py).", type='json'), - SettingDef('venue.theme', 'amber', "Accent colour of the staff apps (the waiter's phones first, plan step 4.6): 'teal' | 'amber' | 'blue' | 'violet' | 'rose'", type='enum', choices=('teal', 'amber', 'blue', 'violet', 'rose')), + SettingDef('venue.theme', 'amber', "Accent colour of the staff apps (the waiter's phones first, plan step 4.6): 'teal' | 'amber' | 'blue' | 'violet' | 'rose', or 'identity' = the first colour of the venue's identity (6R.20: also the counter, KDS and tablets)", type='enum', choices=('teal', 'amber', 'blue', 'violet', 'rose', 'identity')), SettingDef('venue.type', '', 'Kind of venue (restaurant, cafe, bar...), chosen in the setup wizard.', type='str'), SettingDef('venue.currency', 'EUR', 'ISO 4217 currency of all prices.', type='str'), ), diff --git a/local_backend/routers/customer_display.py b/local_backend/routers/customer_display.py index 990432f..bb90167 100644 --- a/local_backend/routers/customer_display.py +++ b/local_backend/routers/customer_display.py @@ -64,6 +64,7 @@ class IdleBody(BaseModel): qr_url: Optional[str] = Field(default=None, max_length=300) qr_caption: Optional[str] = Field(default=None, max_length=80) theme: Literal["dark", "light"] = "dark" + brand: Literal["own", "identity"] = "own" # 6R.20: the venue's identity: its colour as the accent, its logo when the look has none @field_validator("qr_url") @classmethod @@ -157,7 +158,15 @@ def idle_out(db, look: DisplayLook | None) -> dict: cfg = config_of(look) pics = _pictures(db, [cfg["logo"], cfg["image"], *cfg["slides"]]) url = lambda i, size: (media_store.image_of(pics[i]) or {}).get(size) if i in pics else None # noqa: E731 - return {**cfg, "logo_url": url(cfg["logo"], "card"), "image_url": url(cfg["image"], "full"), + logo = url(cfg["logo"], "card") + accent = None + if cfg.get("brand") == "identity": + from core.modules.api import _identity_brief + ib = _identity_brief(db) + accent = ib["colour"] + # its own logo first; else the identity's (the one made for this background, else the main one) + logo = logo or (ib["logo_light"] if cfg.get("theme", "dark") == "dark" else ib["logo_dark"]) or ib["logo"] + return {**cfg, "logo_url": logo, "accent": accent, "image_url": url(cfg["image"], "full"), "slide_urls": [u for u in (url(i, "full") for i in cfg["slides"]) if u], "qr_link": _qr_link(cfg) if cfg["style"] == "qr" else None} diff --git a/local_backend/tests/test_venue_theme.py b/local_backend/tests/test_venue_theme.py index 3d3501e..5e65bf9 100644 --- a/local_backend/tests/test_venue_theme.py +++ b/local_backend/tests/test_venue_theme.py @@ -8,3 +8,13 @@ def test_venue_theme_reaches_bootstrap(client, make_user, login): assert client.get("/api/platform/bootstrap").json()["venue"]["theme"] == "blue" r = client.put("/api/settings/venue.theme", headers=owner, json={"value": "neon"}) assert r.status_code in (400, 422) + + +def test_the_identity_as_the_staff_apps_colour(client, make_user, login): + """6R.20: venue.theme "identity" = the first colour of the venue's identity; bootstrap carries it and the logos.""" + owner = login(make_user(role="owner")) + assert client.get("/api/platform/bootstrap").json()["venue"]["identity"]["colour"] is None + client.put("/api/identity", headers=owner, json={"colours": [{"name": "Main", "colour": "#1E3A8A"}], "slogan": "Since 1987"}) + assert client.put("/api/settings/venue.theme", headers=owner, json={"value": "identity"}).status_code == 200 + v = client.get("/api/platform/bootstrap").json()["venue"] + assert v["theme"] == "identity" and v["identity"]["colour"] == "#1e3a8a" and v["identity"]["slogan"] == "Since 1987" and v["identity"]["logo"] is None diff --git a/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx b/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx index fa4554d..7a879ea 100644 --- a/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx +++ b/manager_dashboard/src/pages/Settings/sections/CustomerDisplaySettings.jsx @@ -138,6 +138,12 @@ export default function CustomerDisplaySettings() { + + + {shows('slides') && ( s.save('venue.timezone', e.target.value)} options={zones.map(z => ({ value: z, label: z.replace(/_/g, ' ') }))} /> - +