|
|
|
@@ -4,8 +4,9 @@
|
|
|
|
|
// same on any TV.
|
|
|
|
|
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
|
|
|
|
import { QRCodeSVG } from 'qrcode.react'
|
|
|
|
|
import { BADGE_ICONS } from './badges'
|
|
|
|
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
|
|
|
|
import { cellWidgets, fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
|
|
|
|
import { badgeColours, badgeName, cellWidgets, fitUnit, FONTS, itemBadges, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
|
|
|
|
|
|
|
|
|
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
|
|
|
|
|
export function Background({ bg, media }) {
|
|
|
|
@@ -63,12 +64,15 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed
|
|
|
|
|
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
|
|
|
|
|
{/* the list: the whole width, or narrower and placed left / centre / right (2026-11-21) */}
|
|
|
|
|
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', width: `${c.board_width || 100}%`,
|
|
|
|
|
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start' }} data-testid="signage-menu-board" data-align={c.board_align || 'left'}>
|
|
|
|
|
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start', justifyContent: VSELF[c.board_valign] || 'flex-start' }}
|
|
|
|
|
data-testid="signage-menu-board" data-align={c.board_align || 'left'} data-valign={c.board_valign || 'top'}>
|
|
|
|
|
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: c.heading_style?.colour || accent, lineHeight: 1.1,
|
|
|
|
|
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
|
|
|
|
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
|
|
|
|
{/* top: the list takes the height (columns fill one after the other); middle / bottom: as tall as it is, placed (owner review 5) */}
|
|
|
|
|
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: (c.board_valign || 'top') === 'top' ? 1 : '0 1 auto',
|
|
|
|
|
minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
|
|
|
|
data-testid="signage-menu-list">
|
|
|
|
|
<MenuGroups c={c} groups={groups} />
|
|
|
|
|
<MenuGroups c={c} groups={groups} badges={venue?.badges} />
|
|
|
|
|
</div>
|
|
|
|
|
{pages.length > 1 && (
|
|
|
|
|
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
|
|
|
@@ -96,8 +100,9 @@ const listSpacing = c => {
|
|
|
|
|
return { lineHeight: look.lineHeight, letterSpacing: look.letterSpacing }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function MenuGroups({ c, groups }) {
|
|
|
|
|
const { t } = useTranslation('terminal')
|
|
|
|
|
export function MenuGroups({ c, groups, badges }) {
|
|
|
|
|
const { t, i18n } = useTranslation('terminal')
|
|
|
|
|
const lang = c.language || (String(i18n.language || '').startsWith('el') ? 'el' : 'en')
|
|
|
|
|
const { formatMoney } = useFormat()
|
|
|
|
|
const look = menuLook(c)
|
|
|
|
|
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
|
|
|
|
@@ -121,10 +126,16 @@ export function MenuGroups({ c, groups }) {
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: '0.3em' }}>
|
|
|
|
|
<span style={{ ...look.item, textDecoration: it.available ? look.item.textDecoration : 'line-through',
|
|
|
|
|
...(nameFills ? { flex: 1, minWidth: 0, textAlign: look.itemAlign } : {}) }} data-testid="signage-menu-name">{it.name}</span>
|
|
|
|
|
{it.badge && (
|
|
|
|
|
<span style={{ ...look.badge, fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.5em', borderRadius: '99em',
|
|
|
|
|
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4 }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
|
|
|
|
)}
|
|
|
|
|
{itemBadges(it, badges).map(d => {
|
|
|
|
|
const Icon = BADGE_ICONS[d.icon]
|
|
|
|
|
return (
|
|
|
|
|
<span key={d.key} style={{ ...badgeColours(d, c), fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.55em', borderRadius: '99em',
|
|
|
|
|
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4, display: 'inline-flex', alignItems: 'center', gap: '0.3em',
|
|
|
|
|
alignSelf: 'center' }} data-testid="signage-badge" data-key={d.key}>
|
|
|
|
|
{Icon && <Icon style={{ width: '1.15em', height: '1.15em', flexShrink: 0 }} strokeWidth={2.5} aria-hidden="true" />}{badgeName(d, lang)}
|
|
|
|
|
</span>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
|
|
|
|
{it.price != null && <>
|
|
|
|
|
<span style={{ ...look.dots, ...(nameFills ? { flex: '0 0 2em' } : { flex: 1, minWidth: '0.6em' }) }} data-testid="signage-menu-dots" />
|
|
|
|
@@ -154,6 +165,12 @@ const CORNER = {
|
|
|
|
|
'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
|
|
|
|
}
|
|
|
|
|
const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' }
|
|
|
|
|
const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: 'center' }
|
|
|
|
|
/** A widget's own colour and the plate behind it (owner review 5); `pad`: a plate that hugs it. */
|
|
|
|
|
const plate = (w, pad) => ({
|
|
|
|
|
...(w.colour ? { color: w.colour } : {}),
|
|
|
|
|
...(w.background_colour ? { background: w.background_colour, borderRadius: '1.2cqmin', ...(pad ? { padding: '0.8cqmin 1.6cqmin' } : {}) } : {}),
|
|
|
|
|
})
|
|
|
|
|
// a menu or a stack in a corner or a bar has no box of its own: it gets one of this size (cqmin)
|
|
|
|
|
const BOXED = { menu: [48, 56], stack: [60, 36] }
|
|
|
|
|
|
|
|
|
@@ -179,7 +196,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
|
|
|
|
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: '9cqmin' }}>
|
|
|
|
|
{bar(where).map(([w, i, body]) => (
|
|
|
|
|
<div key={i} data-widget={i} style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w) }}>{body}</div>
|
|
|
|
|
<div key={i} data-widget={i} style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w, true) }}>{body}</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
@@ -188,7 +205,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
|
|
|
|
return (
|
|
|
|
|
<div key={i} data-widget={i} className="absolute" data-testid="signage-w-box"
|
|
|
|
|
style={{ left: `${w.box.x}%`, top: `${w.box.y}%`, width: `${w.box.w}%`, height: `${w.box.h}%`, containerType: 'size', color: colour || '#fff' }}>
|
|
|
|
|
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w) }}>
|
|
|
|
|
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: VSELF[w.vertical] || 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w) }}>
|
|
|
|
|
{body}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@@ -196,7 +213,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
|
|
|
|
}
|
|
|
|
|
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {}
|
|
|
|
|
return (
|
|
|
|
|
<div key={i} data-widget={i} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff' }}>
|
|
|
|
|
<div key={i} data-widget={i} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true) }}>
|
|
|
|
|
{body}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
@@ -216,10 +233,17 @@ function widgetBody(w, ctx, fit, path) {
|
|
|
|
|
const { media, venue, now, fmt, extras } = ctx
|
|
|
|
|
const { formatDate, formatTime } = fmt
|
|
|
|
|
const x = extras[path] || {}
|
|
|
|
|
const s = SIZE[w.size] || 1
|
|
|
|
|
const unit = (height, width) => (fit ? fitUnit(height, width) : n => `${+(n * s).toFixed(3)}cqmin`)
|
|
|
|
|
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: weight, lineHeight: 1.15,
|
|
|
|
|
textShadow: '0 0.2cqmin 0.8cqmin rgba(0,0,0,0.35)', whiteSpace: fit ? 'nowrap' : undefined })
|
|
|
|
|
const ts = (w.text_size || 100) / 100 // its own text size (owner review 5)
|
|
|
|
|
const s = (SIZE[w.size] || 1) * ts
|
|
|
|
|
// in a box of its own the box sets the size: its text size can only make it smaller there
|
|
|
|
|
const unit = (height, width) => {
|
|
|
|
|
if (!fit) return n => `${+(n * s).toFixed(3)}cqmin`
|
|
|
|
|
const f = fitUnit(height, width)
|
|
|
|
|
return n => f(n * Math.min(1, ts))
|
|
|
|
|
}
|
|
|
|
|
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: w.bold === false ? 400 : w.bold ? Math.max(weight, 800) : weight, lineHeight: 1.15,
|
|
|
|
|
textShadow: w.background_colour ? undefined : '0 0.2cqmin 0.8cqmin rgba(0,0,0,0.35)', whiteSpace: fit ? 'nowrap' : undefined,
|
|
|
|
|
...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}), ...(w.underline ? { textDecoration: 'underline' } : {}) })
|
|
|
|
|
const line = (str, testid, weight) => {
|
|
|
|
|
const u = unit(3.4 * 1.15, textWidth(str.length, 3.4))
|
|
|
|
|
return <span style={text(u, 3.4, weight)} data-testid={testid}>{str}</span>
|
|
|
|
@@ -257,15 +281,15 @@ function widgetBody(w, ctx, fit, path) {
|
|
|
|
|
const u = unit(16 + caption, Math.max(16, w.qr_caption ? textWidth(w.qr_caption.length, 2.4) : 0))
|
|
|
|
|
return (
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
|
|
|
|
|
<div style={{ background: '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
|
|
|
|
<QRCodeSVG value={link} size={256} style={{ width: u(14), height: u(14) }} />
|
|
|
|
|
<div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
|
|
|
|
<QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }} />
|
|
|
|
|
</div>
|
|
|
|
|
{w.qr_caption && <span style={text(u, 2.4)}>{w.qr_caption}</span>}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
if (w.kind === 'weather') return weatherBody(w, venue?.weather, unit, text, formatDate)
|
|
|
|
|
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} />, 'menu')
|
|
|
|
|
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} badges={venue?.badges} />, 'menu')
|
|
|
|
|
if (w.kind === 'stack') return boxed(<Stack w={w} path={path} ctx={ctx} />, 'stack')
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
@@ -311,7 +335,7 @@ function weatherBody(w, wx, unit, text, formatDate) {
|
|
|
|
|
* A menu widget (2026-11-21): a board's list in the widget's box (inside an element with
|
|
|
|
|
* `container-type: size`), its pages turning on the clock; the text sized so a page fills the box.
|
|
|
|
|
*/
|
|
|
|
|
function MenuWidget({ board: b, menu, now }) {
|
|
|
|
|
function MenuWidget({ board: b, menu, now, badges }) {
|
|
|
|
|
const groups = visibleGroups(menu?.groups)
|
|
|
|
|
const per = b.page_size || 8
|
|
|
|
|
const headings = b.category_titles !== false
|
|
|
|
@@ -328,7 +352,7 @@ function MenuWidget({ board: b, menu, now }) {
|
|
|
|
|
data-testid="signage-w-menu" data-page={page} data-pages={pages.length}>
|
|
|
|
|
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: b.heading_style?.colour || accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
|
|
|
|
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
|
|
|
|
|
<MenuGroups c={b} groups={pages[page] || []} />
|
|
|
|
|
<MenuGroups c={b} groups={pages[page] || []} badges={badges} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
@@ -354,11 +378,21 @@ function Stack({ w, path, ctx }) {
|
|
|
|
|
<div key={j} style={{ flex: `${c.share || 1} 1 0%`, minWidth: 0, minHeight: 0, position: 'relative', overflow: 'hidden', containerType: 'size',
|
|
|
|
|
display: 'flex', flexDirection: across }} data-testid="signage-stack-cell" data-share={c.share}>
|
|
|
|
|
{ws.map((cw, k) => {
|
|
|
|
|
const wp = `${cp}.${k}`
|
|
|
|
|
const own = cw.position === 'custom' && cw.box
|
|
|
|
|
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
|
|
|
|
const body = widgetBody(cw, ctx, true, wp)
|
|
|
|
|
return (
|
|
|
|
|
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size',
|
|
|
|
|
display: 'flex', alignItems: 'center', justifyContent: SELF[align], textAlign: align }} data-testid="signage-stack-place">
|
|
|
|
|
{widgetBody(cw, ctx, true, `${cp}.${k}`)}
|
|
|
|
|
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size', position: 'relative',
|
|
|
|
|
...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }}
|
|
|
|
|
data-testid="signage-stack-place" data-place={wp}>
|
|
|
|
|
{body && (own ? (
|
|
|
|
|
<div data-widget={wp} style={{ position: 'absolute', left: `${cw.box.x}%`, top: `${cw.box.y}%`, width: `${cw.box.w}%`, height: `${cw.box.h}%`,
|
|
|
|
|
containerType: 'size', display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align, ...plate(cw) }}
|
|
|
|
|
data-testid="signage-w-box">{body}</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div data-widget={wp} style={{ display: 'flex', maxWidth: '100%', maxHeight: '100%', ...(cw.kind === 'menu' || cw.kind === 'stack' ? { width: '100%', height: '100%' } : {}), ...plate(cw, true) }}>{body}</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|