refactor: @xenia/signage: the slides and the player's logic shared by the terminal and the manager (platform-v2 step 5.6a)
The signage slides (SlideView, TextSlide, MenuSlide, Widgets) and the pure logic (schedule pick, slide windows, menu pages) move from the terminal into packages/signage, so the manager's previews draw a slide exactly as the TV does. Sizes are container units (cqmin) instead of viewport units: a slide draws inside any box with container-type: size (frameStyle sets it on the TV). Tests move with it (10). Dockerfiles copy its package.json; both apps' Tailwind content include it; run-all runs its tests. Signage e2e and the compose stack passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ COPY packages/ui/package.json packages/ui/
|
|||||||
COPY packages/i18n/package.json packages/i18n/
|
COPY packages/i18n/package.json packages/i18n/
|
||||||
COPY packages/api/package.json packages/api/
|
COPY packages/api/package.json packages/api/
|
||||||
COPY packages/access/package.json packages/access/
|
COPY packages/access/package.json packages/access/
|
||||||
|
COPY packages/signage/package.json packages/signage/
|
||||||
COPY waiter_pwa/package.json waiter_pwa/
|
COPY waiter_pwa/package.json waiter_pwa/
|
||||||
COPY manager_dashboard/package.json manager_dashboard/
|
COPY manager_dashboard/package.json manager_dashboard/
|
||||||
COPY terminal/package.json terminal/
|
COPY terminal/package.json terminal/
|
||||||
|
|||||||
@@ -8,13 +8,14 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test": "node --test \"tests/*.test.mjs\"",
|
"test": "node --test \"tests/*.test.mjs\"",
|
||||||
"lint": "eslint eslint.config.js tests src/shell src/live src/pages/platform src/pages/online src/pages/media src/pages/staff src/pages/Settings/sections src/pages/LoginPage.jsx src/components/NotificationBell.jsx src/components/PhoneListener.jsx src/pages/PhonePage.jsx src/store/phoneStore.js src/components/UserMenuButton.jsx src/pages/reports/operations/LogsPanel.jsx src/api/client.js src/store/authStore.js src/main.jsx"
|
"lint": "eslint eslint.config.js tests src/shell src/live src/pages/platform src/pages/online src/pages/media src/pages/signage src/pages/staff src/pages/Settings/sections src/pages/LoginPage.jsx src/components/NotificationBell.jsx src/components/PhoneListener.jsx src/pages/PhonePage.jsx src/store/phoneStore.js src/components/UserMenuButton.jsx src/pages/reports/operations/LogsPanel.jsx src/api/client.js src/store/authStore.js src/main.jsx"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.107.1",
|
"@tanstack/react-query": "^5.107.1",
|
||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import xenia from '@xenia/ui/tailwind-preset'
|
|||||||
export default {
|
export default {
|
||||||
// Shared design tokens (bg-surface, text-ink-2, rounded-control…); adds names only
|
// Shared design tokens (bg-surface, text-ink-2, rounded-control…); adds names only
|
||||||
presets: [xenia],
|
presets: [xenia],
|
||||||
content: ['./index.html', './src/**/*.{js,jsx}'],
|
content: ['./index.html', './src/**/*.{js,jsx}', '../packages/signage/src/**/*.{js,jsx}'], // signage slides use a few utilities (5.6a)
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
fontFamily: {
|
fontFamily: {
|
||||||
|
|||||||
Generated
+18
@@ -20,6 +20,7 @@
|
|||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
@@ -3219,6 +3220,10 @@
|
|||||||
"resolved": "packages/i18n",
|
"resolved": "packages/i18n",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@xenia/signage": {
|
||||||
|
"resolved": "packages/signage",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/@xenia/ui": {
|
"node_modules/@xenia/ui": {
|
||||||
"resolved": "packages/ui",
|
"resolved": "packages/ui",
|
||||||
"link": true
|
"link": true
|
||||||
@@ -9572,6 +9577,18 @@
|
|||||||
"react": "^19.0.0"
|
"react": "^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"packages/signage": {
|
||||||
|
"name": "@xenia/signage",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"lucide-react": "^1.73.0",
|
||||||
|
"qrcode.react": "^4.2.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"packages/ui": {
|
"packages/ui": {
|
||||||
"name": "@xenia/ui",
|
"name": "@xenia/ui",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
@@ -9586,6 +9603,7 @@
|
|||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "@xenia/signage",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"description": "Signage slides as the TVs draw them, and the player's pure logic (schedule pick, slide windows, menu pages): one implementation for the terminal's player and the manager's previews (plan steps 5.5a-5.6a).",
|
||||||
|
"main": "src/index.js",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"lucide-react": "^1.73.0",
|
||||||
|
"qrcode.react": "^4.2.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "node --test \"tests/*.test.mjs\""
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^19.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
// One slide as a TV shows it (plan step 5.6a): picture, video, text or menu board. Used by the
|
||||||
|
// player (terminal) and the manager's previews. Needs a parent with `container-type: size`.
|
||||||
|
// media(id) → { src, url, kind, width, height } | null (src: the address or the TV's kept copy)
|
||||||
|
import { useEffect, useRef } from 'react'
|
||||||
|
import { MenuSlide, TextSlide } from './Slides.jsx'
|
||||||
|
|
||||||
|
export function SlideView({ slide, media, venue, now, pages, page, onEnded, playing = true }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{slide.kind === 'image' && <ImageSlide content={slide.content || {}} media={media} />}
|
||||||
|
{slide.kind === 'video' && <VideoSlide slide={slide} media={media} onEnded={onEnded} playing={playing} />}
|
||||||
|
{slide.kind === 'text' && <TextSlide content={slide.content || {}} media={media} venue={venue} now={now} />}
|
||||||
|
{slide.kind === 'menu' && <MenuSlide slide={slide} media={media} venue={venue} now={now} pages={pages || []} page={page || 0} />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ImageSlide({ content, media }) {
|
||||||
|
const m = content.media_id ? media(content.media_id) : null
|
||||||
|
return (
|
||||||
|
<div className="absolute inset-0" style={{ background: content.background_colour || '#000' }}>
|
||||||
|
{m && <img src={m.src} alt="" className="w-full h-full" style={{ objectFit: content.fit || 'cover' }} data-testid="signage-image" />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function VideoSlide({ slide, media, onEnded, playing }) {
|
||||||
|
const c = slide.content || {}
|
||||||
|
const m = c.media_id ? media(c.media_id) : null
|
||||||
|
const ref = useRef(null)
|
||||||
|
useEffect(() => {
|
||||||
|
const v = ref.current
|
||||||
|
if (!v) return
|
||||||
|
if (playing) v.play?.().catch(() => {})
|
||||||
|
else v.pause?.()
|
||||||
|
}, [m?.src, playing])
|
||||||
|
return (
|
||||||
|
<div className="absolute inset-0" style={{ background: c.background_colour || '#000' }}>
|
||||||
|
{m && <video ref={ref} src={m.src} autoPlay={playing} muted={c.muted !== false || !playing} playsInline loop={!slide.video_to_end}
|
||||||
|
onEnded={slide.video_to_end ? onEnded : undefined} onError={slide.video_to_end ? onEnded : undefined}
|
||||||
|
className="w-full h-full" style={{ objectFit: c.fit || 'cover' }} data-testid="signage-video" />}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Text and menu slides of the signage player, and their widgets (plan steps 5.5a, 5.5b). Colours,
|
// Text and menu slides of the signage player, and their widgets (plan steps 5.5a, 5.5b). Colours,
|
||||||
// fonts and sizes here are the venue's own choices for its TV (slide content = data, CS-16), so
|
// fonts and sizes here are the venue's own choices for its TV (slide content = data, CS-16), so
|
||||||
// they are inline styles, not tokens. Sizes scale with the screen (vmin), so a slide looks the
|
// they are inline styles, not tokens. Sizes scale with the screen (cqmin), so a slide looks the
|
||||||
// same on any TV.
|
// same on any TV.
|
||||||
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
||||||
import { QRCodeSVG } from 'qrcode.react'
|
import { QRCodeSVG } from 'qrcode.react'
|
||||||
@@ -28,10 +28,10 @@ export function TextSlide({ content: c, media, venue, now }) {
|
|||||||
<Background bg={c.background} media={media} />
|
<Background bg={c.background} media={media} />
|
||||||
<div className="absolute inset-0 flex flex-col" style={{
|
<div className="absolute inset-0 flex flex-col" style={{
|
||||||
justifyContent: JUSTIFY[c.vertical] || 'center', textAlign: c.align || 'center',
|
justifyContent: JUSTIFY[c.vertical] || 'center', textAlign: c.align || 'center',
|
||||||
padding: `${hasBar(c, 'top-bar') ? 14 : 8}vmin 8vmin ${hasBar(c, 'bottom-bar') ? 14 : 8}vmin`, gap: `${3 * scale}vmin`,
|
padding: `${hasBar(c, 'top-bar') ? 14 : 8}cqmin 8cqmin ${hasBar(c, 'bottom-bar') ? 14 : 8}cqmin`, gap: `${3 * scale}cqmin`,
|
||||||
}}>
|
}}>
|
||||||
{c.title && <h1 style={{ fontSize: `${9 * scale}vmin`, lineHeight: 1.1, fontWeight: 800, margin: 0 }} data-testid="signage-title">{c.title}</h1>}
|
{c.title && <h1 style={{ fontSize: `${9 * scale}cqmin`, lineHeight: 1.1, fontWeight: 800, margin: 0 }} data-testid="signage-title">{c.title}</h1>}
|
||||||
{c.body && <p style={{ fontSize: `${4.5 * scale}vmin`, lineHeight: 1.35, margin: 0, whiteSpace: 'pre-line' }} data-testid="signage-body">{c.body}</p>}
|
{c.body && <p style={{ fontSize: `${4.5 * scale}cqmin`, lineHeight: 1.35, margin: 0, whiteSpace: 'pre-line' }} data-testid="signage-body">{c.body}</p>}
|
||||||
</div>
|
</div>
|
||||||
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} colour={c.text_colour} />
|
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} colour={c.text_colour} />
|
||||||
</div>
|
</div>
|
||||||
@@ -50,32 +50,32 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
|
|||||||
<div className="absolute inset-0" style={{ color: c.text_colour || '#fff', fontFamily: FONTS[c.font] || FONTS.sans }}>
|
<div className="absolute inset-0" style={{ color: c.text_colour || '#fff', fontFamily: FONTS[c.font] || FONTS.sans }}>
|
||||||
<Background bg={c.background} media={media} />
|
<Background bg={c.background} media={media} />
|
||||||
<div className="absolute inset-0 flex flex-col"
|
<div className="absolute inset-0 flex flex-col"
|
||||||
style={{ padding: `${hasBar(c, 'top-bar') ? 12 : 5}vmin 5vmin ${hasBar(c, 'bottom-bar') ? 12 : 5}vmin` }}
|
style={{ padding: `${hasBar(c, 'top-bar') ? 12 : 5}cqmin 5cqmin ${hasBar(c, 'bottom-bar') ? 12 : 5}cqmin` }}
|
||||||
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
|
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
|
||||||
{c.title && <h1 style={{ fontSize: `${7 * scale}vmin`, fontWeight: 800, margin: '0 0 2vmin', color: accent, lineHeight: 1.1 }}>{c.title}</h1>}
|
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: accent, lineHeight: 1.1 }}>{c.title}</h1>}
|
||||||
<div style={{ columnCount: c.columns || 2, columnGap: '5vmin', fontSize: `${3.2 * scale}vmin`, flex: 1, columnFill: 'auto' }}>
|
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, columnFill: 'auto' }}>
|
||||||
{groups.map((g, i) => (
|
{groups.map((g, i) => (
|
||||||
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '1.6vmin' }}>
|
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '1.6cqmin' }}>
|
||||||
{g.category && c.category_titles !== false && (
|
{g.category && c.category_titles !== false && (
|
||||||
<h2 style={{ fontSize: '1.15em', color: accent, margin: '0 0 0.6vmin', fontWeight: 700, breakAfter: 'avoid' }}
|
<h2 style={{ fontSize: '1.15em', color: accent, margin: '0 0 0.6cqmin', fontWeight: 700, breakAfter: 'avoid' }}
|
||||||
data-testid="signage-menu-heading">{g.category.name}</h2>
|
data-testid="signage-menu-heading">{g.category.name}</h2>
|
||||||
)}
|
)}
|
||||||
{g.items.map(it => (
|
{g.items.map(it => (
|
||||||
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
|
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
|
||||||
style={{ display: 'flex', alignItems: 'center', gap: '1.5vmin', breakInside: 'avoid', padding: '0.5vmin 0',
|
style={{ display: 'flex', alignItems: 'center', gap: '1.5cqmin', breakInside: 'avoid', padding: '0.5cqmin 0',
|
||||||
opacity: it.available ? 1 : 0.5 }}>
|
opacity: it.available ? 1 : 0.5 }}>
|
||||||
{c.show_photos && (it.image
|
{c.show_photos && (it.image
|
||||||
? <img src={it.image} alt="" style={{ width: '7vmin', height: '7vmin', objectFit: 'cover', borderRadius: '1vmin', flexShrink: 0 }} />
|
? <img src={it.image} alt="" style={{ width: '7cqmin', height: '7cqmin', objectFit: 'cover', borderRadius: '1cqmin', flexShrink: 0 }} />
|
||||||
: <span style={{ width: '7vmin', height: '7vmin', flexShrink: 0 }} />)}
|
: <span style={{ width: '7cqmin', height: '7cqmin', flexShrink: 0 }} />)}
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: '1vmin' }}>
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: '1cqmin' }}>
|
||||||
<span style={{ textDecoration: it.available ? 'none' : 'line-through', fontWeight: 600 }}>{it.name}</span>
|
<span style={{ textDecoration: it.available ? 'none' : 'line-through', fontWeight: 600 }}>{it.name}</span>
|
||||||
{it.badge && (
|
{it.badge && (
|
||||||
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.2vmin 0.9vmin', borderRadius: '99vmin',
|
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.2cqmin 0.9cqmin', borderRadius: '99cqmin',
|
||||||
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap' }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap' }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
||||||
)}
|
)}
|
||||||
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
||||||
<span style={{ flex: 1, borderBottom: '0.25vmin dotted currentColor', opacity: 0.35, minWidth: '2vmin' }} />
|
<span style={{ flex: 1, borderBottom: '0.25cqmin dotted currentColor', opacity: 0.35, minWidth: '2cqmin' }} />
|
||||||
{it.price != null && <span style={{ color: accent, fontVariantNumeric: 'tabular-nums', fontWeight: 700, whiteSpace: 'nowrap' }}
|
{it.price != null && <span style={{ color: accent, fontVariantNumeric: 'tabular-nums', fontWeight: 700, whiteSpace: 'nowrap' }}
|
||||||
data-testid="signage-menu-price">{formatMoney(it.price)}</span>}
|
data-testid="signage-menu-price">{formatMoney(it.price)}</span>}
|
||||||
</div>
|
</div>
|
||||||
@@ -87,8 +87,8 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{pages.length > 1 && (
|
{pages.length > 1 && (
|
||||||
<div style={{ display: 'flex', gap: '1vmin', justifyContent: 'center', paddingTop: '1vmin' }} aria-hidden="true">
|
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
||||||
{pages.map((_, i) => <span key={i} style={{ width: '1.2vmin', height: '1.2vmin', borderRadius: '50%', background: i === page ? accent : 'currentColor', opacity: i === page ? 1 : 0.3 }} />)}
|
{pages.map((_, i) => <span key={i} style={{ width: '1.2cqmin', height: '1.2cqmin', borderRadius: '50%', background: i === page ? accent : 'currentColor', opacity: i === page ? 1 : 0.3 }} />)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -101,12 +101,12 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
|
|||||||
|
|
||||||
const SIZE = { small: 0.75, medium: 1, large: 1.4 }
|
const SIZE = { small: 0.75, medium: 1, large: 1.4 }
|
||||||
const CORNER = {
|
const CORNER = {
|
||||||
'top-left': { top: '3vmin', left: '3vmin', alignItems: 'flex-start' },
|
'top-left': { top: '3cqmin', left: '3cqmin', alignItems: 'flex-start' },
|
||||||
'top-center': { top: '3vmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
'top-center': { top: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
||||||
'top-right': { top: '3vmin', right: '3vmin', alignItems: 'flex-end' },
|
'top-right': { top: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
||||||
'bottom-left': { bottom: '3vmin', left: '3vmin', alignItems: 'flex-start' },
|
'bottom-left': { bottom: '3cqmin', left: '3cqmin', alignItems: 'flex-start' },
|
||||||
'bottom-center': { bottom: '3vmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
'bottom-center': { bottom: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
||||||
'bottom-right': { bottom: '3vmin', right: '3vmin', alignItems: 'flex-end' },
|
'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The widgets of a slide, in their corners and bars. One that has nothing to show is left out. */
|
/** The widgets of a slide, in their corners and bars. One that has nothing to show is left out. */
|
||||||
@@ -118,8 +118,8 @@ export function Widgets({ widgets, media, venue, now, colour }) {
|
|||||||
<>
|
<>
|
||||||
{bars.map(([where, pos]) => bar(where).length > 0 && (
|
{bars.map(([where, pos]) => bar(where).length > 0 && (
|
||||||
<div key={where} className="absolute inset-x-0" data-testid={`signage-${where}`}
|
<div key={where} className="absolute inset-x-0" data-testid={`signage-${where}`}
|
||||||
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '3vmin', padding: '2vmin 4vmin',
|
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '3cqmin', padding: '2cqmin 4cqmin',
|
||||||
background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: '9vmin' }}>
|
background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: '9cqmin' }}>
|
||||||
{bar(where).map((w, i) => <Widget key={i} w={w} media={media} venue={venue} now={now} />)}
|
{bar(where).map((w, i) => <Widget key={i} w={w} media={media} venue={venue} now={now} />)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -137,25 +137,25 @@ const ICONS = { sun: Sun, moon: Moon, 'cloud-sun': CloudSun, 'cloud-moon': Cloud
|
|||||||
function Widget({ w, media, venue, now }) {
|
function Widget({ w, media, venue, now }) {
|
||||||
const { formatDate, formatTime } = useFormat()
|
const { formatDate, formatTime } = useFormat()
|
||||||
const s = SIZE[w.size] || 1
|
const s = SIZE[w.size] || 1
|
||||||
const text = { fontSize: `${3.4 * s}vmin`, fontWeight: 700, lineHeight: 1.15, textShadow: '0 0.2vmin 0.8vmin rgba(0,0,0,0.35)' }
|
const text = { fontSize: `${3.4 * s}cqmin`, fontWeight: 700, lineHeight: 1.15, textShadow: '0 0.2cqmin 0.8cqmin rgba(0,0,0,0.35)' }
|
||||||
if (w.kind === 'logo') {
|
if (w.kind === 'logo') {
|
||||||
const m = media(w.media_id)
|
const m = media(w.media_id)
|
||||||
return m ? <img src={m.src} alt="" style={{ height: `${9 * s}vmin`, maxWidth: `${30 * s}vmin`, objectFit: 'contain' }} data-testid="signage-w-logo" /> : null
|
return m ? <img src={m.src} alt="" style={{ height: `${9 * s}cqmin`, maxWidth: `${30 * s}cqmin`, objectFit: 'contain' }} data-testid="signage-w-logo" /> : null
|
||||||
}
|
}
|
||||||
if (w.kind === 'name') return venue?.name ? <span style={{ ...text, fontSize: `${4.2 * s}vmin` }} data-testid="signage-w-name">{venue.name}</span> : null
|
if (w.kind === 'name') return venue?.name ? <span style={{ ...text, fontSize: `${4.2 * s}cqmin` }} data-testid="signage-w-name">{venue.name}</span> : null
|
||||||
if (w.kind === 'date') return <span style={text} data-testid="signage-w-date">{formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong')}</span>
|
if (w.kind === 'date') return <span style={text} data-testid="signage-w-date">{formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong')}</span>
|
||||||
if (w.kind === 'clock') return <span style={{ ...text, fontSize: `${4.6 * s}vmin`, fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">{formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')}</span>
|
if (w.kind === 'clock') return <span style={{ ...text, fontSize: `${4.6 * s}cqmin`, fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">{formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')}</span>
|
||||||
if (w.kind === 'message') {
|
if (w.kind === 'message') {
|
||||||
const msg = w.text || venue?.message
|
const msg = w.text || venue?.message
|
||||||
return msg ? <span style={{ ...text, fontWeight: 600 }} data-testid="signage-w-message">{msg}</span> : null
|
return msg ? <span style={{ ...text, fontWeight: 600 }} data-testid="signage-w-message">{msg}</span> : null
|
||||||
}
|
}
|
||||||
if (w.kind === 'qr') {
|
if (w.kind === 'qr') {
|
||||||
return w.link ? (
|
return w.link ? (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '0.8vmin' }} data-testid="signage-w-qr" data-link={w.link}>
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '0.8cqmin' }} data-testid="signage-w-qr" data-link={w.link}>
|
||||||
<div style={{ background: '#fff', padding: '1vmin', borderRadius: '1vmin', lineHeight: 0 }}>
|
<div style={{ background: '#fff', padding: '1cqmin', borderRadius: '1cqmin', lineHeight: 0 }}>
|
||||||
<QRCodeSVG value={w.link} size={256} style={{ width: `${14 * s}vmin`, height: `${14 * s}vmin` }} />
|
<QRCodeSVG value={w.link} size={256} style={{ width: `${14 * s}cqmin`, height: `${14 * s}cqmin` }} />
|
||||||
</div>
|
</div>
|
||||||
{w.qr_caption && <span style={{ ...text, fontSize: `${2.4 * s}vmin` }}>{w.qr_caption}</span>}
|
{w.qr_caption && <span style={{ ...text, fontSize: `${2.4 * s}cqmin` }}>{w.qr_caption}</span>}
|
||||||
</div>
|
</div>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
@@ -165,14 +165,14 @@ function Widget({ w, media, venue, now }) {
|
|||||||
const Icon = ICONS[weatherIcon(wx.code, wx.is_day)] || Cloud
|
const Icon = ICONS[weatherIcon(wx.code, wx.is_day)] || Cloud
|
||||||
const deg = wx.units === 'fahrenheit' ? '°F' : '°C'
|
const deg = wx.units === 'fahrenheit' ? '°F' : '°C'
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '1.5vmin' }} data-testid="signage-w-weather">
|
<div style={{ display: 'flex', alignItems: 'center', gap: '1.5cqmin' }} data-testid="signage-w-weather">
|
||||||
<Icon style={{ width: `${6 * s}vmin`, height: `${6 * s}vmin` }} aria-hidden="true" />
|
<Icon style={{ width: `${6 * s}cqmin`, height: `${6 * s}cqmin` }} aria-hidden="true" />
|
||||||
<span style={{ ...text, fontSize: `${4.4 * s}vmin` }}>{Math.round(wx.temperature)}{deg}</span>
|
<span style={{ ...text, fontSize: `${4.4 * s}cqmin` }}>{Math.round(wx.temperature)}{deg}</span>
|
||||||
{(w.weather_days || 1) > 1 && (wx.days || []).slice(1, w.weather_days).map(d => {
|
{(w.weather_days || 1) > 1 && (wx.days || []).slice(1, w.weather_days).map(d => {
|
||||||
const DayIcon = ICONS[weatherIcon(d.code, true)] || Cloud
|
const DayIcon = ICONS[weatherIcon(d.code, true)] || Cloud
|
||||||
return (
|
return (
|
||||||
<span key={d.date} style={{ display: 'flex', alignItems: 'center', gap: '0.6vmin', ...text, fontSize: `${2.4 * s}vmin`, fontWeight: 600 }}>
|
<span key={d.date} style={{ display: 'flex', alignItems: 'center', gap: '0.6cqmin', ...text, fontSize: `${2.4 * s}cqmin`, fontWeight: 600 }}>
|
||||||
{formatDate(`${d.date}T12:00:00Z`, 'weekday').slice(0, 3)} <DayIcon style={{ width: `${3.4 * s}vmin`, height: `${3.4 * s}vmin` }} aria-hidden="true" />
|
{formatDate(`${d.date}T12:00:00Z`, 'weekday').slice(0, 3)} <DayIcon style={{ width: `${3.4 * s}cqmin`, height: `${3.4 * s}cqmin` }} aria-hidden="true" />
|
||||||
{Math.round(d.max)}° / {Math.round(d.min)}°
|
{Math.round(d.max)}° / {Math.round(d.min)}°
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// @xenia/signage (plan step 5.6a): what a signage slide looks like, drawn the same in the TV's
|
||||||
|
// player (terminal/src/apps/signage) and in the manager's live previews. Sizes are container
|
||||||
|
// units (cqmin): put a slide inside an element with `container-type: size` (frameStyle() does).
|
||||||
|
export * from './logic.js'
|
||||||
|
export { Background, MenuSlide, TextSlide, Widgets } from './Slides.jsx'
|
||||||
|
export { SlideView } from './SlideView.jsx'
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// The signage player's logic (plan step 5.5a). Pure: unit-tested in Node (tests/signage.test.mjs).
|
// The signage player's logic (plan steps 5.5a, 5.5b; @xenia/signage since 5.6a). Pure: unit-tested in
|
||||||
|
// Node (packages/signage/tests/logic.test.mjs).
|
||||||
// The schedule rules are the server's (local_backend/services/signage_schedule.py) so a screen
|
// The schedule rules are the server's (local_backend/services/signage_schedule.py) so a screen
|
||||||
// switches playlists by itself while the server is down; the same cases are tested on both sides.
|
// switches playlists by itself while the server is down; the same cases are tested on both sides.
|
||||||
|
|
||||||
@@ -94,9 +95,9 @@ export function slideMs(slide) {
|
|||||||
export function frameStyle(rotation) {
|
export function frameStyle(rotation) {
|
||||||
const r = Number(rotation) || 0
|
const r = Number(rotation) || 0
|
||||||
if (r === 90 || r === 270) {
|
if (r === 90 || r === 270) {
|
||||||
return { width: '100vh', height: '100vw', transform: `translate(-50%, -50%) rotate(${r}deg)`, top: '50%', left: '50%', position: 'absolute' }
|
return { width: '100vh', height: '100vw', transform: `translate(-50%, -50%) rotate(${r}deg)`, top: '50%', left: '50%', position: 'absolute', containerType: 'size' }
|
||||||
}
|
}
|
||||||
return { width: '100vw', height: '100vh', transform: r === 180 ? 'rotate(180deg)' : undefined, top: 0, left: 0, position: 'absolute' }
|
return { width: '100vw', height: '100vh', transform: r === 180 ? 'rotate(180deg)' : undefined, top: 0, left: 0, position: 'absolute', containerType: 'size' }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every media address a playlist (or a schedule's playlists) needs, to keep on the device. */
|
/** Every media address a playlist (or a schedule's playlists) needs, to keep on the device. */
|
||||||
@@ -119,7 +120,7 @@ export const FONTS = {
|
|||||||
|
|
||||||
// ── menu boards (5.5b) ───────────────────────────────────────────────────────
|
// ── menu boards (5.5b) ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
/** The frame's height in vmin (its shorter side is 100) for a screen w × h: 100 when wide, ~178 when tall (16:9). */
|
/** The frame's height in cqmin (its shorter side is 100) for a screen w × h: 100 when wide, ~178 when tall (16:9). */
|
||||||
export function frameHeightVmin(rotation, w = 16, h = 9) {
|
export function frameHeightVmin(rotation, w = 16, h = 9) {
|
||||||
const turned = Number(rotation) === 90 || Number(rotation) === 270
|
const turned = Number(rotation) === 90 || Number(rotation) === 270
|
||||||
const frameTall = turned ? w > h : h > w // the screen's sides, swapped when the picture is turned
|
const frameTall = turned ? w > h : h > w // the screen's sides, swapped when the picture is turned
|
||||||
@@ -128,7 +129,7 @@ export function frameHeightVmin(rotation, w = 16, h = 9) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* How many rows fit in one column of a menu board: rows are items (taller with a photo or a
|
* How many rows fit in one column of a menu board: rows are items (taller with a photo or a
|
||||||
* description) and group headings. Sizes in vmin, as the board draws them.
|
* description) and group headings. Sizes in cqmin, as the board draws them.
|
||||||
*/
|
*/
|
||||||
export function rowsPerColumn({ heightVmin = 100, textSize = 100, photos = false, descriptions = false, title = false, bars = 0 }) {
|
export function rowsPerColumn({ heightVmin = 100, textSize = 100, photos = false, descriptions = false, title = false, bars = 0 }) {
|
||||||
const s = (textSize || 100) / 100
|
const s = (textSize || 100) / 100
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// local_backend/tests/test_signage_schedule.py, slide windows, the next slide, the frame.
|
// local_backend/tests/test_signage_schedule.py, slide windows, the next slide, the frame.
|
||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
import { boardPages, frameHeightVmin, frameStyle, localNow, matches, mediaUrls, menuMs, menuPages, nextSlide, pageAt, pick, playlistNow, rowsPerColumn, slideMs, weatherIcon } from '../src/apps/signage/logic.js'
|
import { boardPages, frameHeightVmin, frameStyle, localNow, matches, mediaUrls, menuMs, menuPages, nextSlide, pageAt, pick, playlistNow, rowsPerColumn, slideMs, weatherIcon } from '../src/logic.js'
|
||||||
|
|
||||||
const at = (date, hhmm) => {
|
const at = (date, hhmm) => {
|
||||||
const d = new Date(`${date}T12:00:00Z`)
|
const d = new Date(`${date}T12:00:00Z`)
|
||||||
@@ -11,6 +11,7 @@ COPY packages/ui/package.json packages/ui/
|
|||||||
COPY packages/i18n/package.json packages/i18n/
|
COPY packages/i18n/package.json packages/i18n/
|
||||||
COPY packages/api/package.json packages/api/
|
COPY packages/api/package.json packages/api/
|
||||||
COPY packages/access/package.json packages/access/
|
COPY packages/access/package.json packages/access/
|
||||||
|
COPY packages/signage/package.json packages/signage/
|
||||||
COPY waiter_pwa/package.json waiter_pwa/
|
COPY waiter_pwa/package.json waiter_pwa/
|
||||||
COPY manager_dashboard/package.json manager_dashboard/
|
COPY manager_dashboard/package.json manager_dashboard/
|
||||||
COPY terminal/package.json terminal/
|
COPY terminal/package.json terminal/
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"@xenia/access": "^0.0.0",
|
"@xenia/access": "^0.0.0",
|
||||||
"@xenia/api": "^0.0.0",
|
"@xenia/api": "^0.0.0",
|
||||||
"@xenia/i18n": "^0.0.0",
|
"@xenia/i18n": "^0.0.0",
|
||||||
|
"@xenia/signage": "^0.0.0",
|
||||||
"@xenia/ui": "^0.0.0",
|
"@xenia/ui": "^0.0.0",
|
||||||
"axios": "^1.21.1",
|
"axios": "^1.21.1",
|
||||||
"lucide-react": "^1.73.0",
|
"lucide-react": "^1.73.0",
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import client from '../../api/client'
|
import client from '../../api/client'
|
||||||
import { useDevice, useLiveEvent, useLiveEvents } from '../../device/context'
|
import { useDevice, useLiveEvent, useLiveEvents } from '../../device/context'
|
||||||
import { boardPages, frameStyle, localNow, mediaUrls, menuMs, nextSlide, pageAt, playlistNow, slideMs } from './logic'
|
import { boardPages, frameStyle, localNow, mediaUrls, menuMs, nextSlide, pageAt, playlistNow, SlideView, slideMs } from '@xenia/signage'
|
||||||
import { MenuSlide, TextSlide } from './Slides'
|
|
||||||
|
|
||||||
const quiet = { xenia: { noOverride: true } }
|
const quiet = { xenia: { noOverride: true } }
|
||||||
const CACHE_KEY = 'xenia:signage:screen'
|
const CACHE_KEY = 'xenia:signage:screen'
|
||||||
@@ -186,33 +185,7 @@ function Layer({ slide, media, venue, now, onEnded, className, current = false,
|
|||||||
return (
|
return (
|
||||||
<section className={`absolute inset-0 overflow-hidden ${className}`} style={{ animationDuration: `${TRANSITION_MS}ms` }}
|
<section className={`absolute inset-0 overflow-hidden ${className}`} style={{ animationDuration: `${TRANSITION_MS}ms` }}
|
||||||
data-testid={current ? 'signage-slide' : 'signage-slide-out'} data-kind={slide.kind} data-slide={slide.id}>
|
data-testid={current ? 'signage-slide' : 'signage-slide-out'} data-kind={slide.kind} data-slide={slide.id}>
|
||||||
{slide.kind === 'image' && <ImageSlide content={slide.content} media={media} />}
|
<SlideView slide={slide} media={media} venue={venue} now={now} pages={pages} page={page} onEnded={current ? onEnded : undefined} />
|
||||||
{slide.kind === 'video' && <VideoSlide slide={slide} media={media} onEnded={current ? onEnded : undefined} />}
|
|
||||||
{slide.kind === 'text' && <TextSlide content={slide.content} media={media} venue={venue} now={now} />}
|
|
||||||
{slide.kind === 'menu' && <MenuSlide slide={slide} media={media} venue={venue} now={now} pages={pages || []} page={page || 0} />}
|
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImageSlide({ content, media }) {
|
|
||||||
const m = media(content.media_id)
|
|
||||||
return (
|
|
||||||
<div className="absolute inset-0" style={{ background: content.background_colour || '#000' }}>
|
|
||||||
{m && <img src={m.src} alt="" className="w-full h-full" style={{ objectFit: content.fit || 'cover' }} data-testid="signage-image" />}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function VideoSlide({ slide, media, onEnded }) {
|
|
||||||
const c = slide.content
|
|
||||||
const m = media(c.media_id)
|
|
||||||
const ref = useRef(null)
|
|
||||||
useEffect(() => { ref.current?.play?.().catch(() => {}) }, [m?.src])
|
|
||||||
return (
|
|
||||||
<div className="absolute inset-0" style={{ background: c.background_colour || '#000' }}>
|
|
||||||
{m && <video ref={ref} src={m.src} autoPlay muted={c.muted !== false} playsInline loop={!slide.video_to_end}
|
|
||||||
onEnded={slide.video_to_end ? onEnded : undefined} onError={slide.video_to_end ? onEnded : undefined}
|
|
||||||
className="w-full h-full" style={{ objectFit: c.fit || 'cover' }} data-testid="signage-video" />}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import xenia from '@xenia/ui/tailwind-preset'
|
|||||||
export default {
|
export default {
|
||||||
// Shared design tokens only (bg-surface, text-ink-2, rounded-control…), CS-16
|
// Shared design tokens only (bg-surface, text-ink-2, rounded-control…), CS-16
|
||||||
presets: [xenia],
|
presets: [xenia],
|
||||||
content: ['./index.html', './src/**/*.{js,jsx}'],
|
content: ['./index.html', './src/**/*.{js,jsx}', '../packages/signage/src/**/*.{js,jsx}'], // signage slides use a few utilities (5.6a)
|
||||||
theme: { extend: {} },
|
theme: { extend: {} },
|
||||||
plugins: [],
|
plugins: [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const suites = [
|
|||||||
['unit: packages/i18n (node --test + guard)', 'npm', ['test', '--silent', '-w', '@xenia/i18n'], CS],
|
['unit: packages/i18n (node --test + guard)', 'npm', ['test', '--silent', '-w', '@xenia/i18n'], CS],
|
||||||
['unit: packages/api (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/api'], CS],
|
['unit: packages/api (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/api'], CS],
|
||||||
['unit: packages/access (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/access'], CS],
|
['unit: packages/access (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/access'], CS],
|
||||||
|
['unit: packages/signage (node --test)', 'npm', ['test', '--silent', '-w', '@xenia/signage'], CS],
|
||||||
['unit: manager_dashboard (node --test)', 'npm', ['test', '--silent', '-w', 'manager-dashboard'], CS],
|
['unit: manager_dashboard (node --test)', 'npm', ['test', '--silent', '-w', 'manager-dashboard'], CS],
|
||||||
['lint: manager_dashboard (v2 code)', 'npm', ['run', 'lint', '--silent', '-w', 'manager-dashboard'], CS],
|
['lint: manager_dashboard (v2 code)', 'npm', ['run', 'lint', '--silent', '-w', 'manager-dashboard'], CS],
|
||||||
['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS],
|
['unit: terminal (node --test)', 'npm', ['test', '--silent', '-w', 'terminal'], CS],
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ COPY packages/ui/package.json packages/ui/
|
|||||||
COPY packages/i18n/package.json packages/i18n/
|
COPY packages/i18n/package.json packages/i18n/
|
||||||
COPY packages/api/package.json packages/api/
|
COPY packages/api/package.json packages/api/
|
||||||
COPY packages/access/package.json packages/access/
|
COPY packages/access/package.json packages/access/
|
||||||
|
COPY packages/signage/package.json packages/signage/
|
||||||
COPY waiter_pwa/package.json waiter_pwa/
|
COPY waiter_pwa/package.json waiter_pwa/
|
||||||
COPY manager_dashboard/package.json manager_dashboard/
|
COPY manager_dashboard/package.json manager_dashboard/
|
||||||
COPY terminal/package.json terminal/
|
COPY terminal/package.json terminal/
|
||||||
|
|||||||
Reference in New Issue
Block a user