|
|
|
@@ -5,6 +5,7 @@
|
|
|
|
|
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
|
|
|
|
import { QRCodeSVG } from 'qrcode.react'
|
|
|
|
|
import { BADGE_ICONS } from './badges'
|
|
|
|
|
import { cq, CQ_BOX } from './cq'
|
|
|
|
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
|
|
|
|
import { badgeColours, badgeName, cellWidgets, TIGHT, fitUnit, FONTS, itemBadges, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
|
|
|
|
|
|
|
|
@@ -30,10 +31,10 @@ export function TextSlide({ content: c, media, venue, now, extras, embed }) {
|
|
|
|
|
<Background bg={c.background} media={media} />
|
|
|
|
|
<div className="absolute inset-0 flex flex-col" style={{
|
|
|
|
|
justifyContent: JUSTIFY[c.vertical] || 'center', textAlign: c.align || 'center',
|
|
|
|
|
padding: `${hasBar(c, 'top-bar') ? 14 : 8}cqmin 8cqmin ${hasBar(c, 'bottom-bar') ? 14 : 8}cqmin`, gap: `${3 * scale}cqmin`,
|
|
|
|
|
padding: `${cq(hasBar(c, 'top-bar') ? 14 : 8)} ${cq(8)} ${cq(hasBar(c, 'bottom-bar') ? 14 : 8)}`, gap: cq(3 * scale),
|
|
|
|
|
}}>
|
|
|
|
|
{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}cqmin`, lineHeight: 1.35, margin: 0, whiteSpace: 'pre-line' }} data-testid="signage-body">{c.body}</p>}
|
|
|
|
|
{c.title && <h1 style={{ fontSize: cq(9 * scale), lineHeight: 1.1, fontWeight: 800, margin: 0 }} data-testid="signage-title">{c.title}</h1>}
|
|
|
|
|
{c.body && <p style={{ fontSize: cq(4.5 * scale), lineHeight: 1.35, margin: 0, whiteSpace: 'pre-line' }} data-testid="signage-body">{c.body}</p>}
|
|
|
|
|
</div>
|
|
|
|
|
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} colour={c.text_colour} extras={extras} embed={embed} />
|
|
|
|
|
</div>
|
|
|
|
@@ -60,23 +61,23 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed
|
|
|
|
|
<div className="absolute inset-0" style={{ color: c.text_colour || '#fff', fontFamily: FONTS[c.font] || FONTS.sans }}>
|
|
|
|
|
<Background bg={c.background} media={media} />
|
|
|
|
|
<div className="absolute inset-0 flex flex-col"
|
|
|
|
|
style={{ padding: `${hasBar(c, 'top-bar') ? 12 : 5}cqmin 5cqmin ${hasBar(c, 'bottom-bar') ? 12 : 5}cqmin` }}
|
|
|
|
|
style={{ padding: `${cq(hasBar(c, 'top-bar') ? 12 : 5)} ${cq(5)} ${cq(hasBar(c, 'bottom-bar') ? 12 : 5)}` }}
|
|
|
|
|
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', 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,
|
|
|
|
|
{c.title && <h1 style={{ fontSize: cq(7 * scale), fontWeight: 800, margin: `0 0 ${cq(2)}`, color: c.heading_style?.colour || accent, lineHeight: 1.1,
|
|
|
|
|
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
|
|
|
|
{/* 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',
|
|
|
|
|
<div style={{ columnCount: c.columns || 2, columnGap: cq(5), fontSize: cq(3.2 * scale), 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} badges={venue?.badges} />
|
|
|
|
|
</div>
|
|
|
|
|
{pages.length > 1 && (
|
|
|
|
|
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
|
|
|
|
{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 style={{ display: 'flex', gap: cq(1), justifyContent: 'center', paddingTop: cq(1) }} aria-hidden="true">
|
|
|
|
|
{pages.map((_, i) => <span key={i} style={{ width: cq(1.2), height: cq(1.2), borderRadius: '50%', background: i === page ? accent : 'currentColor', opacity: i === page ? 1 : 0.3 }} />)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
@@ -157,12 +158,12 @@ export function MenuGroups({ c, groups, badges }) {
|
|
|
|
|
|
|
|
|
|
const SIZE = { small: 0.75, medium: 1, large: 1.4 }
|
|
|
|
|
const CORNER = {
|
|
|
|
|
'top-left': { top: '3cqmin', left: '3cqmin', alignItems: 'flex-start' },
|
|
|
|
|
'top-center': { top: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
|
|
|
|
'top-right': { top: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
|
|
|
|
'bottom-left': { bottom: '3cqmin', left: '3cqmin', alignItems: 'flex-start' },
|
|
|
|
|
'bottom-center': { bottom: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
|
|
|
|
'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
|
|
|
|
|
'top-left': { top: cq(3), left: cq(3), alignItems: 'flex-start' },
|
|
|
|
|
'top-center': { top: cq(3), left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
|
|
|
|
'top-right': { top: cq(3), right: cq(3), alignItems: 'flex-end' },
|
|
|
|
|
'bottom-left': { bottom: cq(3), left: cq(3), alignItems: 'flex-start' },
|
|
|
|
|
'bottom-center': { bottom: cq(3), left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
|
|
|
|
|
'bottom-right': { bottom: cq(3), right: cq(3), alignItems: 'flex-end' },
|
|
|
|
|
}
|
|
|
|
|
const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' }
|
|
|
|
|
const placedBy = w => (w.position === 'custom' && w.box ? (TIGHT.includes(w.kind) ? 'tight' : true) : false)
|
|
|
|
@@ -170,7 +171,7 @@ const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: '
|
|
|
|
|
/** 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' } : {}) } : {}),
|
|
|
|
|
...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}),
|
|
|
|
|
})
|
|
|
|
|
// 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] }
|
|
|
|
@@ -194,8 +195,8 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
|
|
|
|
<>
|
|
|
|
|
{bars.map(([where, pos]) => bar(where).length > 0 && (
|
|
|
|
|
<div key={where} className="absolute inset-x-0" data-testid={`signage-${where}`}
|
|
|
|
|
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' }}>
|
|
|
|
|
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: cq(3), padding: `${cq(2)} ${cq(4)}`,
|
|
|
|
|
background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: cq(9) }}>
|
|
|
|
|
{bar(where).map(([w, i, body]) => (
|
|
|
|
|
<div key={i} data-widget={i} style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w, true) }}>{body}</div>
|
|
|
|
|
))}
|
|
|
|
@@ -215,7 +216,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
|
|
|
|
if (w.position === 'custom') {
|
|
|
|
|
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' }}>
|
|
|
|
|
style={{ left: `${w.box.x}%`, top: `${w.box.y}%`, width: `${w.box.w}%`, height: `${w.box.h}%`, containerType: 'size', color: colour || '#fff' }} {...CQ_BOX}>
|
|
|
|
|
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: VSELF[w.vertical] || 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w) }}>
|
|
|
|
|
{body}
|
|
|
|
|
</div>
|
|
|
|
@@ -250,13 +251,13 @@ function widgetBody(w, ctx, fit, path) {
|
|
|
|
|
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`
|
|
|
|
|
if (fit === 'tight') return n => `${+(n * (w.box.h / height) * ts).toFixed(4)}cqh`
|
|
|
|
|
if (!fit) return n => cq(+(n * s).toFixed(3))
|
|
|
|
|
if (fit === 'tight') return n => cq(+(n * (w.box.h / height) * ts).toFixed(4), 'h')
|
|
|
|
|
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,
|
|
|
|
|
textShadow: w.background_colour ? undefined : `0 ${cq(0.2)} ${cq(0.8)} 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))
|
|
|
|
@@ -264,15 +265,15 @@ function widgetBody(w, ctx, fit, path) {
|
|
|
|
|
}
|
|
|
|
|
// a menu or a stack fills a box: its own, or (in a corner / bar) one of a usual size
|
|
|
|
|
const boxed = (body, kind) => (fit ? body : (
|
|
|
|
|
<div style={{ width: `${BOXED[kind][0] * s}cqmin`, height: `${BOXED[kind][1] * s}cqmin`, containerType: 'size' }}>{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') {
|
|
|
|
|
const m = media(w.media_id)
|
|
|
|
|
if (!m) return null
|
|
|
|
|
if (fit === 'tight') return <img src={m.src} alt="" style={{ height: `${+(w.box.h * ts).toFixed(4)}cqh`, 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
|
|
|
|
|
? <img src={m.src} alt="" style={{ width: '100%', height: '100%', objectFit: 'contain', objectPosition: OBJECT_POSITION[widgetAlign(w)] }} data-testid="signage-w-logo" />
|
|
|
|
|
: <img src={m.src} alt="" style={{ height: `${9 * s}cqmin`, maxWidth: `${30 * s}cqmin`, objectFit: 'contain' }} data-testid="signage-w-logo" />
|
|
|
|
|
: <img src={m.src} alt="" style={{ height: cq(9 * s), maxWidth: cq(30 * s), objectFit: 'contain' }} data-testid="signage-w-logo" />
|
|
|
|
|
}
|
|
|
|
|
if (w.kind === 'name') {
|
|
|
|
|
if (!venue?.name) return null
|
|
|
|
@@ -360,7 +361,7 @@ function MenuWidget({ board: b, menu, now, badges }) {
|
|
|
|
|
const scale = (b.text_size || 100) / 100
|
|
|
|
|
const rowH = (b.show_photos ? 2.6 * (b.photo_size || 100) / 100 : b.show_descriptions ? 2.1 : 1.5) * menuLook(b).rowScale
|
|
|
|
|
const lines = Math.ceil(per / cols) + (headings ? 1 : 0)
|
|
|
|
|
const fontSize = `calc(${scale} * min(${(100 / (lines * rowH + (b.title ? 2 : 0) + 0.8)).toFixed(3)}cqh, ${(100 / (cols * 15)).toFixed(3)}cqw))`
|
|
|
|
|
const fontSize = `calc(${scale} * min(${cq((100 / (lines * rowH + (b.title ? 2 : 0) + 0.8)).toFixed(3), 'h')}, ${cq((100 / (cols * 15)).toFixed(3), 'w')}))`
|
|
|
|
|
const accent = b.accent_colour || '#f59e0b'
|
|
|
|
|
return (
|
|
|
|
|
<div style={{ width: '100%', height: '100%', overflow: 'hidden', fontSize, color: b.text_colour || '#fff', fontFamily: FONTS[b.font] || FONTS.sans, textAlign: 'left' }}
|
|
|
|
@@ -391,7 +392,7 @@ function Stack({ w, path, ctx }) {
|
|
|
|
|
const slide = !ws.length && c.slide_id ? ctx.extras[cp]?.slide : null
|
|
|
|
|
return (
|
|
|
|
|
<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}>
|
|
|
|
|
display: 'flex', flexDirection: across }} {...CQ_BOX} data-testid="signage-stack-cell" data-share={c.share}>
|
|
|
|
|
{ws.map((cw, k) => {
|
|
|
|
|
const wp = `${cp}.${k}`
|
|
|
|
|
const own = cw.position === 'custom' && cw.box
|
|
|
|
@@ -400,14 +401,14 @@ function Stack({ w, path, ctx }) {
|
|
|
|
|
return (
|
|
|
|
|
<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}>
|
|
|
|
|
{...CQ_BOX} data-testid="signage-stack-place" data-place={wp}>
|
|
|
|
|
{body && (own && TIGHT.includes(cw.kind) ? (
|
|
|
|
|
<div data-widget={wp} style={{ position: 'absolute', left: `${cw.box.x}%`, top: `${cw.box.y}%`, width: 'max-content', display: 'flex', flexDirection: 'column',
|
|
|
|
|
alignItems: SELF[align], textAlign: align, ...plate(cw, true) }} data-testid="signage-w-box" data-tight="">{body}</div>
|
|
|
|
|
) : 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>
|
|
|
|
|
{...CQ_BOX} 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>
|
|
|
|
|
))}
|
|
|
|
|