feat(terminal): older TVs get a legacy build with a compatibility layer; modern output unchanged
- @vitejs/plugin-legacy: browsers without import.meta.resolve (older than Chrome 105 / Firefox 106 / Safari 16.4) load a second copy built for Chrome 79 / Firefox 78 / Safari 13 with polyfills. The modern targets and the stylesheet stay on Vite's own defaults, so modern chunks are byte-identical to before (only plugin-legacy's 230-byte guard in the entry). - terminal/src/compat.js (legacy copy only): swaps in <name>.compat.css (lightningcss for the older targets), sets container-size variables for signage slides, emulates flex gap. - @xenia/signage cq()/CQ_BOX: container units as before where supported, calc(var()) fallback otherwise; EmbeddedSlide no longer uses inline `inset`. - Shared Notice (@xenia/ui); "Devices that work" in Pair a device and Signage -> Screens (EN/EL). - tests/e2e/compat.mjs: modern browser loads nothing extra; a simulated older TV runs the legacy copy and the layer, pairs, and plays a slide at the same sizes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -234,7 +234,16 @@
|
||||
"removeTitle": "Αφαίρεση: {{name}};",
|
||||
"removeBody": "Σταματά αμέσως και δείχνει την οθόνη σύζευξης. Για να ξαναχρησιμοποιηθεί, κάντε ξανά σύζευξη.",
|
||||
"changeAppBody": "Όποιος είναι συνδεδεμένος σε αυτή αποσυνδέεται.",
|
||||
"limitReached": "{{label}}: η άδεια επιτρέπει {{max}}. Αφαιρέστε μία ή ζητήστε μεγαλύτερη άδεια."
|
||||
"limitReached": "{{label}}: η άδεια επιτρέπει {{max}}. Αφαιρέστε μία ή ζητήστε μεγαλύτερη άδεια.",
|
||||
"support": {
|
||||
"title": "Συσκευές που λειτουργούν",
|
||||
"bestLabel": "Ιδανικά:",
|
||||
"best": "Chrome ή Edge 111, Firefox 114, Safari 16.4 ή νεότερα: ενημερωμένα κινητά, tablet και υπολογιστές, Android TV box, οι περισσότερες τηλεοράσεις από το 2024 και μετά. Όλα τρέχουν σε πλήρη ταχύτητα.",
|
||||
"compatLabel": "Λειτουργεί, με επίπεδο συμβατότητας:",
|
||||
"compat": "Chrome 79, Firefox 78, Safari 13 ή νεότερα, π.χ. ο ενσωματωμένος browser τηλεοράσεων LG και Samsung από το 2021 έως το 2023. Φτιαγμένο για οθόνες ψηφιακής σήμανσης: μπορεί να φορτώνει και να παίζει πιο αργά. Για ταμεία, οθόνες κουζίνας και tablet μενού χρησιμοποιήστε νεότερη συσκευή.",
|
||||
"oldLabel": "Πολύ παλιό:",
|
||||
"old": "οτιδήποτε παλαιότερο (π.χ. τηλεοράσεις LG του 2020 ή παλαιότερες) δείχνει λευκή σελίδα. Συνδέστε στην τηλεόραση ένα Android TV box ή stick (οποιοδήποτε πρόσφατο κάνει) και ανοίξτε εκεί τη διεύθυνση."
|
||||
}
|
||||
},
|
||||
"roles": {
|
||||
"superadmin": "Superadmin",
|
||||
|
||||
@@ -234,7 +234,16 @@
|
||||
"removeTitle": "Remove {{name}}?",
|
||||
"removeBody": "It stops at once and shows the pairing screen. To use it again, pair it again.",
|
||||
"changeAppBody": "Whoever is signed in on it is signed out.",
|
||||
"limitReached": "{{label}}: the license allows {{max}}. Remove one or ask for a bigger license."
|
||||
"limitReached": "{{label}}: the license allows {{max}}. Remove one or ask for a bigger license.",
|
||||
"support": {
|
||||
"title": "Devices that work",
|
||||
"bestLabel": "Best:",
|
||||
"best": "Chrome or Edge 111, Firefox 114, Safari 16.4 or newer: phones, tablets and computers that are up to date, Android TV boxes, most TVs from 2024 on. Everything runs at full speed.",
|
||||
"compatLabel": "Works, with a compatibility layer:",
|
||||
"compat": "Chrome 79, Firefox 78, Safari 13 or newer, e.g. the built-in browser of LG and Samsung TVs from 2021 to 2023. Made for screens with signage: it may load and play more slowly. For tills, kitchen screens and menu tablets use a newer device.",
|
||||
"oldLabel": "Too old:",
|
||||
"old": "anything older (e.g. LG TVs from 2020 or before) shows a blank page. Plug an Android TV box or stick into the TV (any recent one is fine) and open the address there."
|
||||
}
|
||||
},
|
||||
"roles": {
|
||||
"superadmin": "Superadmin",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
// slide.extras: what the server added to its widgets by path (QR links, menus, slides inside stacks)
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||
import { boardPages, pageAt } from './logic.js'
|
||||
import { CQ_BOX } from './cq.js'
|
||||
import { BlankSlide, MenuSlide, TextSlide } from './Slides.jsx'
|
||||
|
||||
export function SlideView({ slide, media, venue, now, pages, page, onEnded, playing = true }) {
|
||||
@@ -39,7 +40,7 @@ function EmbeddedSlide({ slide, media, venue, now }) {
|
||||
const pages = slide.kind === 'menu' && size ? boardPages(slide, 0, size.w || 16, size.h || 9) : null
|
||||
const page = pages ? pageAt(pages.length, slide.content?.page_seconds, now.getTime()) : 0
|
||||
return (
|
||||
<div ref={ref} style={{ position: 'absolute', inset: 0, overflow: 'hidden', containerType: 'size' }} data-testid="signage-embedded" data-embedded="" data-kind={slide.kind} data-id={slide.id}>
|
||||
<div ref={ref} style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, overflow: 'hidden', containerType: 'size' }} {...CQ_BOX} data-testid="signage-embedded" data-embedded="" data-kind={slide.kind} data-id={slide.id}>
|
||||
{size && <SlideView slide={{ ...slide, video_to_end: false }} media={media} venue={venue} now={now} pages={pages} page={page} />}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Container units with a fallback for older TV browsers (2026-11-21). A slide is sized in container units
|
||||
// (cqmin, cqh, cqw: Chrome 105, Firefox 110, Safari 16). Where the browser has them, cq() writes them
|
||||
// exactly as before. On older browsers (an LG / Samsung TV from 2021–2023) it writes
|
||||
// calc(n * var(--xcqmin)) instead. The terminal's compatibility layer (terminal/src/compat.js) then
|
||||
// measures every container (an element marked with CQ_BOX) and gives its children those variables, so
|
||||
// each size refers to the nearest container, as the real units do.
|
||||
|
||||
const NATIVE = typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || CSS.supports('width', '1cqmin')
|
||||
|
||||
/** True where the browser has container units: no fallback at all. */
|
||||
export const CQ_NATIVE = NATIVE
|
||||
|
||||
const VIEWPORT = { min: 'vmin', h: 'vh', w: 'vw' }
|
||||
|
||||
/** `n` container units: cq(3) → "3cqmin", cq(4, 'h') → "4cqh" (or the fallback on an older browser). */
|
||||
export function cq(n, unit = 'min') {
|
||||
return NATIVE ? `${n}cq${unit}` : `calc(${n} * var(--xcq${unit}, 1${VIEWPORT[unit]}))`
|
||||
}
|
||||
|
||||
/** Spread on every element with `container-type: size`: nothing where the browser has container units. */
|
||||
export const CQ_BOX = NATIVE ? {} : { 'data-cq': '' }
|
||||
@@ -2,6 +2,7 @@
|
||||
// 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 { cq, CQ_BOX, CQ_NATIVE } from './cq.js'
|
||||
export { BADGE_ICONS } from './badges.js'
|
||||
export { Background, BlankSlide, MenuSlide, TextSlide, Widgets } from './Slides.jsx'
|
||||
export { SlideView } from './SlideView.jsx'
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Node (packages/signage/tests/logic.test.mjs).
|
||||
// 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.
|
||||
import { cq } from './cq.js'
|
||||
|
||||
/** The venue's local clock at `date`: { weekday (0 = Monday), minutes, date: "YYYY-MM-DD" }. */
|
||||
export function localNow(timeZone, date = new Date()) {
|
||||
@@ -309,7 +310,7 @@ export function widgetAlign(w) {
|
||||
export function fitUnit(height, width) {
|
||||
const byH = 100 / Math.max(0.1, height)
|
||||
const byW = 100 / Math.max(0.1, width)
|
||||
return n => `calc(${+n.toFixed(3)} * min(${+byH.toFixed(4)}cqh, ${+byW.toFixed(4)}cqw))`
|
||||
return n => `calc(${+n.toFixed(3)} * min(${cq(+byH.toFixed(4), 'h')}, ${cq(+byW.toFixed(4), 'w')}))`
|
||||
}
|
||||
|
||||
/** A line of `chars` characters at `size` usual units: about how wide it is (bold sans). */
|
||||
|
||||
@@ -221,3 +221,25 @@ test('owner review 5: the venue badges, several per product; a board with its ow
|
||||
assert.equal(badgeName(mine[0], 'el'), 'Gluten free')
|
||||
assert.equal(badgeName(DEFAULT_BADGES[1], 'el'), 'Πρόταση σεφ')
|
||||
})
|
||||
|
||||
test('container units: written exactly as before where the browser has them (older TVs, 2026-11-21)', async () => {
|
||||
const { cq, CQ_BOX, CQ_NATIVE } = await import('../src/cq.js')
|
||||
const { fitUnit } = await import('../src/logic.js')
|
||||
assert.equal(CQ_NATIVE, true)
|
||||
assert.equal(cq(3), '3cqmin')
|
||||
assert.equal(cq(4.5, 'h'), '4.5cqh')
|
||||
assert.equal(cq(0.25, 'w'), '0.25cqw')
|
||||
assert.deepEqual(CQ_BOX, {})
|
||||
assert.equal(fitUnit(4, 20)(2), 'calc(2 * min(25cqh, 5cqw))')
|
||||
})
|
||||
|
||||
test('container units: an older browser gets calc() of the variables the compat layer sets', async () => {
|
||||
globalThis.CSS = { supports: () => false }
|
||||
try {
|
||||
const { cq, CQ_BOX, CQ_NATIVE } = await import('../src/cq.js?older')
|
||||
assert.equal(CQ_NATIVE, false)
|
||||
assert.equal(cq(3), 'calc(3 * var(--xcqmin, 1vmin))')
|
||||
assert.equal(cq(4.5, 'h'), 'calc(4.5 * var(--xcqh, 1vh))')
|
||||
assert.deepEqual(CQ_BOX, { 'data-cq': '' })
|
||||
} finally { delete globalThis.CSS }
|
||||
})
|
||||
|
||||
@@ -679,3 +679,26 @@
|
||||
border-right: 1px dashed #888; border-bottom: 1px dashed #888;
|
||||
padding: 6mm 4mm; display: grid; justify-items: center; align-content: start; gap: 2mm; text-align: center;
|
||||
}
|
||||
|
||||
/* ── Notice (2026-11-21) ─────────────────────────────────────────────────── */
|
||||
.x-notice {
|
||||
--x-notice-tone: var(--x-info); --x-notice-soft: var(--x-info-soft); --x-notice-ink: var(--x-info-ink);
|
||||
display: grid; gap: 6px; padding: 10px 14px; border-radius: var(--x-radius-control);
|
||||
border: 1px solid var(--x-notice-tone); border-left-width: 4px; background: var(--x-notice-soft);
|
||||
color: var(--x-ink); font-size: var(--x-text-label); line-height: var(--x-leading-label);
|
||||
}
|
||||
.x-notice--success { --x-notice-tone: var(--x-success); --x-notice-soft: var(--x-success-soft); --x-notice-ink: var(--x-success-ink); }
|
||||
.x-notice--warning { --x-notice-tone: var(--x-warning); --x-notice-soft: var(--x-warning-soft); --x-notice-ink: var(--x-warning-ink); }
|
||||
.x-notice--danger { --x-notice-tone: var(--x-danger); --x-notice-soft: var(--x-danger-soft); --x-notice-ink: var(--x-danger-ink); }
|
||||
.x-notice--neutral { --x-notice-tone: var(--x-line-strong); --x-notice-soft: var(--x-surface-2); --x-notice-ink: var(--x-ink); }
|
||||
.x-notice__title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--x-notice-ink); }
|
||||
.x-notice__icon { display: inline-flex; }
|
||||
.x-notice__body { color: var(--x-ink-2); }
|
||||
.x-notice__items { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
|
||||
.x-notice__item { display: grid; grid-template-columns: 8px 1fr; gap: 10px; align-items: baseline; color: var(--x-ink-2); }
|
||||
.x-notice__dot { width: 8px; height: 8px; border-radius: var(--x-radius-full); background: var(--x-notice-item, var(--x-ink-3)); transform: translateY(-1px); }
|
||||
.x-notice__item--success { --x-notice-item: var(--x-success); }
|
||||
.x-notice__item--warning { --x-notice-item: var(--x-warning); }
|
||||
.x-notice__item--danger { --x-notice-item: var(--x-danger); }
|
||||
.x-notice__item--info { --x-notice-item: var(--x-info); }
|
||||
.x-notice__label { color: var(--x-ink); font-weight: 600; }
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import { cx } from '../internal/cx.js'
|
||||
|
||||
/**
|
||||
* A boxed note in a tone (2026-11-21): a title, text, and an optional list of points, each with a tone
|
||||
* dot and a short label (e.g. what works, what works with limits, what doesn't).
|
||||
* <Notice tone="info" title="Devices that work">Some text</Notice>
|
||||
* <Notice title="…" items={[{ tone: 'success', label: 'Best', text: 'Chrome 111+' }, …]} />
|
||||
* Tones: info (default), success, warning, danger, neutral.
|
||||
*/
|
||||
export function Notice({ tone = 'info', title, icon, items, className, children, ...rest }) {
|
||||
return (
|
||||
<div className={cx('x-notice', `x-notice--${tone}`, className)} {...rest}>
|
||||
{(title || icon) && (
|
||||
<div className="x-notice__title">
|
||||
{icon && <span className="x-notice__icon" aria-hidden="true">{icon}</span>}
|
||||
{title}
|
||||
</div>
|
||||
)}
|
||||
{children && <div className="x-notice__body">{children}</div>}
|
||||
{items?.length > 0 && (
|
||||
<ul className="x-notice__items">
|
||||
{items.map((it, i) => (
|
||||
<li key={i} className={cx('x-notice__item', `x-notice__item--${it.tone || 'neutral'}`)} data-tone={it.tone || 'neutral'}>
|
||||
<span className="x-notice__dot" aria-hidden="true" />
|
||||
<span>{it.label && <strong className="x-notice__label">{it.label}</strong>}{it.label && ' '}{it.text}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -28,6 +28,7 @@ export { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './components
|
||||
export { FieldRow } from './components/FieldRow.jsx'
|
||||
export { Slider } from './components/Slider.jsx'
|
||||
export { NumberInput } from './components/NumberInput.jsx'
|
||||
export { Notice } from './components/Notice.jsx'
|
||||
export { IconPicker } from './components/IconPicker.jsx'
|
||||
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
||||
|
||||
Reference in New Issue
Block a user