// 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 // they are inline styles, not tokens. Sizes scale with the screen (cqmin), so a slide looks the // same on any TV. import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react' import { QRCodeSVG } from 'qrcode.react' import { useFormat, useTranslation } from '@xenia/i18n' import { FONTS, weatherIcon } from './logic' /** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */ export function Background({ bg, media }) { const m = bg?.kind === 'media' ? media(bg.media_id) : null return (
{m && } {m && bg.dim > 0 &&
}
) } const JUSTIFY = { top: 'flex-start', middle: 'center', bottom: 'flex-end' } const hasBar = (c, where) => (c.widgets || []).some(w => w.position === where) export function TextSlide({ content: c, media, venue, now }) { const scale = (c.text_size || 100) / 100 return (
{c.title &&

{c.title}

} {c.body &&

{c.body}

}
) } /** A menu board (5.5b): its page of items (pages flip on their own), photos, descriptions, badges, sold out. */ export function MenuSlide({ slide, media, venue, now, page, pages }) { const { t } = useTranslation('terminal') const { formatMoney } = useFormat() const c = slide.content const scale = (c.text_size || 100) / 100 const accent = c.accent_colour || '#f59e0b' const groups = pages[page] || [] return (
{c.title &&

{c.title}

}
{groups.map((g, i) => (
{g.category && c.category_titles !== false && (

{g.category.name}

)} {g.items.map(it => (
{c.show_photos && (it.image ? : )}
{it.name} {it.badge && ( {t(`signage.badges.${it.badge}`)} )} {!it.available && {t('signage.soldOut')}} {it.price != null && {formatMoney(it.price)}}
{it.description &&
{it.description}
}
))}
))}
{pages.length > 1 && ( )}
) } // ── widgets (5.5b) ────────────────────────────────────────────────────────── 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' }, } /** The widgets of a slide, in their corners and bars. One that has nothing to show is left out. */ export function Widgets({ widgets, media, venue, now, colour }) { if (!widgets?.length) return null const bar = where => widgets.filter(w => w.position === where) const bars = [['top-bar', { top: 0 }], ['bottom-bar', { bottom: 0 }]] return ( <> {bars.map(([where, pos]) => bar(where).length > 0 && (
{bar(where).map((w, i) => )}
))} {widgets.filter(w => CORNER[w.position]).map((w, i) => (
))} ) } const ICONS = { sun: Sun, moon: Moon, 'cloud-sun': CloudSun, 'cloud-moon': CloudMoon, cloud: Cloud, fog: CloudFog, rain: CloudRain, snow: CloudSnow, storm: CloudLightning } function Widget({ w, media, venue, now }) { const { formatDate, formatTime } = useFormat() const s = SIZE[w.size] || 1 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') { const m = media(w.media_id) return m ? : null } if (w.kind === 'name') return venue?.name ? {venue.name} : null if (w.kind === 'date') return {formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong')} if (w.kind === 'clock') return {formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')} if (w.kind === 'message') { const msg = w.text || venue?.message return msg ? {msg} : null } if (w.kind === 'qr') { return w.link ? (
{w.qr_caption && {w.qr_caption}}
) : null } if (w.kind === 'weather') { const wx = venue?.weather if (!wx || wx.temperature == null) return null // no internet / no place: hidden (5.4c) const Icon = ICONS[weatherIcon(wx.code, wx.is_day)] || Cloud const deg = wx.units === 'fahrenheit' ? '°F' : '°C' return (
) } return null }