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:
+1
-1
@@ -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` |
|
| `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 (`<Page>`: 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) |
|
| `docs/DESIGN.md` | **The design language** (2026-11-20): the page rule (`<Page>`: 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) |
|
| `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/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/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (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 `<Allergens>` (a product's allergens, the same in every app). Plain-JS subpaths `@xenia/access/salesPoints`, `/allergens` for Node tests |
|
| `packages/access/` | `<AccessProvider>` (bootstrap → modules, permission keys, venue, language; mounts the approval dialog), `useCan`, `useModule`, `<Can>`, `<RequireModule>` (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 `<Allergens>` (a product's allergens, the same in every app). Plain-JS subpaths `@xenia/access/salesPoints`, `/allergens` for Node tests |
|
||||||
| `packages/i18n/` | Translations (`locales/<lang>/<ns>.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) |
|
| `packages/i18n/` | Translations (`locales/<lang>/<ns>.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) |
|
||||||
|
|||||||
@@ -38,6 +38,22 @@ router = APIRouter()
|
|||||||
_optional_bearer = HTTPBearer(auto_error=False)
|
_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]:
|
def permission_keys_for(user) -> list[str]:
|
||||||
"""The keys a user holds (user_permissions; superadmin: every key)."""
|
"""The keys a user holds (user_permissions; superadmin: every key)."""
|
||||||
from core.access.check import user_keys
|
from core.access.check import user_keys
|
||||||
@@ -113,6 +129,7 @@ def bootstrap(
|
|||||||
"language": i18n.venue_language(),
|
"language": i18n.venue_language(),
|
||||||
"currency": _setting(db, "venue.currency", "EUR"),
|
"currency": _setting(db, "venue.currency", "EUR"),
|
||||||
"theme": _setting(db, "venue.theme", "amber") or "amber", # the accent colour (4.6, data-venue-theme)
|
"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(),
|
"business_day_rollover_hour": timeutil.rollover_hour(),
|
||||||
},
|
},
|
||||||
"modules": [{"key": m.key, "kind": m.kind} for m in registry().values() if m.key in effective],
|
"modules": [{"key": m.key, "kind": m.kind} for m in registry().values() if m.key in effective],
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ MODULE = Module(
|
|||||||
SettingDef('venue.name', '', 'Venue name shown on screens and tickets.', type='str'),
|
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.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.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.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'),
|
SettingDef('venue.currency', 'EUR', 'ISO 4217 currency of all prices.', type='str'),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class IdleBody(BaseModel):
|
|||||||
qr_url: Optional[str] = Field(default=None, max_length=300)
|
qr_url: Optional[str] = Field(default=None, max_length=300)
|
||||||
qr_caption: Optional[str] = Field(default=None, max_length=80)
|
qr_caption: Optional[str] = Field(default=None, max_length=80)
|
||||||
theme: Literal["dark", "light"] = "dark"
|
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")
|
@field_validator("qr_url")
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -157,7 +158,15 @@ def idle_out(db, look: DisplayLook | None) -> dict:
|
|||||||
cfg = config_of(look)
|
cfg = config_of(look)
|
||||||
pics = _pictures(db, [cfg["logo"], cfg["image"], *cfg["slides"]])
|
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
|
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],
|
"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}
|
"qr_link": _qr_link(cfg) if cfg["style"] == "qr" else None}
|
||||||
|
|
||||||
|
|||||||
@@ -8,3 +8,13 @@ def test_venue_theme_reaches_bootstrap(client, make_user, login):
|
|||||||
assert client.get("/api/platform/bootstrap").json()["venue"]["theme"] == "blue"
|
assert client.get("/api/platform/bootstrap").json()["venue"]["theme"] == "blue"
|
||||||
r = client.put("/api/settings/venue.theme", headers=owner, json={"value": "neon"})
|
r = client.put("/api/settings/venue.theme", headers=owner, json={"value": "neon"})
|
||||||
assert r.status_code in (400, 422)
|
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
|
||||||
|
|||||||
@@ -138,6 +138,12 @@ export default function CustomerDisplaySettings() {
|
|||||||
<option value="light">{t('display.themes.light')}</option>
|
<option value="light">{t('display.themes.light')}</option>
|
||||||
</Select>
|
</Select>
|
||||||
</Field>
|
</Field>
|
||||||
|
<Field label={t('display.brand')} hint={t('display.brandHint')}>
|
||||||
|
<Select value={form.brand || 'own'} onChange={e => set('brand', e.target.value)} data-testid="display-brand">
|
||||||
|
<option value="own">{t('display.brands.own')}</option>
|
||||||
|
<option value="identity">{t('display.brands.identity')}</option>
|
||||||
|
</Select>
|
||||||
|
</Field>
|
||||||
{shows('slides') && (
|
{shows('slides') && (
|
||||||
<Field label={t('display.slideSeconds')}>
|
<Field label={t('display.slideSeconds')}>
|
||||||
<Input inputMode="numeric" value={String(form.slide_seconds)} data-testid="display-slide-seconds"
|
<Input inputMode="numeric" value={String(form.slide_seconds)} data-testid="display-slide-seconds"
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
// Venue language and time zone (plan step 2.6f, D-11, D-12): venue.language is the
|
// Venue language and time zone (plan step 2.6f, D-11, D-12): venue.language is the
|
||||||
// language of staff without their own choice and of printed tickets/reports; venue.timezone
|
// language of staff without their own choice and of printed tickets/reports; venue.timezone
|
||||||
// is the zone every time is shown in (applies at once); venue.theme is the staff apps' accent
|
// is the zone every time is shown in (applies at once); venue.theme is the staff apps' accent
|
||||||
// colour (plan step 4.6: the waiter's phones). All reload bootstrap after saving.
|
// colour (plan step 4.6: the waiter's phones; 6R.20: "The venue's identity" = its first colour, for
|
||||||
|
// the phones and every screen of the terminal). All reload bootstrap after saving.
|
||||||
import { useId, useMemo } from 'react'
|
import { useId, useMemo } from 'react'
|
||||||
import { useAccess } from '@xenia/access'
|
import { useAccess } from '@xenia/access'
|
||||||
import { LANGUAGE_NAMES, useTranslation, useFormat } from '@xenia/i18n'
|
import { LANGUAGE_NAMES, useTranslation, useFormat } from '@xenia/i18n'
|
||||||
import { Select, Spinner } from '@xenia/ui'
|
import { Select, Spinner } from '@xenia/ui'
|
||||||
import { SettingRow, SettingsCard } from './SettingsCard'
|
import { SettingRow, SettingsCard } from './SettingsCard'
|
||||||
import { useSettings } from './useSettings'
|
import { useSettings } from './useSettings'
|
||||||
|
import { useIdentity } from '../../../shell/useIdentity'
|
||||||
import { timeZones } from './timeZones'
|
import { timeZones } from './timeZones'
|
||||||
|
|
||||||
const VENUE_THEMES = ['amber', 'teal', 'blue', 'violet', 'rose'] // packages/ui tokens.css data-venue-theme
|
const VENUE_THEMES = ['amber', 'teal', 'blue', 'violet', 'rose', 'identity'] // packages/ui tokens.css data-venue-theme; identity: venueAccent.js
|
||||||
|
|
||||||
export default function VenueSettings() {
|
export default function VenueSettings() {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
const f = useFormat()
|
const f = useFormat()
|
||||||
const { languages } = useAccess()
|
const { languages } = useAccess()
|
||||||
const s = useSettings()
|
const s = useSettings()
|
||||||
|
const { data: identity } = useIdentity()
|
||||||
const langId = useId()
|
const langId = useId()
|
||||||
const tzId = useId()
|
const tzId = useId()
|
||||||
const themeId = useId()
|
const themeId = useId()
|
||||||
@@ -37,7 +40,8 @@ export default function VenueSettings() {
|
|||||||
onChange={e => s.save('venue.timezone', e.target.value)}
|
onChange={e => s.save('venue.timezone', e.target.value)}
|
||||||
options={zones.map(z => ({ value: z, label: z.replace(/_/g, ' ') }))} />
|
options={zones.map(z => ({ value: z, label: z.replace(/_/g, ' ') }))} />
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
<SettingRow label={t('settings.venue.theme')} htmlFor={themeId} hint={t('settings.venue.themeHint')}>
|
<SettingRow label={t('settings.venue.theme')} htmlFor={themeId} hint={t('settings.venue.themeHint')}
|
||||||
|
warning={s.get('venue.theme') === 'identity' && !identity?.colours?.length ? t('settings.venue.identityNoColour') : undefined}>
|
||||||
<Select id={themeId} value={s.get('venue.theme', 'amber')} disabled={s.saving} data-testid="setting-venue.theme"
|
<Select id={themeId} value={s.get('venue.theme', 'amber')} disabled={s.saving} data-testid="setting-venue.theme"
|
||||||
onChange={e => s.save('venue.theme', e.target.value)}
|
onChange={e => s.save('venue.theme', e.target.value)}
|
||||||
options={VENUE_THEMES.map(v => ({ value: v, label: t(`settings.venue.themes.${v}`) }))} />
|
options={VENUE_THEMES.map(v => ({ value: v, label: t(`settings.venue.themes.${v}`) }))} />
|
||||||
|
|||||||
@@ -315,8 +315,13 @@ function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, on
|
|||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
if (MORE_KINDS.includes(w.kind)) return <MoreBelow w={w} set={set} media={media} onMedia={onMedia} />
|
if (MORE_KINDS.includes(w.kind)) return <MoreBelow w={w} set={set} media={media} onMedia={onMedia} />
|
||||||
if (w.kind === 'logo') {
|
if (w.kind === 'logo') {
|
||||||
return <MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
|
return (
|
||||||
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
|
<div className="grid gap-1">
|
||||||
|
<MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
|
||||||
|
onChange={item => { onMedia(item); set({ media_id: item.id }) }} onRemove={() => set({ media_id: null })} />
|
||||||
|
{!w.media_id && <p className="text-caption text-ink-3">{t('signage.widgets.logoFromIdentity')}</p>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (w.kind === 'message') return <MessageHint />
|
if (w.kind === 'message') return <MessageHint />
|
||||||
if (w.kind === 'weather') {
|
if (w.kind === 'weather') {
|
||||||
|
|||||||
@@ -418,14 +418,16 @@
|
|||||||
"timezone": "Ζώνη ώρας",
|
"timezone": "Ζώνη ώρας",
|
||||||
"timezoneHint": "Όλες οι ώρες εμφανίζονται σε αυτή. Η ώρα εκεί τώρα: {{time}}.",
|
"timezoneHint": "Όλες οι ώρες εμφανίζονται σε αυτή. Η ώρα εκεί τώρα: {{time}}.",
|
||||||
"theme": "Χρώμα",
|
"theme": "Χρώμα",
|
||||||
"themeHint": "Το χρώμα έμφασης στα κινητά των σερβιτόρων.",
|
"themeHint": "Το χρώμα έμφασης στα κινητά των σερβιτόρων· η «Ταυτότητα του καταστήματος» χρωματίζει και το ταμείο, τις οθόνες κουζίνας και τα tablet μενού.",
|
||||||
"themes": {
|
"themes": {
|
||||||
"amber": "Πορτοκαλί",
|
"amber": "Πορτοκαλί",
|
||||||
"teal": "Πετρόλ",
|
"teal": "Πετρόλ",
|
||||||
"blue": "Μπλε",
|
"blue": "Μπλε",
|
||||||
"violet": "Μωβ",
|
"violet": "Μωβ",
|
||||||
"rose": "Ροζ"
|
"rose": "Ροζ",
|
||||||
}
|
"identity": "Η ταυτότητα του καταστήματος (το πρώτο χρώμα της)"
|
||||||
|
},
|
||||||
|
"identityNoColour": "Η ταυτότητα του καταστήματος δεν έχει χρώματα ακόμη (Ρυθμίσεις → Ταυτότητα): τα κινητά μένουν πορτοκαλί και οι οθόνες κρατούν το δικό τους χρώμα μέχρι να αποκτήσει."
|
||||||
},
|
},
|
||||||
"print": {
|
"print": {
|
||||||
"title": "Ειδοποιήσεις εκτύπωσης",
|
"title": "Ειδοποιήσεις εκτύπωσης",
|
||||||
@@ -1138,6 +1140,12 @@
|
|||||||
"deleteTitle": "Διαγραφή «{{name}}»;",
|
"deleteTitle": "Διαγραφή «{{name}}»;",
|
||||||
"deleteBody": "Οι οθόνες που τη δείχνουν επιστρέφουν στην προεπιλεγμένη εμφάνιση ({{name}}). Οι εικόνες της μένουν στη βιβλιοθήκη πολυμέσων.",
|
"deleteBody": "Οι οθόνες που τη δείχνουν επιστρέφουν στην προεπιλεγμένη εμφάνιση ({{name}}). Οι εικόνες της μένουν στη βιβλιοθήκη πολυμέσων.",
|
||||||
"deleted": "Η εμφάνιση διαγράφηκε."
|
"deleted": "Η εμφάνιση διαγράφηκε."
|
||||||
|
},
|
||||||
|
"brand": "Χρώματα και λογότυπο",
|
||||||
|
"brandHint": "Η «Ταυτότητα του καταστήματος» χρησιμοποιεί το πρώτο της χρώμα και, όταν αυτή η εμφάνιση δεν έχει δικό της λογότυπο, το λογότυπό της.",
|
||||||
|
"brands": {
|
||||||
|
"own": "Της εμφάνισης",
|
||||||
|
"identity": "Η ταυτότητα του καταστήματος"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"calls": {
|
"calls": {
|
||||||
@@ -1732,7 +1740,8 @@
|
|||||||
},
|
},
|
||||||
"weatherHours": "Ώρες",
|
"weatherHours": "Ώρες",
|
||||||
"weatherPlace": "Η τοποθεσία",
|
"weatherPlace": "Η τοποθεσία",
|
||||||
"weatherPlaceLabel": "Δείχνει το όνομά της"
|
"weatherPlaceLabel": "Δείχνει το όνομά της",
|
||||||
|
"logoFromIdentity": "Χωρίς εικόνα: εμφανίζεται το λογότυπο του καταστήματος (Ρυθμίσεις → Ταυτότητα)."
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"playlists": "Λίστες",
|
"playlists": "Λίστες",
|
||||||
|
|||||||
@@ -418,14 +418,16 @@
|
|||||||
"timezone": "Time zone",
|
"timezone": "Time zone",
|
||||||
"timezoneHint": "Every time is shown in it. The time there now: {{time}}.",
|
"timezoneHint": "Every time is shown in it. The time there now: {{time}}.",
|
||||||
"theme": "Colour",
|
"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": {
|
"themes": {
|
||||||
"amber": "Amber",
|
"amber": "Amber",
|
||||||
"teal": "Teal",
|
"teal": "Teal",
|
||||||
"blue": "Blue",
|
"blue": "Blue",
|
||||||
"violet": "Violet",
|
"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": {
|
"print": {
|
||||||
"title": "Print alerts",
|
"title": "Print alerts",
|
||||||
@@ -1138,6 +1140,12 @@
|
|||||||
"deleteTitle": "Delete \"{{name}}\"?",
|
"deleteTitle": "Delete \"{{name}}\"?",
|
||||||
"deleteBody": "Displays showing it go back to the default look ({{name}}). Its pictures stay in the media library.",
|
"deleteBody": "Displays showing it go back to the default look ({{name}}). Its pictures stay in the media library.",
|
||||||
"deleted": "Look deleted."
|
"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": {
|
"calls": {
|
||||||
@@ -1732,7 +1740,8 @@
|
|||||||
},
|
},
|
||||||
"weatherHours": "Hours",
|
"weatherHours": "Hours",
|
||||||
"weatherPlace": "The place",
|
"weatherPlace": "The place",
|
||||||
"weatherPlaceLabel": "Show its name"
|
"weatherPlaceLabel": "Show its name",
|
||||||
|
"logoFromIdentity": "No picture chosen: the venue's logo (Settings → Identity) shows."
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"playlists": "Playlists",
|
"playlists": "Playlists",
|
||||||
|
|||||||
@@ -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>
|
<div style={{ width: cq(BOXED[kind][0] * s), height: cq(BOXED[kind][1] * s), containerType: 'size' }} {...CQ_BOX}>{body}</div>
|
||||||
))
|
))
|
||||||
if (w.kind === 'logo') {
|
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 (!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" />
|
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
|
return fit
|
||||||
|
|||||||
@@ -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
|
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]
|
return [...out]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,4 +38,5 @@ export { Stepper } from './components/Stepper.jsx'
|
|||||||
export { ReasonPicker, reasonText } from './components/ReasonPicker.jsx'
|
export { ReasonPicker, reasonText } from './components/ReasonPicker.jsx'
|
||||||
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
|
export { UiLabelsProvider, DEFAULT_LABELS } from './components/labels.js'
|
||||||
export { cx } from './internal/cx.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'
|
export { THEMES, PALETTES, STYLES, THEME_STORAGE_KEY, PALETTE_STORAGE_KEY, STYLE_STORAGE_KEY, applyLook, applyTheme, getStoredLook, getStoredTheme, resolveMode } from './theme.js'
|
||||||
|
|||||||
@@ -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')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;/)
|
||||||
|
})
|
||||||
+13
-3
@@ -6,11 +6,11 @@
|
|||||||
// retries by itself while the server can't be reached (unattended screens)
|
// retries by itself while the server can't be reached (unattended screens)
|
||||||
// Terminal pairing → sign-in → the device's own app, or a "can't run" screen
|
// Terminal pairing → sign-in → the device's own app, or a "can't run" screen
|
||||||
// The screen follows the device, not the URL; only the dev pages have routes.
|
// The screen follows the device, not the URL; only the dev pages have routes.
|
||||||
import { lazy, Suspense } from 'react'
|
import { lazy, Suspense, useEffect } from 'react'
|
||||||
import { BrowserRouter, Route, Routes } from 'react-router-dom'
|
import { BrowserRouter, Route, Routes } from 'react-router-dom'
|
||||||
import { AccessProvider } from '@xenia/access'
|
import { AccessProvider, useAccess } from '@xenia/access'
|
||||||
import { createI18n } from '@xenia/i18n'
|
import { createI18n } from '@xenia/i18n'
|
||||||
import { Spinner, ToastProvider } from '@xenia/ui'
|
import { applyVenueTheme, Spinner, ToastProvider } from '@xenia/ui'
|
||||||
import client from './api/client'
|
import client from './api/client'
|
||||||
import DeviceProvider from './device/DeviceProvider'
|
import DeviceProvider from './device/DeviceProvider'
|
||||||
import { useDevice } from './device/context'
|
import { useDevice } from './device/context'
|
||||||
@@ -30,12 +30,22 @@ function Root() {
|
|||||||
return (
|
return (
|
||||||
<AccessProvider client={client} token={sessionKey} i18n={i18n} loading={loading} autoRetryMs={AUTO_RETRY_MS}>
|
<AccessProvider client={client} token={sessionKey} i18n={i18n} loading={loading} autoRetryMs={AUTO_RETRY_MS}>
|
||||||
<ToastProvider placement="bottom-center">
|
<ToastProvider placement="bottom-center">
|
||||||
|
<VenueAccent />
|
||||||
<Terminal />
|
<Terminal />
|
||||||
</ToastProvider>
|
</ToastProvider>
|
||||||
</AccessProvider>
|
</AccessProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The venue's own colour as the accent of every screen when the venue chose it (6R.20, Settings →
|
||||||
|
* Venue → "The venue's identity"); otherwise the screens keep their own accent. */
|
||||||
|
function VenueAccent() {
|
||||||
|
const venue = useAccess()?.venue
|
||||||
|
const colour = venue?.theme === 'identity' ? venue?.identity?.colour : null
|
||||||
|
useEffect(() => { applyVenueTheme(colour ? 'identity' : null, colour) }, [colour])
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// change re-reads it (`display.settings`). GET /api/display/state on start and reconnect.
|
// change re-reads it (`display.settings`). GET /api/display/state on start and reconnect.
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||||
import { applyTheme, getStoredTheme } from '@xenia/ui'
|
import { applyTheme, applyVenueTheme, getStoredTheme } from '@xenia/ui'
|
||||||
import { QrCode } from '@xenia/ui/qr'
|
import { QrCode } from '@xenia/ui/qr'
|
||||||
import client from '../../api/client'
|
import client from '../../api/client'
|
||||||
import { useLiveEvent, useLiveEvents } from '../../device/context'
|
import { useLiveEvent, useLiveEvents } from '../../device/context'
|
||||||
@@ -45,6 +45,13 @@ export default function CustomerDisplayApp() {
|
|||||||
applyTheme(theme)
|
applyTheme(theme)
|
||||||
return () => { applyTheme(getStoredTheme()) }
|
return () => { applyTheme(getStoredTheme()) }
|
||||||
}, [theme])
|
}, [theme])
|
||||||
|
// a look on the venue's identity (6R.20): its colour is the accent while the display shows it
|
||||||
|
const accent = data?.idle?.accent
|
||||||
|
useEffect(() => {
|
||||||
|
if (!accent) return undefined
|
||||||
|
applyVenueTheme('identity', accent)
|
||||||
|
return () => { applyVenueTheme(null) }
|
||||||
|
}, [accent])
|
||||||
|
|
||||||
if (!data) return <main className="absolute inset-0 bg-canvas" data-testid="app-customer_display" />
|
if (!data) return <main className="absolute inset-0 bg-canvas" data-testid="app-customer_display" />
|
||||||
const view = viewOf(state, receivedAt, now)
|
const view = viewOf(state, receivedAt, now)
|
||||||
|
|||||||
@@ -109,6 +109,13 @@ export default function SignageApp() {
|
|||||||
}, [calib])
|
}, [calib])
|
||||||
|
|
||||||
const kept = useKeptMedia(useMemo(() => mediaUrls(data), [data]))
|
const kept = useKeptMedia(useMemo(() => mediaUrls(data), [data]))
|
||||||
|
// the venue's logos from the TV's kept copies too (a logo widget without its own picture, 6R.20)
|
||||||
|
const venue = useMemo(() => {
|
||||||
|
const v = data?.venue
|
||||||
|
const logos = v?.identity?.logos
|
||||||
|
if (!logos) return v
|
||||||
|
return { ...v, identity: { ...v.identity, logos: Object.fromEntries(Object.entries(logos).map(([k, l]) => [k, l && { ...l, card: kept[l.card] || l.card }])) } }
|
||||||
|
}, [data, kept])
|
||||||
const playlist = playlistNow(data, now)
|
const playlist = playlistNow(data, now)
|
||||||
const tz = data?.schedule?.timezone
|
const tz = data?.schedule?.timezone
|
||||||
const screen = data?.screen
|
const screen = data?.screen
|
||||||
@@ -122,7 +129,7 @@ export default function SignageApp() {
|
|||||||
data-testid="signage-area" data-area={`${pic.left},${pic.top},${pic.width},${pic.height}`}>
|
data-testid="signage-area" data-area={`${pic.left},${pic.top},${pic.width},${pic.height}`}>
|
||||||
<div style={frameStyle(screen?.rotation, pic)} {...CQ_BOX} data-testid="signage-frame" data-rotation={screen?.rotation ?? 0}>
|
<div style={frameStyle(screen?.rotation, pic)} {...CQ_BOX} data-testid="signage-frame" data-rotation={screen?.rotation ?? 0}>
|
||||||
{playlist?.slides?.length
|
{playlist?.slides?.length
|
||||||
? <Player key={playlist.id} playlist={playlist} kept={kept} tz={tz} venue={data?.venue} now={now} frame={frame} fit={screen?.fit} />
|
? <Player key={playlist.id} playlist={playlist} kept={kept} tz={tz} venue={venue} now={now} frame={frame} fit={screen?.fit} />
|
||||||
: <Empty text={data ? t('signage.nothing') : t('signage.starting')} />}
|
: <Empty text={data ? t('signage.nothing') : t('signage.starting')} />}
|
||||||
</div>
|
</div>
|
||||||
{calibrating && <Calibration pic={pic} name={screen?.name} />}
|
{calibrating && <Calibration pic={pic} name={screen?.name} />}
|
||||||
|
|||||||
+13
-2
@@ -586,11 +586,13 @@ try {
|
|||||||
// ── 6R.14 / 6R.15: the identity and opening hours feed the new widgets on the TV ──
|
// ── 6R.14 / 6R.15: the identity and opening hours feed the new widgets on the TV ──
|
||||||
const ident = await api('GET', '/api/identity', { token: boss })
|
const ident = await api('GET', '/api/identity', { token: boss })
|
||||||
await api('PUT', '/api/identity', { token: boss, body: { name: ident.name || 'Taverna', wifi: { ssid: 'Xenia Guests', password: 'kalimera', security: 'WPA' },
|
await api('PUT', '/api/identity', { token: boss, body: { name: ident.name || 'Taverna', wifi: { ssid: 'Xenia Guests', password: 'kalimera', security: 'WPA' },
|
||||||
contact: { phone: '2310 123456', instagram: '@xenia' } } })
|
contact: { phone: '2310 123456', instagram: '@xenia' }, colours: [{ name: 'Main', colour: '#1e3a8a' }], logos: { main: photo.id } } })
|
||||||
|
await api('PUT', '/api/settings/venue.theme', { token: boss, body: { value: 'identity' } })
|
||||||
await api('PUT', '/api/signage/reviews', { token: boss, body: { reviews: [{ name: 'Maria', stars: 5, text: 'Best octopus on the island' }, { name: 'Bob', stars: 2, text: 'Meh' }] } })
|
await api('PUT', '/api/signage/reviews', { token: boss, body: { reviews: [{ name: 'Maria', stars: 5, text: 'Best octopus on the island' }, { name: 'Bob', stars: 2, text: 'Meh' }] } })
|
||||||
await api('PUT', '/api/identity/hours', { token: boss, body: { days: [[{ from: '12:00', to: '23:00' }], [], [], [], [], [], []] } })
|
await api('PUT', '/api/identity/hours', { token: boss, body: { days: [[{ from: '12:00', to: '23:00' }], [], [], [], [], [], []] } })
|
||||||
const dishes = await api('POST', '/api/media/folders', { token: boss, body: { name: 'Dishes' } })
|
const dishes = await api('POST', '/api/media/folders', { token: boss, body: { name: 'Dishes' } })
|
||||||
await api('POST', '/api/media/move', { token: boss, body: { ids: [photo.id], folder_id: dishes.id } })
|
await api('POST', '/api/media/move', { token: boss, body: { ids: [photo.id], folder_id: dishes.id } })
|
||||||
|
await api('PUT', '/api/signage/performance', { token: boss, body: { max_widgets: 20 } }) // this slide shows them all at once
|
||||||
const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } })
|
const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } })
|
||||||
await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [
|
await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [
|
||||||
{ kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' },
|
{ kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' },
|
||||||
@@ -600,7 +602,8 @@ try {
|
|||||||
{ kind: 'reviews', position: 'custom', box: { x: 30, y: 40, w: 40, h: 25 } },
|
{ kind: 'reviews', position: 'custom', box: { x: 30, y: 40, w: 40, h: 25 } },
|
||||||
{ kind: 'gallery', position: 'custom', box: { x: 75, y: 30, w: 20, h: 20 }, gallery_source: 'folder', gallery_folder: dishes.id },
|
{ kind: 'gallery', position: 'custom', box: { x: 75, y: 30, w: 20, h: 20 }, gallery_source: 'folder', gallery_folder: dishes.id },
|
||||||
{ kind: 'date', position: 'custom', box: { x: 5, y: 80, w: 20, h: 6 }, date_format: 'numeric', date_separator: '.' },
|
{ kind: 'date', position: 'custom', box: { x: 5, y: 80, w: 20, h: 6 }, date_format: 'numeric', date_separator: '.' },
|
||||||
{ kind: 'clock', position: 'custom', box: { x: 30, y: 80, w: 20, h: 6 }, clock_format: '12', clock_separator: '.' }] } } })
|
{ kind: 'clock', position: 'custom', box: { x: 30, y: 80, w: 20, h: 6 }, clock_format: '12', clock_separator: '.' },
|
||||||
|
{ kind: 'logo', position: 'bottom-center' }] } } })
|
||||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } })
|
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } })
|
||||||
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'gallery'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
|
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'gallery'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
|
||||||
r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV',
|
r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV',
|
||||||
@@ -615,6 +618,14 @@ try {
|
|||||||
const dateTxt = await tv.getByTestId('signage-w-date').textContent()
|
const dateTxt = await tv.getByTestId('signage-w-date').textContent()
|
||||||
const clockTxt = await tv.getByTestId('signage-w-clock').textContent()
|
const clockTxt = await tv.getByTestId('signage-w-clock').textContent()
|
||||||
r.check('6R.17: a numeric date with dots, a 12-hour clock with a dot', /^\d\d\.\d\d\.\d{4}$/.test(dateTxt) && /^\d{1,2}\.\d\d\s?(am|pm|AM|PM|π\.μ\.|μ\.μ\.)$/i.test(clockTxt), `${dateTxt} | ${clockTxt}`)
|
r.check('6R.17: a numeric date with dots, a 12-hour clock with a dot', /^\d\d\.\d\d\.\d{4}$/.test(dateTxt) && /^\d{1,2}\.\d\d\s?(am|pm|AM|PM|π\.μ\.|μ\.μ\.)$/i.test(clockTxt), `${dateTxt} | ${clockTxt}`)
|
||||||
|
r.check("6R.20: a logo widget without its own picture shows the venue's logo", await waitFor(async () => (await tv.getByTestId('signage-w-logo').count()) === 1 || null, 10_000, 300) === true)
|
||||||
|
await tv.reload()
|
||||||
|
const accent = await waitFor(async () => {
|
||||||
|
const a = await tv.evaluate(() => [document.documentElement.getAttribute('data-venue-theme'), getComputedStyle(document.documentElement).getPropertyValue('--x-accent-rgb').trim()])
|
||||||
|
return a[0] === 'identity' ? a : null
|
||||||
|
}, 15_000, 300)
|
||||||
|
r.check('6R.20: the venue identity colour is the accent of the screens (venue.theme identity)', accent?.[1] === '30 58 138', JSON.stringify(accent))
|
||||||
|
await api('PUT', '/api/settings/venue.theme', { token: boss, body: { value: 'amber' } })
|
||||||
r.check('6R.19: a review typed in by hand shows (the 2-star one is left out)', await tv.getByTestId('signage-w-reviews').getAttribute('data-count') === '1'
|
r.check('6R.19: a review typed in by hand shows (the 2-star one is left out)', await tv.getByTestId('signage-w-reviews').getAttribute('data-count') === '1'
|
||||||
&& (await tv.getByTestId('signage-w-reviews').textContent()).includes('Best octopus'))
|
&& (await tv.getByTestId('signage-w-reviews').textContent()).includes('Best octopus'))
|
||||||
r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim()))
|
r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim()))
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { i18n } from './i18n'
|
|||||||
import useAuthStore from './store/authStore'
|
import useAuthStore from './store/authStore'
|
||||||
import useShiftStore from './store/shiftStore'
|
import useShiftStore from './store/shiftStore'
|
||||||
import useThemeStore from './store/themeStore'
|
import useThemeStore from './store/themeStore'
|
||||||
|
import { applyVenueTheme } from '@xenia/ui'
|
||||||
import useTableColourStore from './store/tableColourStore'
|
import useTableColourStore from './store/tableColourStore'
|
||||||
import useConnectionStore from './store/connectionStore'
|
import useConnectionStore from './store/connectionStore'
|
||||||
import useWaiterFavoritesStore from './store/waiterFavoritesStore'
|
import useWaiterFavoritesStore from './store/waiterFavoritesStore'
|
||||||
@@ -333,16 +334,19 @@ function OfflineListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Light / dark from the user menu (per phone), the accent colour from the venue (bootstrap
|
// Light / dark from the user menu (per phone), the accent colour from the venue (bootstrap
|
||||||
// venue.theme, Settings → Venue; plan step 4.6). The waiter's colours are @xenia/ui tokens.
|
// venue.theme, Settings → Venue; plan step 4.6; "identity": the venue's own colour, 6R.20). The
|
||||||
|
// waiter's colours are @xenia/ui tokens.
|
||||||
function ThemeApplier() {
|
function ThemeApplier() {
|
||||||
const dark = useThemeStore(s => s.dark)
|
const dark = useThemeStore(s => s.dark)
|
||||||
const venueTheme = useAccess()?.venue?.theme || 'amber'
|
const venue = useAccess()?.venue
|
||||||
|
const venueTheme = venue?.theme || 'amber'
|
||||||
|
const colour = venue?.identity?.colour
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.documentElement.setAttribute('data-theme', dark ? 'dark' : 'light')
|
document.documentElement.setAttribute('data-theme', dark ? 'dark' : 'light')
|
||||||
}, [dark])
|
}, [dark])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.documentElement.setAttribute('data-venue-theme', venueTheme)
|
applyVenueTheme(venueTheme === 'identity' && !colour ? 'amber' : venueTheme, colour)
|
||||||
}, [venueTheme])
|
}, [venueTheme, colour])
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user