feat(signage): Slides library, widgets placed on the preview, blank slides, slide editor rework

- Slides library (Alembic 0044, /api/signage/library): slides kept with a name and a
  description, added to playlists as copies ("Add a slide" → Your slides, "Keep in Slides"),
  or shown alone as a screen's default (device config `slide`, played as "slide:<id>",
  also as a schedule's fallback). Signage → Slides: gallery + a two-pane editor.
- Widgets moved and sized by hand on the preview (WidgetCanvas: handles, snapping, arrow
  keys): position/size "custom" with a box the TV draws the same; alignment per widget.
- Blank slides (background + widgets); menu boards narrower and placed left/centre/right.
- Slide editor reworked: name | show, transition effect | seconds; sections; text look on
  one row with ready colours; one card per widget, settings on one row.
- Questions inside the page (@xenia/ui ConfirmDialog/useConfirm), Switch boxed, Segmented
  fill; the timeline's drop line; schedule lines run on weekdays or smart days, not both;
  the playlist editor stays within 1080p with a long timeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 07:53:27 +02:00
co-authored by Claude Opus 5.5
parent 60e6a16217
commit 83551714f7
46 changed files with 1934 additions and 431 deletions
+1
View File
@@ -26,6 +26,7 @@
},
"ui": {
"close": "Κλείσιμο",
"cancel": "Άκυρο",
"dismiss": "Απόρριψη",
"loading": "Φόρτωση",
"moreInfo": "Περισσότερες πληροφορίες",
+60 -10
View File
@@ -1270,7 +1270,9 @@
"image": "Εικόνα",
"video": "Βίντεο",
"text": "Κείμενο",
"menu": "Μενού"
"menu": "Μενού",
"blank": "Κενή",
"blankWidgets": "Κενή με widgets"
},
"misfit": "Αυτή η εικόνα ή το βίντεο δεν ταιριάζει στο σχήμα της λίστας: θα κοπεί ή θα έχει μπάρες.",
"toTheEnd": "ως το τέλος",
@@ -1291,7 +1293,7 @@
"6": "Κυρ"
},
"duplicateSlide": "Αντίγραφο της διαφάνειας",
"deleteSlide": "Αφαίρεση αυτής της διαφάνειας;",
"deleteSlide": "Φεύγει από αυτή τη λίστα. Οι εικόνες και τα βίντεό της μένουν στη βιβλιοθήκη πολυμέσων.",
"removed": "Η διαφάνεια αφαιρέθηκε.",
"addSlide": "Προσθήκη διαφάνειας",
"added": "Η διαφάνεια προστέθηκε.",
@@ -1344,7 +1346,7 @@
"videoToEndHint": "Όχι: δείχνεται για τα δευτερόλεπτα παρακάτω (και επαναλαμβάνεται αν είναι μικρότερο).",
"duration": "Δευτερόλεπτα στην οθόνη",
"durationMenuHint": "Ένα μεγάλο μενού γυρίζει σελίδες και μένει όσο χρειάζεται.",
"transition": "Μπαίνει με",
"transition": "Εφέ μετάβασης",
"transitionDefault": "Τη μετάβαση της λίστας",
"when": "Πότε εμφανίζεται",
"whenHint": "Κενό για πάντα. Διαλέξτε ημέρες, ώρες (μπορεί να περνούν τα μεσάνυχτα) ή ημερομηνίες για να εμφανίζεται μόνο τότε. Αυτό στενεύει το πρόγραμμα της λίστας: μια διαφάνεια με ώρα εκτός των ωρών που παίζει η λίστα της δεν εμφανίζεται ποτέ.",
@@ -1429,7 +1431,12 @@
"pageSeconds": "Δευτερόλεπτα ανά σελίδα",
"language": "Γλώσσα",
"languageHint": "Τα ονόματα των προϊόντων σε αυτή την οθόνη. Χωρίς μετάφραση: όπως γράφτηκαν.",
"asTyped": "Όπως γράφτηκαν"
"asTyped": "Όπως γράφτηκαν",
"which": "Προϊόντα",
"layout": "Διάταξη",
"width": "Πλάτος λίστας",
"place": "Θέση λίστας",
"placeHint": "Σε όλο το πλάτος η λίστα γεμίζει την οθόνη: στενέψτε την για να τη μετακινήσετε."
},
"badges": {
"new": "Νέο",
@@ -1477,7 +1484,13 @@
"weatherDays": "Μέρες",
"days_one": "Σήμερα",
"days_other": "Σήμερα και {{count}} μέρες",
"weatherNeedsInternet": "Ο καιρός χρειάζεται internet: χωρίς αυτό (ή χωρίς πόλη) το στοιχείο κρύβεται."
"weatherNeedsInternet": "Ο καιρός χρειάζεται internet: χωρίς αυτό (ή χωρίς πόλη) το στοιχείο κρύβεται.",
"dragHint": "Συμβουλή: επιλέξτε ένα widget στην προεπισκόπηση, σύρετέ το για να το μετακινήσετε και από τις λαβές για να αλλάξετε το μέγεθος. Τα πεδία Θέση και Μέγεθος γράφουν τότε «Προσαρμοσμένο».",
"custom": "Προσαρμοσμένο",
"align": "Στοίχιση",
"alignAuto": "Αυτόματη",
"dateStyle": "Μορφή",
"canvas": "Τα widgets της διαφάνειας: σύρετε ένα για μετακίνηση, τις λαβές για μέγεθος, τα βέλη για μικρές κινήσεις"
},
"tabs": {
"playlists": "Λίστες",
@@ -1509,7 +1522,12 @@
"shape": "Σχήμα τηλεόρασης",
"nowScheduled": "Τώρα: {{name}} (από πρόγραμμα)",
"nowDefault": "Τώρα: {{name}} (η προεπιλογή της)",
"nowNothing": "Τώρα: τίποτα (κενή οθόνη)"
"nowNothing": "Τώρα: τίποτα (κενή οθόνη)",
"default": "Παίζει από προεπιλογή",
"defaultHint": "Όταν δεν ταιριάζει καμία γραμμή προγράμματος: μια λίστα ή μία διαφάνεια μόνη της.",
"aPlaylist": "Λίστα",
"aSlide": "Διαφάνεια",
"nowSlide": "Τώρα: {{name}} (η διαφάνεια προεπιλογής της)"
},
"schedules": {
"new": "Νέο πρόγραμμα",
@@ -1549,7 +1567,8 @@
"scene": "Μόνο σε σκηνή",
"anyScene": "Πάντα (χωρίς σκηνή)",
"enabled": "Ενεργή",
"playingNow": "Παίζει τώρα σε: {{names}}"
"playingNow": "Παίζει τώρα σε: {{names}}",
"smartDaysHint": "Μια γραμμή παίζει σε ημέρες της εβδομάδας ή σε έξυπνες ημέρες: η επιλογή του ενός καθαρίζει το άλλο. Για τα δύο, προσθέστε άλλη γραμμή με την ίδια λίστα."
},
"settings": {
"message": "Μήνυμα ημέρας",
@@ -1571,9 +1590,40 @@
"refresh": "Ενημέρωση τώρα",
"forget": "Αφαίρεση πόλης"
},
"slidesTab": {
"title": "Έρχονται διαφάνειες για επαναχρησιμοποίηση",
"body": "Εδώ θα φτιάχνετε μεμονωμένες διαφάνειες, θα τις κρατάτε και θα τις προσθέτετε σε όποια λίστα θέλετε."
"discardTitle": "Αλλαγές χωρίς αποθήκευση",
"discardYes": "Έξοδος χωρίς αποθήκευση",
"deleteSlideTitle": "Αφαίρεση «{{name}}»;",
"bgKind": "Είδος",
"dimLabel": "Σκούρεμα φωτογραφίας",
"textTitle": "Κείμενο",
"textLook": "Εμφάνιση κειμένου",
"textSizeLabel": "Μέγεθος κειμένου",
"library": {
"intro": "Διαφάνειες που φτιάχνετε μία φορά και κρατάτε: προσθέστε τες σε όποια λίστα θέλετε (Προσθήκη διαφάνειας → Οι διαφάνειές σας) ή δείξτε μία μόνη της σε μια οθόνη (Οθόνες).",
"new": "Νέα διαφάνεια",
"none": "Δεν έχετε κρατήσει διαφάνειες ακόμα.",
"noneHint": "Φτιάξτε μια διαφάνεια εδώ ή κρατήστε μία από μια λίστα (Κράτηση στις Διαφάνειες, κάτω από τις ρυθμίσεις της).",
"edit": "Επεξεργασία «{{name}}»",
"onScreens": "Προβάλλεται σε {{names}}",
"deleteTitle": "Διαγραφή «{{name}}»;",
"deleteBody": "Όσες λίστες πήραν αντίγραφό της το κρατούν.",
"deleteUsed": "Προβάλλεται σε {{names}}: αυτές οι οθόνες δεν θα δείχνουν τίποτα μέχρι να επιλέξετε κάτι άλλο. Οι λίστες κρατούν τα αντίγραφά τους.",
"newName": "{{kind}} (νέα)",
"back": "Πίσω στις διαφάνειες",
"untitled": "Διαφάνεια χωρίς όνομα",
"name": "Όνομα",
"description": "Σύντομη περιγραφή",
"descriptionHint": "Για να την ξεχωρίζετε: τι δείχνει και πότε τη χρησιμοποιείτε.",
"kindIs": "Είδος: {{kind}}",
"settings": "Ρυθμίσεις",
"yours": "Οι διαφάνειές σας",
"addHint": "Από την καρτέλα Διαφάνειες: ένα αντίγραφο μπαίνει σε αυτή τη λίστα.",
"noneYet": "Δεν έχετε κρατήσει διαφάνειες: φτιάξτε τες στην καρτέλα Διαφάνειες ή κρατήστε μία από μια λίστα.",
"keep": "Κράτηση στις Διαφάνειες",
"keepTitle": "Κράτηση αυτής της διαφάνειας",
"keepHint": "Ένα αντίγραφο της διαφάνειας όπως είναι τώρα πηγαίνει στην καρτέλα Διαφάνειες, για άλλες λίστες ή για να προβάλλεται μόνη της σε μια οθόνη.",
"keepYes": "Κράτηση",
"kept": "Κρατήθηκε στις Διαφάνειες."
}
},
"overview": {
+5
View File
@@ -550,6 +550,11 @@
"hint": "Τι παίζει αυτή η οθόνη (Προβολή).",
"none": "Τίποτα (κενή οθόνη)"
},
"slide": {
"label": "Διαφάνεια",
"hint": "Ή μία διαφάνεια από τη βιβλιοθήκη Διαφάνειες, όταν δεν έχει επιλεγεί λίστα προβολής.",
"none": "Καμία"
},
"orientation": {
"label": "Προσανατολισμός",
"hint": "Πώς κρέμεται η τηλεόραση: οι διαφάνειες φτιάχνονται για αυτό το σχήμα.",
+1
View File
@@ -26,6 +26,7 @@
},
"ui": {
"close": "Close",
"cancel": "Cancel",
"dismiss": "Dismiss",
"loading": "Loading",
"moreInfo": "More info",
+60 -10
View File
@@ -1270,7 +1270,9 @@
"image": "Picture",
"video": "Video",
"text": "Text",
"menu": "Menu board"
"menu": "Menu board",
"blank": "Blank",
"blankWidgets": "Blank with widgets"
},
"misfit": "This picture or video doesn't fit the playlist's shape: it will be cropped or have bars.",
"toTheEnd": "to the end",
@@ -1291,7 +1293,7 @@
"6": "Sun"
},
"duplicateSlide": "Duplicate the slide",
"deleteSlide": "Remove this slide?",
"deleteSlide": "It goes from this playlist. Its pictures and videos stay in the media library.",
"removed": "Slide removed.",
"addSlide": "Add a slide",
"added": "Slide added.",
@@ -1344,7 +1346,7 @@
"videoToEndHint": "Off: it shows for the seconds below (and repeats if it is shorter).",
"duration": "Seconds on screen",
"durationMenuHint": "A long menu turns its pages and stays as long as it needs.",
"transition": "Comes in with",
"transition": "Transition effect",
"transitionDefault": "The playlist's transition",
"when": "When it shows",
"whenHint": "Leave empty for always. Pick days, hours (they may pass midnight) or dates to show it only then. This narrows the playlist's schedule: a slide whose time is outside the hours its playlist plays never shows.",
@@ -1429,7 +1431,12 @@
"pageSeconds": "Seconds per page",
"language": "Language",
"languageHint": "The products' names on this board. Not translated: as typed.",
"asTyped": "As typed"
"asTyped": "As typed",
"which": "Products",
"layout": "Layout",
"width": "Width of the list",
"place": "Where the list sits",
"placeHint": "At the full width the list fills the screen: make it narrower to place it."
},
"badges": {
"new": "New",
@@ -1477,7 +1484,13 @@
"weatherDays": "Days",
"days_one": "Today",
"days_other": "Today and {{count}} days",
"weatherNeedsInternet": "The weather needs internet: without it (or without a town set) the widget is hidden."
"weatherNeedsInternet": "The weather needs internet: without it (or without a town set) the widget is hidden.",
"dragHint": "Tip: pick a widget on the preview, drag it to move it and its handles to size it. Where and size then read \"Custom\".",
"custom": "Custom",
"align": "Alignment",
"alignAuto": "Auto",
"dateStyle": "Style",
"canvas": "The slide's widgets: drag one to move it, its handles to size it, arrow keys to nudge it"
},
"tabs": {
"playlists": "Playlists",
@@ -1509,7 +1522,12 @@
"shape": "TV shape",
"nowScheduled": "Now: {{name}} (by a schedule)",
"nowDefault": "Now: {{name}} (its default)",
"nowNothing": "Now: nothing (a blank screen)"
"nowNothing": "Now: nothing (a blank screen)",
"default": "Plays by default",
"defaultHint": "When no schedule line matches: a playlist, or one slide shown alone.",
"aPlaylist": "Playlist",
"aSlide": "Slide",
"nowSlide": "Now: {{name}} (its default slide)"
},
"schedules": {
"new": "New schedule",
@@ -1549,7 +1567,8 @@
"scene": "Only during a scene",
"anyScene": "Always (no scene)",
"enabled": "On",
"playingNow": "Playing now on {{names}}"
"playingNow": "Playing now on {{names}}",
"smartDaysHint": "A line runs on weekdays or on smart days: picking one clears the other. For both, add another line with the same playlist."
},
"settings": {
"message": "Message of the day",
@@ -1571,9 +1590,40 @@
"refresh": "Fetch now",
"forget": "Remove the town"
},
"slidesTab": {
"title": "Slides to reuse are coming",
"body": "Here you will make single slides, keep them, and add them to any playlist."
"discardTitle": "Unsaved changes",
"discardYes": "Leave without saving",
"deleteSlideTitle": "Remove \"{{name}}\"?",
"bgKind": "Kind",
"dimLabel": "Darken the photo",
"textTitle": "Text",
"textLook": "Text look",
"textSizeLabel": "Text size",
"library": {
"intro": "Slides you build once and keep: add them to any playlist (Add a slide → Your slides), or show one alone on a screen (Screens).",
"new": "New slide",
"none": "No slides kept yet.",
"noneHint": "Build a slide here, or keep one from a playlist (Keep in Slides, under its settings).",
"edit": "Edit \"{{name}}\"",
"onScreens": "Shown on {{names}}",
"deleteTitle": "Delete \"{{name}}\"?",
"deleteBody": "Playlists that got a copy of it keep their copy.",
"deleteUsed": "It is shown on {{names}}: those screens will show nothing until you pick something else. Playlists keep their copies.",
"newName": "{{kind}} (new)",
"back": "Back to the slides",
"untitled": "A slide without a name",
"name": "Name",
"description": "Short description",
"descriptionHint": "To tell it apart later: what it shows and when you use it.",
"kindIs": "Kind: {{kind}}",
"settings": "Settings",
"yours": "Your slides",
"addHint": "From the Slides tab: a copy goes into this playlist.",
"noneYet": "No slides kept yet: build them in the Slides tab, or keep one from a playlist.",
"keep": "Keep in Slides",
"keepTitle": "Keep this slide",
"keepHint": "A copy of the slide as it is now goes to the Slides tab, to reuse in other playlists or show alone on a screen.",
"keepYes": "Keep it",
"kept": "Kept in Slides."
}
},
"overview": {
+5
View File
@@ -550,6 +550,11 @@
"hint": "What this screen plays (Signage).",
"none": "Nothing (a blank screen)"
},
"slide": {
"label": "Slide",
"hint": "Or a single slide from the Slides library, shown when no playlist is picked.",
"none": "None"
},
"orientation": {
"label": "Orientation",
"hint": "How the TV hangs: slides are built for this shape.",
+1
View File
@@ -29,6 +29,7 @@ export function useUiLabels() {
const language = i18n.resolvedLanguage || i18n.language
return useMemo(() => ({
close: t('ui.close'),
cancel: t('ui.cancel'),
dismiss: t('ui.dismiss'),
loading: t('ui.loading'),
moreInfo: t('ui.moreInfo'),
+3 -2
View File
@@ -1,8 +1,8 @@
// One slide as a TV shows it (plan step 5.6a): picture, video, text or menu board. Used by the
// One slide as a TV shows it (plan step 5.6a): picture, video, text, menu board or blank (2026-11-21). 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'
import { BlankSlide, MenuSlide, TextSlide } from './Slides.jsx'
export function SlideView({ slide, media, venue, now, pages, page, onEnded, playing = true }) {
return (
@@ -10,6 +10,7 @@ export function SlideView({ slide, media, venue, now, pages, page, onEnded, play
{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 === 'blank' && <BlankSlide 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} />}
</>
)
+96 -30
View File
@@ -5,7 +5,7 @@
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'
import { fitUnit, FONTS, textWidth, weatherIcon, widgetAlign } from './logic'
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
export function Background({ bg, media }) {
@@ -19,6 +19,7 @@ export function Background({ bg, media }) {
}
const JUSTIFY = { top: 'flex-start', middle: 'center', bottom: 'flex-end' }
const BOARD_ALIGN = { left: 'flex-start', center: 'center', right: 'flex-end' }
const hasBar = (c, where) => (c.widgets || []).some(w => w.position === where)
export function TextSlide({ content: c, media, venue, now }) {
@@ -38,6 +39,16 @@ export function TextSlide({ content: c, media, venue, now }) {
)
}
/** A blank slide (2026-11-21): its background and its widgets, nothing else. */
export function BlankSlide({ content: c, media, venue, now }) {
return (
<div className="absolute inset-0" data-testid="signage-blank">
<Background bg={c.background} media={media} />
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} />
</div>
)
}
/** 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')
@@ -52,7 +63,11 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
<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` }}
data-testid="signage-menu" data-page={page} data-pages={pages.length}>
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: accent, lineHeight: 1.1 }}>{c.title}</h1>}
{/* 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'}>
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: 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, columnFill: 'auto' }}>
{groups.map((g, i) => (
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '1.6cqmin' }}>
@@ -91,13 +106,14 @@ export function MenuSlide({ slide, media, venue, now, page, pages }) {
{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>
<Widgets widgets={c.widgets} media={media} venue={venue} now={now} colour={c.text_colour} />
</div>
)
}
// ── widgets (5.5b) ──────────────────────────────────────────────────────────
// ── widgets (5.5b; placed by hand on the editor's preview, owner 2026-11-21) ────
const SIZE = { small: 0.75, medium: 1, large: 1.4 }
const CORNER = {
@@ -108,11 +124,19 @@ const CORNER = {
'bottom-center': { bottom: '3cqmin', left: '50%', transform: 'translateX(-50%)', alignItems: 'center' },
'bottom-right': { bottom: '3cqmin', right: '3cqmin', alignItems: 'flex-end' },
}
const SELF = { left: 'flex-start', center: 'center', right: '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, or (moved and sized by hand: position
* "custom") each in its own box, scaled to fill it. One that has nothing to show is left out.
* Each carries `data-widget` = its index in the slide's list (the editor's handles find it so).
*/
export function Widgets({ widgets, media, venue, now, colour }) {
const fmt = useFormat()
if (!widgets?.length) return null
const bar = where => widgets.filter(w => w.position === where)
const ctx = { media, venue, now, fmt }
const shown = widgets.map((w, i) => [w, i, widgetBody(w, ctx, w.position === 'custom' && !!w.box)]).filter(([, , body]) => body)
const bar = where => shown.filter(([w]) => w.position === where)
const bars = [['top-bar', { top: 0 }], ['bottom-bar', { bottom: 0 }]]
return (
<>
@@ -120,59 +144,99 @@ export function Widgets({ widgets, media, venue, now, colour }) {
<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' }}>
{bar(where).map((w, i) => <Widget key={i} w={w} media={media} venue={venue} now={now} />)}
{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>
))}
{widgets.filter(w => CORNER[w.position]).map((w, i) => (
<div key={`c${i}`} className="absolute" style={{ ...CORNER[w.position], display: 'flex', flexDirection: 'column', color: colour || '#fff' }}>
<Widget w={w} media={media} venue={venue} now={now} />
{shown.filter(([w]) => CORNER[w.position]).map(([w, i, body]) => {
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {}
return (
<div key={`c${i}`} data-widget={i} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff' }}>
{body}
</div>
)
})}
{shown.filter(([w]) => w.position === 'custom' && w.box).map(([w, i, body]) => (
<div key={`b${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) }}>
{body}
</div>
</div>
))}
</>
)
}
const ICONS = { sun: Sun, moon: Moon, 'cloud-sun': CloudSun, 'cloud-moon': CloudMoon, cloud: Cloud, fog: CloudFog, rain: CloudRain, snow: CloudSnow, storm: CloudLightning }
const OBJECT_POSITION = { left: 'left center', center: 'center', right: 'right center' }
function Widget({ w, media, venue, now }) {
const { formatDate, formatTime } = useFormat()
/**
* What one widget shows, or null when it has nothing to show. Sizes are "usual units" (cqmin of
* the slide at size medium); `fit`: the widget fills its own box instead (fitUnit).
*/
function widgetBody(w, { media, venue, now, fmt }, fit) {
const { formatDate, formatTime } = fmt
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)' }
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 })
if (w.kind === 'logo') {
const m = media(w.media_id)
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 (!m) return null
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" />
}
if (w.kind === 'name') {
if (!venue?.name) return null
const u = unit(4.2 * 1.15, textWidth(venue.name.length, 4.2))
return <span style={text(u, 4.2)} data-testid="signage-w-name">{venue.name}</span>
}
if (w.kind === 'date') {
const str = formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong')
const u = unit(3.4 * 1.15, textWidth(str.length, 3.4))
return <span style={text(u, 3.4)} data-testid="signage-w-date">{str}</span>
}
if (w.kind === 'clock') {
const u = unit(4.6 * 1.15, textWidth(w.clock_seconds ? 8 : 5, 4.6)) // its usual width: the size stays as the minutes turn
return <span style={{ ...text(u, 4.6), fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">{formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')}</span>
}
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 === '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') {
const msg = w.text || venue?.message
return msg ? <span style={{ ...text, fontWeight: 600 }} data-testid="signage-w-message">{msg}</span> : null
if (!msg) return null
const u = unit(3.4 * 1.15, textWidth(msg.length, 3.4))
return <span style={text(u, 3.4, 600)} data-testid="signage-w-message">{msg}</span>
}
if (w.kind === 'qr') {
return 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: '1cqmin', borderRadius: '1cqmin', lineHeight: 0 }}>
<QRCodeSVG value={w.link} size={256} style={{ width: `${14 * s}cqmin`, height: `${14 * s}cqmin` }} />
if (!w.link) return null
const caption = w.qr_caption ? 2.4 * 1.15 + 0.8 : 0
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={w.link}>
<div style={{ background: '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
<QRCodeSVG value={w.link} size={256} style={{ width: u(14), height: u(14) }} />
</div>
{w.qr_caption && <span style={{ ...text, fontSize: `${2.4 * s}cqmin` }}>{w.qr_caption}</span>}
{w.qr_caption && <span style={text(u, 2.4)}>{w.qr_caption}</span>}
</div>
) : 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'
const days = (w.weather_days || 1) > 1 ? (wx.days || []).slice(1, w.weather_days) : []
const u = unit(6, 6 + 1.5 + textWidth(4, 4.4) + days.length * (1.5 + 3.4 + textWidth(12, 2.4)))
return (
<div style={{ display: 'flex', alignItems: 'center', gap: '1.5cqmin' }} data-testid="signage-w-weather">
<Icon style={{ width: `${6 * s}cqmin`, height: `${6 * s}cqmin` }} aria-hidden="true" />
<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 => {
<div style={{ display: 'flex', alignItems: 'center', gap: u(1.5) }} data-testid="signage-w-weather">
<Icon style={{ width: u(6), height: u(6), flexShrink: 0 }} aria-hidden="true" />
<span style={text(u, 4.4)}>{Math.round(wx.temperature)}{deg}</span>
{days.map(d => {
const DayIcon = ICONS[weatherIcon(d.code, true)] || Cloud
return (
<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}cqmin`, height: `${3.4 * s}cqmin` }} aria-hidden="true" />
<span key={d.date} style={{ display: 'flex', alignItems: 'center', gap: u(0.6), ...text(u, 2.4, 600) }}>
{formatDate(`${d.date}T12:00:00Z`, 'weekday').slice(0, 3)} <DayIcon style={{ width: u(3.4), height: u(3.4) }} aria-hidden="true" />
{Math.round(d.max)}° / {Math.round(d.min)}°
</span>
)
@@ -182,3 +246,5 @@ function Widget({ w, media, venue, now }) {
}
return null
}
const ICONS = { sun: Sun, moon: Moon, 'cloud-sun': CloudSun, 'cloud-moon': CloudMoon, cloud: Cloud, fog: CloudFog, rain: CloudRain, snow: CloudSnow, storm: CloudLightning }
+1 -1
View File
@@ -2,5 +2,5 @@
// 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 { Background, BlankSlide, MenuSlide, TextSlide, Widgets } from './Slides.jsx'
export { SlideView } from './SlideView.jsx'
+32
View File
@@ -248,3 +248,35 @@ export function boardPages(slide, rotation, w, h) {
const per = c.page_size || rows * (c.columns || 2)
return menuPages(slide.menu?.groups || [], per, c.category_titles !== false)
}
// ── widgets placed by hand (owner 2026-11-21) ─────────────────────────────────
/** The slide kinds that carry widgets. */
export const WIDGET_HOSTS = ['text', 'menu', 'blank']
/** How a widget lines up inside its place: its own choice, else by its corner / its box's side. */
export function widgetAlign(w) {
if (w?.align && w.align !== 'auto') return w.align
if (w?.position === 'custom' && w.box) {
const mid = w.box.x + w.box.w / 2
return mid < 100 / 3 ? 'left' : mid > 200 / 3 ? 'right' : 'center'
}
const p = w?.position || ''
return p.endsWith('left') ? 'left' : p.endsWith('right') ? 'right' : p.endsWith('center') ? 'center' : 'left'
}
/**
* A size unit for a widget that fills its own box: `n` units of its usual size (cqmin at "medium")
* scaled so the whole widget, `height` × `width` usual units, fits the box (inside an element with
* `container-type: size`). → n → CSS length.
*/
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))`
}
/** A line of `chars` characters at `size` usual units: about how wide it is (bold sans). */
export function textWidth(chars, size) {
return Math.max(1, chars) * size * 0.6
}
+19
View File
@@ -136,3 +136,22 @@ test('smart days and scenes, the same dates as the server (owner 2026-11-21)', a
assert.equal(pick(entries, 99, sat, [1]), 50)
assert.ok(!matches({ scene_id: 2 }, sat, [1]))
})
test('widgets placed by hand: how they line up, and a unit that fills their box (2026-11-21)', async () => {
const { fitUnit, textWidth, widgetAlign } = await import('../src/logic.js')
assert.equal(widgetAlign({ position: 'top-right' }), 'right')
assert.equal(widgetAlign({ position: 'bottom-center' }), 'center')
assert.equal(widgetAlign({ position: 'top-bar' }), 'left')
assert.equal(widgetAlign({ position: 'top-left', align: 'center' }), 'center') // its own choice
assert.equal(widgetAlign({ position: 'custom', box: { x: 70, y: 0, w: 25, h: 10 } }), 'right') // by its box's side
assert.equal(widgetAlign({ position: 'custom', box: { x: 40, y: 0, w: 20, h: 10 } }), 'center')
assert.equal(fitUnit(5, 20)(2.5), 'calc(2.5 * min(20cqh, 5cqw))')
assert.equal(textWidth(5, 4), 12)
})
test('a screen whose default is a library slide plays it when no line matches', () => {
const one = { id: 'slide:3', slides: [{ id: 3 }] }
const data = { schedule: { entries: [{ playlist_id: 1, date_from: '2000-01-01', date_to: '2000-01-01' }], fallback_playlist_id: 'slide:3', scenes: [], timezone: 'Europe/Athens' },
playlists: { 1: { id: 1, slides: [] }, 'slide:3': one } }
assert.equal(playlistNow(data, new Date('2026-11-21T12:00:00Z')), one)
})
+10
View File
@@ -342,6 +342,13 @@
.x-switch-row__label { display: block; font-size: var(--x-text-body); line-height: var(--x-leading-body); font-weight: var(--x-weight-medium); color: var(--x-ink); cursor: pointer; }
.x-switch-row__description { margin-top: var(--x-space-0-5); font-size: var(--x-text-label); line-height: var(--x-leading-label); color: var(--x-ink-2); }
.x-switch-row--disabled .x-switch-row__label { cursor: not-allowed; opacity: 0.6; }
/* boxed (2026-11-21): a switch in a row of fields, as tall and as framed as an input beside it */
.x-switch-row--boxed {
box-sizing: border-box; min-height: var(--x-control-md); padding: var(--x-space-2) var(--x-space-3);
background: var(--x-surface); border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control);
}
.x-switch-row--boxed .x-switch-row__label { font-size: var(--x-text-label); }
.x-confirm__body { font-size: var(--x-text-body); line-height: var(--x-leading-body); color: var(--x-ink-2); }
/* ── ReasonPicker ───────────────────────────────────────────────────────────── */
.x-reasons { display: grid; gap: var(--x-space-2); }
@@ -514,6 +521,9 @@
border: var(--x-border-width) solid var(--x-line-strong); border-radius: var(--x-radius-control); background: var(--x-surface-2);
}
.x-segmented--sm { min-height: var(--x-control-sm); }
/* fill (2026-11-21): as wide as its column, the options sharing the width */
.x-segmented--fill { display: flex; width: 100%; }
.x-segmented--fill > .x-segmented__item { flex: 1 1 0; justify-content: center; }
.x-segmented__item {
display: inline-flex; align-items: center; gap: var(--x-space-1-5); padding: 0 var(--x-space-3);
border: 0; border-radius: calc(var(--x-radius-control) - 3px); background: transparent; color: var(--x-ink-2);
@@ -0,0 +1,41 @@
import { useCallback, useState } from 'react'
import { Button } from './Button.jsx'
import { Dialog } from './Dialog.jsx'
import { useLabels } from './labels.js'
/**
* Asks before doing something: a small dialog inside the page, never the browser's confirm()
* (2026-11-21). tone 'danger' for deleting / throwing work away.
* <ConfirmDialog open title="Delete this slide?" confirmLabel="Delete" tone="danger"
* onConfirm={remove} onCancel={close}>It goes from the playlist.</ConfirmDialog>
*/
export function ConfirmDialog({ open, title, children, confirmLabel, cancelLabel, tone = 'primary', onConfirm, onCancel, busy = false, testId }) {
const labels = useLabels()
return (
<Dialog open={open} size="sm" title={title} onClose={onCancel}
footer={<>
<Button variant="secondary" onClick={onCancel} data-testid={testId ? `${testId}-cancel` : 'confirm-cancel'}>{cancelLabel ?? labels.cancel}</Button>
<Button variant={tone === 'danger' ? 'danger' : 'primary'} loading={busy} onClick={onConfirm}
data-testid={testId ? `${testId}-ok` : 'confirm-ok'}>{confirmLabel ?? labels.submit}</Button>
</>}>
{children && <div className="x-confirm__body">{children}</div>}
</Dialog>
)
}
/**
* The same as a hook that answers with a promise:
* const [confirm, confirmDialog] = useConfirm()
* if (!(await confirm({ title, body, confirmLabel, tone: 'danger' }))) return
* …render {confirmDialog} somewhere in the component.
*/
export function useConfirm() {
const [ask, setAsk] = useState(null)
const confirm = useCallback(opts => new Promise(resolve => setAsk({ ...opts, resolve })), [])
const answer = value => { ask?.resolve(value); setAsk(null) }
const dialog = ask ? (
<ConfirmDialog open title={ask.title} confirmLabel={ask.confirmLabel} cancelLabel={ask.cancelLabel} tone={ask.tone} testId={ask.testId}
onConfirm={() => answer(true)} onCancel={() => answer(false)}>{ask.body}</ConfirmDialog>
) : null
return [confirm, dialog]
}
+5 -4
View File
@@ -42,15 +42,16 @@ export function FilterChip({ pressed = false, tone = 'neutral', count, size = 'm
}
/**
* A few mutually exclusive views (List / Map). options: [{ value, label, icon? }].
* A few mutually exclusive views (List / Map). options: [{ value, label, icon?, ariaLabel? }]
* (ariaLabel: the name of an option shown as an icon only). fill: as wide as its column, the options sharing it.
* <Segmented value={view} onChange={setView} options={[…]} aria-label="View" />
*/
export function Segmented({ options = [], value, onChange, size = 'md', className, ...rest }) {
export function Segmented({ options = [], value, onChange, size = 'md', fill = false, className, ...rest }) {
return (
<div role="group" className={cx('x-segmented', `x-segmented--${size}`, className)} {...rest}>
<div role="group" className={cx('x-segmented', `x-segmented--${size}`, fill && 'x-segmented--fill', className)} {...rest}>
{options.map(o => (
<button key={o.value} type="button" aria-pressed={o.value === value} className={cx('x-segmented__item', o.value === value && 'x-segmented__item--on')}
onClick={() => onChange?.(o.value)} data-testid={o.testId}>
onClick={() => onChange?.(o.value)} data-testid={o.testId} aria-label={o.ariaLabel} title={o.ariaLabel}>
{o.icon}{o.label}
</button>
))}
+3 -2
View File
@@ -7,8 +7,9 @@ import { cx } from '../internal/cx.js'
* onChange receives the new boolean. Without `label`, pass aria-label.
* The whole row (label + description) is clickable.
* info: an element right after the label (an <InfoTip>), not after the switch.
* boxed: framed and as tall as an input, the text left and the switch right (a switch in a row of fields).
*/
export function Switch({ checked, onChange, label, description, info, disabled = false, id, className, ...rest }) {
export function Switch({ checked, onChange, label, description, info, disabled = false, boxed = false, id, className, ...rest }) {
const auto = useId()
const switchId = id || auto
const descId = `${switchId}-desc`
@@ -31,7 +32,7 @@ export function Switch({ checked, onChange, label, description, info, disabled =
if (!label && !description) return <span className={cx('x-switch-bare', className)}>{control}</span>
return (
<div className={cx('x-switch-row', disabled && 'x-switch-row--disabled', className)}>
<div className={cx('x-switch-row', boxed && 'x-switch-row--boxed', disabled && 'x-switch-row--disabled', className)}>
<div className="x-switch-row__text">
{label && (
<span className="x-switch-row__head">
+1
View File
@@ -7,6 +7,7 @@ import { createContext, createElement, useContext } from 'react'
export const DEFAULT_LABELS = {
close: 'Close',
cancel: 'Cancel',
dismiss: 'Dismiss',
loading: 'Loading',
moreInfo: 'More info',
+1
View File
@@ -11,6 +11,7 @@
export { Button, IconButton } from './components/Button.jsx'
export { Dialog } from './components/Dialog.jsx'
export { ConfirmDialog, useConfirm } from './components/ConfirmDialog.jsx'
export { Sheet } from './components/Sheet.jsx'
export { PrintArea, PrintSheet } from './components/PrintArea.jsx'
export { ToastProvider } from './components/Toast.jsx'