feat(signage): widget settings regrouped (main / Text and colours / More), alignment that lines up multi-line widgets, multi-line texts, gallery title, logos larger than the slide; calibration past the recognised resolution and shown the first time

Owner review 2026-11-23 of every widget:
- A widget card is its main settings (the row and what needs room under it: pictures, a gallery's
  pictures or folder, weather details and place, a countdown's start and end, reviews' stars and
  author, a scrolling text's speed, a shape's colours and border, QR caption), then "Text and
  colours" (new LookFields.jsx: text colour, plate, font, style, size, weight, highlight, shadow,
  QR colours; a logo's / gallery's border), then More settings (opacity, rotation, animation, fit,
  typing, blink, QR logo; shadow / border only where there is no Text and colours).
- Date format / separator and clock 12/24 / separator are main settings.
- Alignment only where it lines something up; the TV now aligns the lines of a text, the hours
  (centre: days and times meet in the middle), contact rows, Wi-Fi (code left / right / above),
  the weather's column / card / list / hourly, reviews (stars too), a countdown, a QR caption.
- Text and message: a 2-line textarea in its own row; Enter makes new lines (the TV sizes by the
  longest line and the number of lines).
- Gallery: a title above or below the pictures (title_position).
- A widget's box may reach 400 % of the slide (a logo zoomed in past the slide's edges saved again).
- "Auto" stays "Auto" in Greek; scrolling text Left / Right; reviews' stars choice no longer clipped;
  countdown "When it ends" hint as an info tip (fields level).

Calibration: an edge may go past the recognised window (down to -2000 px); the dialog's rows are
centred, "Each click moves" sits above its choice, the window size is labelled "Recognised
resolution" with what it means; the TV asks for its screen answer on every calibrate event and
while calibrating (the outline shows the first time), the dialog sends "on" again after 1.5 s.
NumberInput takes a leading minus when min < 0. E2E: waits for the Add-a-slide dialog to go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 05:40:04 +02:00
co-authored by Claude Opus 5.5
parent 1b111c0e27
commit cd8218689c
20 changed files with 431 additions and 257 deletions
@@ -3,6 +3,10 @@
// pixel by pixel (or in steps of 10 / 50 px), or a preset sets the largest box of a common shape in
// the middle of the TV's window (it reports its size). Every change reaches the TV at once; closing
// ends the calibration (the TV also stops by itself after 15 min).
// Owner 2026-11-23: every row centred; "Each click moves" above its choice; the window size is
// marked as the one the TV reported (recognised), and an edge may go past it (below 0 px) when the
// TV's real picture is larger; "on" is sent again a moment after opening (the TV shows the outline
// the first time).
import { useCallback, useEffect, useRef, useState } from 'react'
import toast from 'react-hot-toast'
import { errorMessage } from '@xenia/api'
@@ -15,6 +19,7 @@ import { ShapeMark } from './ShapeField'
const EDGES = ['top', 'right', 'bottom', 'left']
const PRESETS = ['full', '16:9', '16:10', '21:9', '32:9', '4:3', '9:16']
const SAVE_MS = 200
const OUT = 2000 // px an edge may reach past the recognised window
export default function CalibrateDialog({ screen, onClose, onSaved }) {
const { t } = useTranslation('manager')
@@ -30,7 +35,8 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
useEffect(() => {
const mine = ++alive.current
api.calibrateScreen(screen.id, true).catch(err => toast.error(errorMessage(err, t)))
return () => { setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, false).catch(() => {}) }, 300) }
const again = setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, true).catch(() => {}) }, 1500)
return () => { clearTimeout(again); setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, false).catch(() => {}) }, 300) }
}, [screen.id]) // eslint-disable-line react-hooks/exhaustive-deps
// the TV's window size (it reports it when it starts and when it changes)
useEffect(() => {
@@ -54,15 +60,20 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
useEffect(() => () => clearTimeout(timer.current), [])
const win = viewport ? { w: viewport.width, h: viewport.height } : null
const pic = win ? pictureArea(win, area) : null
const setEdge = (edge, v) => change({ ...area, [edge]: Math.max(0, Math.min(4000, v ?? 0)) })
const setEdge = (edge, v) => change({ ...area, [edge]: Math.max(-OUT, Math.min(4000, v ?? 0)) })
// the diagram: the TV's window and the picture inside it, to scale
// the diagram: the recognised window (dashed) and the picture, to scale; a picture reaching past
// the window makes the drawing as large as both
const bounds = win && pic ? {
x: Math.min(0, pic.left), y: Math.min(0, pic.top),
r: Math.max(win.w, pic.left + pic.width), b: Math.max(win.h, pic.top + pic.height),
} : null
const W = 320
const H = win ? Math.round(W * win.h / win.w) : 180
const k = win ? W / win.w : 0
const H = bounds ? Math.round(W * (bounds.b - bounds.y) / (bounds.r - bounds.x)) : 180
const k = bounds ? W / (bounds.r - bounds.x) : 0
const edge = e => (
<Field label={t(`signage.calibrate.edges.${e}`)} className="w-36">
<NumberInput size="sm" value={area[e]} min={0} max={4000} step={step} suffix="px" onChange={v => setEdge(e, v)} data-testid={`signage-calibrate-${e}`} />
<NumberInput size="sm" value={area[e]} min={-OUT} max={4000} step={step} suffix="px" onChange={v => setEdge(e, v)} data-testid={`signage-calibrate-${e}`} />
</Field>
)
return (
@@ -71,13 +82,17 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
<Button variant="secondary" onClick={() => change({ left: 0, top: 0, right: 0, bottom: 0 })} data-testid="signage-calibrate-reset">{t('signage.calibrate.reset')}</Button>
<Button onClick={onClose} data-testid="signage-calibrate-done">{t('signage.calibrate.done')}</Button>
</>}>
<div className="grid gap-5" data-testid="signage-calibrate-dialog">
<p className="text-label text-ink-2" data-testid="signage-calibrate-window">
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
</p>
<div className="grid gap-2">
<div className="grid gap-5 justify-items-center text-center" data-testid="signage-calibrate-dialog">
<div className="grid gap-1 justify-items-center">
<span className="text-caption font-medium text-ink-3 uppercase tracking-wide">{t('signage.calibrate.recognised')}</span>
<p className="text-body-lg font-semibold text-ink tabular-nums" data-testid="signage-calibrate-window">
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
</p>
{win && <p className="text-caption text-ink-3 max-w-md">{t('signage.calibrate.recognisedHint')}</p>}
</div>
<div className="grid gap-2 justify-items-center">
<span className="text-label font-medium text-ink">{t('signage.calibrate.presets')}</span>
<div className="flex flex-wrap gap-1.5">
<div className="flex flex-wrap justify-center gap-1.5">
{PRESETS.map(p => (
<Button key={p} size="sm" variant="secondary" disabled={!win} onClick={() => change(presetInsets(win, p))} data-preset={p}
icon={p === 'full' ? undefined : <ShapeMark shape={p} size={16} />}>
@@ -86,7 +101,7 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
))}
</div>
</div>
<div className="flex flex-wrap items-center gap-3">
<div className="grid gap-2 justify-items-center">
<span className="text-label font-medium text-ink">{t('signage.calibrate.step')}</span>
<Segmented value={step} onChange={setStep} options={[1, 10, 50].map(n => ({ value: n, label: `${n} px` }))} data-testid="signage-calibrate-step" />
</div>
@@ -94,13 +109,15 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
{edge('top')}
<div className="flex items-center gap-3 flex-wrap justify-center">
{edge('left')}
<div className="relative rounded-control border border-line-strong bg-surface-2" style={{ width: W, height: H }} aria-hidden="true">
{pic && (
<div className="relative rounded-control bg-surface-2" style={{ width: W, height: H }} aria-hidden="true" data-testid="signage-calibrate-diagram">
{pic && bounds && <>
<div className="absolute border-2 border-accent bg-accent-soft grid place-items-center text-caption text-accent-ink tabular-nums"
style={{ left: pic.left * k, top: pic.top * k, width: pic.width * k, height: pic.height * k }}>
style={{ left: (pic.left - bounds.x) * k, top: (pic.top - bounds.y) * k, width: pic.width * k, height: pic.height * k }}>
{Math.round(pic.width)} × {Math.round(pic.height)}
</div>
)}
<div className="absolute border border-dashed border-line-strong rounded-[2px] pointer-events-none"
style={{ left: -bounds.x * k, top: -bounds.y * k, width: win.w * k, height: win.h * k }} />
</>}
</div>
{edge('right')}
</div>
@@ -109,7 +126,9 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
<p className="text-label text-ink-2 text-center" data-testid="signage-calibrate-picture">
{pic ? t('signage.calibrate.picture', { w: Math.round(pic.width), h: Math.round(pic.height), shape: shapeName(pic.width, pic.height) }) : ''}
</p>
<p className="text-caption text-ink-3 max-w-md">{t('signage.calibrate.edgesHint')}</p>
{EDGES.some(e => area[e] > 0) && <p className="text-caption text-ink-3">{t('signage.calibrate.outside')}</p>}
{EDGES.some(e => area[e] < 0) && <p className="text-caption text-warning-ink" data-testid="signage-calibrate-past">{t('signage.calibrate.past')}</p>}
</div>
</Dialog>
)
@@ -0,0 +1,98 @@
// A widget's "Text and colours" (owner review 5, 2026-11-21; owner 2026-11-23: everything about its
// text and colours in one place): its text colour (text and pictures; empty = the slide's), a plate
// behind it, its font, bold / italic / underline, text size and weight, a highlight behind the text,
// its shadow (and the shadow's colour); a QR code's dots and background; a picture's (logo, gallery)
// border. A menu, a stack and a shape have none (their own look / their main settings).
import { useState } from 'react'
import { Bold, ChevronDown, Italic, Palette, Underline } from 'lucide-react'
import { useTranslation } from '@xenia/i18n'
import { ColourField, Dropdown, Field, FieldRow, Segmented, Slider } from '@xenia/ui'
import { FONT_KEYS, FRAMED, lookKind, WIDGET_COLOURS } from './signageLogic'
// which widgets have text (their colour, font, style, size, weight, highlight)
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews', 'gallery']
const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900]
export default function LookFields({ w, set }) {
const { t } = useTranslation('manager')
const [open, setOpen] = useState(false)
if (!lookKind(w.kind)) return null
const text = TEXT_KINDS.includes(w.kind)
const framed = FRAMED.includes(w.kind)
const m = 'signage.more'
const changed = !!(w.colour || w.background_colour || w.font || w.bold != null || w.italic || w.underline || (w.text_size && w.text_size !== 100) || w.qr_colour || w.qr_background
|| w.weight || w.highlight || (w.shadow && w.shadow !== 'none') || (framed && (w.border_width || w.border_radius)))
const styles = [w.bold !== false && 'bold', w.italic && 'italic', w.underline && 'underline'].filter(Boolean)
return (
<div className="grid gap-2" data-testid="signage-widget-look">
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-look-toggle"
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
<Palette size={15} aria-hidden="true" />{t('signage.widgets.look')}
{changed && <span className="w-1.5 h-1.5 rounded-full bg-accent" aria-hidden="true" />}
<ChevronDown size={15} className={`transition-transform duration-fast ${open ? 'rotate-180' : ''}`} aria-hidden="true" />
</button>
{open && (
<FieldRow className="-mx-3" min="10rem">
{text && <ColourField label={t('signage.widgets.colour')} value={w.colour || WIDGET_COLOURS.text} onChange={colour => set({ colour })} testId="signage-widget-colour"
auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />}
<ColourField label={t('signage.widgets.plate')} value={w.background_colour || WIDGET_COLOURS.plate} onChange={background_colour => set({ background_colour })} testId="signage-widget-plate"
auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} />
{text && <>
<Field label={t('signage.font')}>
<Dropdown value={w.font || ''} onChange={v => set({ font: v || null })} data-testid="signage-widget-font"
options={[{ value: '', label: t('signage.widgets.asSlide') }, ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]} />
</Field>
<Field label={t('signage.look.f.widget.style')}>
<Segmented multiple fill value={styles} data-testid="signage-widget-style"
onChange={list => set({ bold: list.includes('bold') ? null : false, italic: list.includes('italic'), underline: list.includes('underline') })}
options={[['bold', Bold], ['italic', Italic], ['underline', Underline]].map(([v, Icon]) => (
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.look.${v}`), testId: `signage-widget-${v}` }))} />
</Field>
<Slider label={t('signage.widgets.textSize')} value={w.text_size || 100} min={50} max={200} step={10} suffix="%" onChange={text_size => set({ text_size })} testId="signage-widget-text-size" />
<Field label={t(`${m}.weight`)}>
<Dropdown value={w.weight || ''} onChange={v => set({ weight: v === '' ? null : Number(v) })} data-testid="signage-more-weight"
options={[{ value: '', label: t(`${m}.usual`) }, ...WEIGHTS.map(n => ({ value: n, label: t(`${m}.weights.${n}`) }))]} />
</Field>
<ColourField label={t(`${m}.highlight`)} value={w.highlight || WIDGET_COLOURS.plate} onChange={highlight => set({ highlight })} testId="signage-more-highlight"
auto={{ label: t(`${m}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} />
</>}
<ShadowFields w={w} set={set} />
{(w.kind === 'qr' || w.kind === 'wifi') && <>
<ColourField label={t('signage.widgets.qrColour')} value={w.qr_colour || WIDGET_COLOURS.qr} onChange={qr_colour => set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} />
<ColourField label={t('signage.widgets.qrBackground')} value={w.qr_background || WIDGET_COLOURS.qrBackground} onChange={qr_background => set({ qr_background })} testId="signage-widget-qr-background" />
</>}
{framed && <BorderFields w={w} set={set} />}
</FieldRow>
)}
</div>
)
}
/** A widget's shadow and its colour (here, or under More settings for a widget without Text and colours). */
export function ShadowFields({ w, set }) {
const { t } = useTranslation('manager')
const m = 'signage.more'
return (<>
<Field label={t(`${m}.shadow`)}>
<Dropdown value={w.shadow || 'none'} onChange={shadow => set({ shadow })} data-testid="signage-more-shadow"
options={['none', 'soft', 'strong', 'glow'].map(x => ({ value: x, label: t(`${m}.shadows.${x}`) }))} />
</Field>
{w.shadow && w.shadow !== 'none' && (
<ColourField label={t(`${m}.shadowColour`)} value={w.shadow_colour || WIDGET_COLOURS.plate} onChange={shadow_colour => set({ shadow_colour })}
auto={{ label: t(`${m}.usual`), on: !w.shadow_colour, pick: () => set({ shadow_colour: null }) }} />
)}
</>)
}
/** A widget's border: its width, colour and rounded corners. */
export function BorderFields({ w, set }) {
const { t } = useTranslation('manager')
const m = 'signage.more'
return (<>
<Slider label={t(`${m}.border`)} value={w.border_width || 0} min={0} max={20} onChange={border_width => set({ border_width })} testId="signage-more-border" />
{w.border_width > 0 && (
<ColourField label={t(`${m}.borderColour`)} value={w.border_colour || WIDGET_COLOURS.text} onChange={border_colour => set({ border_colour })} />
)}
<Slider label={t(`${m}.radius`)} value={w.border_radius || 0} min={0} max={100} step={5} onChange={border_radius => set({ border_radius })} />
</>)
}
@@ -2,27 +2,26 @@
// for every widget its opacity, rotation (steps or any angle), shadow, border and an entrance
// animation; a logo's fit; for texts the weight, a highlight behind them and typing themselves out;
// date and clock formats; a logo in the middle of a QR code. The TV draws them (Slides.jsx `fx`,
// `animate`, `dateText`).
// `animate`, `dateText`). Owner 2026-11-23: the weight, highlight and shadow moved to "Text and
// colours" (LookFields; the shadow stays here for a menu, a stack, a shape), a logo's / gallery's
// border too, the date's and clock's formats to their main settings.
import { useState } from 'react'
import { ChevronDown, SlidersHorizontal } from 'lucide-react'
import { useTranslation } from '@xenia/i18n'
import { ColourField, Dropdown, Field, FieldRow, Segmented, Slider, Switch } from '@xenia/ui'
import { Dropdown, Field, FieldRow, Segmented, Slider, Switch } from '@xenia/ui'
import { BorderFields, ShadowFields } from './LookFields'
import { MediaPick } from './SignageFields'
import { moreChanged, WIDGET_COLOURS } from './signageLogic'
import { FRAMED, lookKind, moreChanged } from './signageLogic'
const TEXTS = ['name', 'date', 'clock', 'message', 'text', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'weather']
const TYPED = ['name', 'message', 'text']
const ANIMATIONS = ['none', 'fade', 'rise', 'drop', 'slide-left', 'slide-right', 'zoom', 'pop', 'pulse', 'float']
const DELAYS = [0, 5, 10, 15, 20, 30, 50]
const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900]
const DATE_FORMATS = ['long', 'weekday_day_month', 'day_month', 'weekday', 'numeric', 'numeric_short', 'iso']
export default function MoreSettings({ w, set, media = {}, onMedia }) {
const { t } = useTranslation('manager')
const [open, setOpen] = useState(false)
const k = 'signage.more'
const text = TEXTS.includes(w.kind)
const numeric = ['numeric', 'numeric_short', 'iso'].includes(w.date_format)
const look = lookKind(w.kind)
return (
<div className="grid gap-2" data-testid="signage-widget-more">
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-more-toggle"
@@ -39,19 +38,8 @@ export default function MoreSettings({ w, set, media = {}, onMedia }) {
options={[0, 90, 180, -90].map(r => ({ value: r, label: `${r}°` }))} data-testid="signage-more-rotation-steps" />
</Field>
<Slider label={t(`${k}.angle`)} value={w.rotation || 0} min={-180} max={180} step={1} suffix="°" onChange={rotation => set({ rotation })} testId="signage-more-rotation" />
<Field label={t(`${k}.shadow`)}>
<Dropdown value={w.shadow || 'none'} onChange={shadow => set({ shadow })} data-testid="signage-more-shadow"
options={['none', 'soft', 'strong', 'glow'].map(x => ({ value: x, label: t(`${k}.shadows.${x}`) }))} />
</Field>
{w.shadow && w.shadow !== 'none' && (
<ColourField label={t(`${k}.shadowColour`)} value={w.shadow_colour || WIDGET_COLOURS.plate} onChange={shadow_colour => set({ shadow_colour })}
auto={{ label: t(`${k}.usual`), on: !w.shadow_colour, pick: () => set({ shadow_colour: null }) }} />
)}
<Slider label={t(`${k}.border`)} value={w.border_width || 0} min={0} max={20} onChange={border_width => set({ border_width })} testId="signage-more-border" />
{w.border_width > 0 && (
<ColourField label={t(`${k}.borderColour`)} value={w.border_colour || WIDGET_COLOURS.text} onChange={border_colour => set({ border_colour })} />
)}
<Slider label={t(`${k}.radius`)} value={w.border_radius || 0} min={0} max={100} step={5} onChange={border_radius => set({ border_radius })} />
{!look && <ShadowFields w={w} set={set} />}
{!FRAMED.includes(w.kind) && <BorderFields w={w} set={set} />}
<Field label={t(`${k}.animation`)}>
<Dropdown value={w.animation || 'none'} onChange={animation => set({ animation })} data-testid="signage-more-animation"
options={ANIMATIONS.map(x => ({ value: x, label: t(`${k}.animations.${x}`) }))} />
@@ -68,46 +56,17 @@ export default function MoreSettings({ w, set, media = {}, onMedia }) {
options={['contain', 'cover', 'fill'].map(x => ({ value: x, label: t(`${k}.fits.${x}`) }))} />
</Field>
)}
{text && (
<Field label={t(`${k}.weight`)}>
<Dropdown value={w.weight || ''} onChange={v => set({ weight: v === '' ? null : Number(v) })} data-testid="signage-more-weight"
options={[{ value: '', label: t(`${k}.usual`) }, ...WEIGHTS.map(n => ({ value: n, label: t(`${k}.weights.${n}`) }))]} />
</Field>
)}
{text && (
<ColourField label={t(`${k}.highlight`)} value={w.highlight || WIDGET_COLOURS.plate} onChange={highlight => set({ highlight })} testId="signage-more-highlight"
auto={{ label: t(`${k}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} />
)}
{TYPED.includes(w.kind) && (
<Field label={t(`${k}.typing`)}>
<Switch boxed className="h-control" checked={w.text_effect === 'typewriter'} onChange={on => set({ text_effect: on ? 'typewriter' : 'none' })}
label={t(`${k}.typewriter`)} data-testid="signage-more-typewriter" />
</Field>
)}
{w.kind === 'date' && (
<Field label={t(`${k}.dateFormat`)}>
<Dropdown value={w.date_format || (w.date_style === 'short' ? 'numeric' : 'long')} onChange={date_format => set({ date_format })} data-testid="signage-more-date-format"
options={DATE_FORMATS.map(x => ({ value: x, label: t(`${k}.dateFormats.${x}`) }))} />
</Field>
)}
{w.kind === 'date' && numeric && (
<Field label={t(`${k}.separator`)}>
<Segmented fill value={w.date_separator || (w.date_format === 'iso' ? '-' : '/')} onChange={date_separator => set({ date_separator })}
options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${k}.space`) : x }))} />
</Field>
)}
{w.kind === 'clock' && <>
<Field label={t(`${k}.clockFormat`)}>
<Segmented fill value={w.clock_format || '24'} onChange={clock_format => set({ clock_format })} data-testid="signage-more-clock-format"
options={['24', '12'].map(x => ({ value: x, label: t(`${k}.clockFormats.${x}`) }))} />
</Field>
<Field label={t(`${k}.separator`)}>
<Segmented fill value={w.clock_separator || ':'} onChange={clock_separator => set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} />
</Field>
{w.kind === 'clock' && (
<Field label={t(`${k}.blink`)}>
<Switch boxed className="h-control" checked={!!w.clock_blink} onChange={clock_blink => set({ clock_blink })} label={t(`${k}.blinkLabel`)} />
</Field>
</>}
)}
{w.kind === 'qr' && (
<div className="col-span-full">
<MediaPick kind="image" label={t(`${k}.qrLogo`)} value={w.media_id} entry={media[String(w.media_id)]} testid="signage-more-qr-logo"
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react'
import { ArrowLeft, ArrowRight, Film, Plus, X } from 'lucide-react'
import { Link } from 'react-router-dom'
import { useTranslation } from '@xenia/i18n'
import { Button, ColourField, Dropdown, Field, IconButton, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
import { Button, ColourField, Dropdown, Field, IconButton, InfoTip, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
import { listFolders } from '../media/mediaApi'
import MediaPicker from '../media/MediaPicker'
import { useHours, useIdentity } from '../../shell/useIdentity'
@@ -84,7 +84,7 @@ export function MoreInlineFields({ w, set }) {
}
if (w.kind === 'gallery') {
return (<>
<Field label={t(`${k}.gallery.source`)}>
<Field label={t(`${k}.gallery.source`)} className="col-span-2">
<Segmented fill value={w.gallery_source || 'pictures'} onChange={gallery_source => set({ gallery_source })} data-testid="signage-widget-gallery-source"
options={['pictures', 'folder'].map(v => ({ value: v, label: t(`${k}.gallery.sources.${v}`) }))} />
</Field>
@@ -99,11 +99,19 @@ export function MoreInlineFields({ w, set }) {
<Dropdown value={w.gallery_fit || 'cover'} onChange={gallery_fit => set({ gallery_fit })}
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
</Field>
{/* its title, above or below the pictures (owner 2026-11-23) */}
<Field label={t(`${k}.gallery.title`)}>
<Input value={w.text || ''} maxLength={120} placeholder={t(`${k}.gallery.titlePlaceholder`)} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-gallery-title" />
</Field>
<Field label={t(`${k}.gallery.titleAt`)}>
<Segmented fill value={w.title_position || 'above'} onChange={title_position => set({ title_position })} data-testid="signage-widget-gallery-title-at"
options={['above', 'below'].map(v => ({ value: v, label: t(`${k}.gallery.titleAts.${v}`) }))} />
</Field>
</>)
}
if (w.kind === 'reviews') {
return (<>
<Field label={t(`${k}.reviews.min`)}>
<Field label={t(`${k}.reviews.min`)} className="col-span-2">
<Segmented fill value={w.reviews_min || 4} onChange={reviews_min => set({ reviews_min })} data-testid="signage-widget-reviews-min"
options={[1, 2, 3, 4, 5].map(n => ({ value: n, label: `${n}+` }))} />
</Field>
@@ -176,7 +184,7 @@ export function MoreBelowFields({ w, set, media = {}, onMedia }) {
options={['full', 'hide'].map(v => ({ value: v, label: t(`${k}.countdown.waitingModes.${v}`) }))} />
</Field>
)}
<Field label={t(`${k}.countdown.done`)} hint={t(`${k}.countdown.doneHint`)}>
<Field label={t(`${k}.countdown.done`)} info={<InfoTip>{t(`${k}.countdown.doneHint`)}</InfoTip>}>
<Input value={w.countdown_done || ''} maxLength={80} placeholder={t(`${k}.countdown.donePlaceholder`)} onChange={e => set({ countdown_done: e.target.value || null, countdown_done_hide: !e.target.value })} />
</Field>
</div>
@@ -24,24 +24,32 @@
// in layers: the card at the top is the widget drawn over the others, so a new widget goes on top
// (last in the slide's list, first here); the arrows bring a widget forward / send it backward.
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
// Owner 2026-11-23: a card is its main settings (the row and what needs more room under it: a
// picture, a gallery's pictures, the weather's details, a countdown's start and end…), then "Text
// and colours" (LookFields: every text, colour, shadow and highlight setting), then More settings.
// Alignment only where it lines something up: texts of several lines (Enter makes a new line in a
// text or the message), the hours, contact details, Wi-Fi (its code left / right / above), the
// weather laid out in rows, reviews, a countdown's title, a QR's caption, a gallery's title; inside
// a stack's part it also places the widget in its part.
import { Fragment, useEffect, useRef, useState } from 'react'
import {
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Bold, Italic, Palette, RotateCcw, Underline, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, RotateCcw, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
CalendarClock, Contact, GalleryHorizontal, MessageSquareQuote, MoveHorizontal, Shapes, Timer, Wifi,
} from 'lucide-react'
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
import { useTranslation } from '@xenia/i18n'
import { Button, ColourField, Dialog, Dropdown, Field, FieldRow, IconButton, Input, Popover, Segmented, Slider, Switch } from '@xenia/ui'
import { Button, Dialog, Dropdown, Field, IconButton, Input, Popover, Segmented, Switch, Textarea } from '@xenia/ui'
import MessageOfTheDay from './MessageOfTheDay'
import { usePerformance } from './usePerformance'
import * as api from './signageApi'
import LookFields from './LookFields'
import MenuEditor from './MenuEditor'
import MoreSettings from './MoreSettings'
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
import { MediaPick, Section } from './SignageFields'
import {
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, FONT_KEYS, WIDGET_COLOURS, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
} from './signageLogic'
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
@@ -50,6 +58,23 @@ const MORE_KINDS = ['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact',
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
const DATE_FORMATS = ['long', 'weekday_day_month', 'day_month', 'weekday', 'numeric', 'numeric_short', 'iso']
/**
* Whether the alignment lines something up (owner 2026-11-23): a widget of several lines or parts;
* one line (a name, date, clock), a picture, a scrolling text, a shape, a menu or a stack: no (each
* is exactly as big as what it shows, or fills its place). In a stack's part it also places the
* widget in its part, so there every widget but a stack, a menu, a scrolling text and a shape has it.
*/
function alignable(w, inPart = false) {
if (['stack', 'menu', 'ticker', 'shape'].includes(w.kind)) return false
if (inPart) return true
if (['logo', 'name', 'date', 'clock'].includes(w.kind)) return false
if (w.kind === 'weather') return (w.weather_layout || 'row') !== 'row'
if (w.kind === 'gallery' || w.kind === 'countdown') return !!w.text
if (w.kind === 'qr') return !!w.qr_caption
return true
}
let library = null // the Slides library (for stacks' parts), read once
@@ -135,13 +160,13 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
options={[...['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) })),
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
</Field>
{w.kind !== 'stack' && <AlignField w={w} set={patch => set(i, patch)} />}
{alignable(w) && <AlignField w={w} set={patch => set(i, patch)} />}
<InlineFields w={w} set={patch => set(i, patch)} />
</div>
<LookFields w={w} set={patch => set(i, patch)} />
<MoreSettings w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
<BelowFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0}
selected={selected} onSelect={onSelect} />
<LookFields w={w} set={patch => set(i, patch)} />
<MoreSettings w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
</div>
</div>
)
@@ -179,64 +204,12 @@ function VerticalField({ w, set }) {
)
}
// which widgets have text (their colour, font, style and size), a QR code's own colours, a plate
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews']
/**
* A widget's own look (owner review 5), folded under "Text and colours": its colour (text and
* pictures; empty = the slide's), a plate behind it, its font, bold / italic / underline and text
* size; a QR code's dots and background. A logo has only the plate; a menu has its own look.
*/
function LookFields({ w, set }) {
const { t } = useTranslation('manager')
const [open, setOpen] = useState(false)
if (w.kind === 'menu' || w.kind === 'stack' || w.kind === 'shape') return null
const text = TEXT_KINDS.includes(w.kind)
const changed = !!(w.colour || w.background_colour || w.font || w.bold != null || w.italic || w.underline || (w.text_size && w.text_size !== 100) || w.qr_colour || w.qr_background)
const styles = [w.bold !== false && 'bold', w.italic && 'italic', w.underline && 'underline'].filter(Boolean)
return (
<div className="grid gap-2" data-testid="signage-widget-look">
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-look-toggle"
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
<Palette size={15} aria-hidden="true" />{t(text ? 'signage.widgets.look' : 'signage.widgets.plateOnly')}
{changed && <span className="w-1.5 h-1.5 rounded-full bg-accent" aria-hidden="true" />}
<ChevronDown size={15} className={`transition-transform duration-fast ${open ? 'rotate-180' : ''}`} aria-hidden="true" />
</button>
{open && (
<FieldRow className="-mx-3" min="10rem">
{text && <ColourField label={t('signage.widgets.colour')} value={w.colour || WIDGET_COLOURS.text} onChange={colour => set({ colour })} testId="signage-widget-colour"
auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />}
<ColourField label={t('signage.widgets.plate')} value={w.background_colour || WIDGET_COLOURS.plate} onChange={background_colour => set({ background_colour })} testId="signage-widget-plate"
auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} />
{text && <>
<Field label={t('signage.font')}>
<Dropdown value={w.font || ''} onChange={v => set({ font: v || null })} data-testid="signage-widget-font"
options={[{ value: '', label: t('signage.widgets.asSlide') }, ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]} />
</Field>
<Field label={t('signage.look.f.widget.style')}>
<Segmented multiple fill value={styles} data-testid="signage-widget-style"
onChange={list => set({ bold: list.includes('bold') ? null : false, italic: list.includes('italic'), underline: list.includes('underline') })}
options={[['bold', Bold], ['italic', Italic], ['underline', Underline]].map(([v, Icon]) => (
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.look.${v}`), testId: `signage-widget-${v}` }))} />
</Field>
<Slider label={t('signage.widgets.textSize')} value={w.text_size || 100} min={50} max={200} step={10} suffix="%" onChange={text_size => set({ text_size })} testId="signage-widget-text-size" />
</>}
{(w.kind === 'qr' || w.kind === 'wifi') && <>
<ColourField label={t('signage.widgets.qrColour')} value={w.qr_colour || WIDGET_COLOURS.qr} onChange={qr_colour => set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} />
<ColourField label={t('signage.widgets.qrBackground')} value={w.qr_background || WIDGET_COLOURS.qrBackground} onChange={qr_background => set({ qr_background })} testId="signage-widget-qr-background" />
</>}
</FieldRow>
)}
</div>
)
}
/** The message of the day's hint, and the message itself changed right here (owner review 5). */
function MessageHint() {
const { t } = useTranslation('manager')
const [open, setOpen] = useState(false)
return (
<div className="flex flex-wrap items-center gap-2 -mt-2">
<div className="flex flex-wrap items-center gap-2">
<p className="text-caption text-ink-3 flex-1 min-w-[12rem]">{t('signage.widgets.ownTextHint')}</p>
<Button size="sm" variant="secondary" onClick={() => setOpen(true)} data-testid="signage-widget-message-open">{t('signage.widgets.changeMessage')}</Button>
{open && (
@@ -252,35 +225,36 @@ function MessageHint() {
/** The options only some widgets have, on the same row as where / size / alignment. */
function InlineFields({ w, set }) {
const { t } = useTranslation('manager')
const m = 'signage.more'
if (MORE_KINDS.includes(w.kind)) return <MoreInline w={w} set={set} />
if (w.kind === 'message') {
return (
<Field label={t('signage.widgets.ownText')} className="col-span-2">
<Input value={w.text || ''} maxLength={200} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
</Field>
)
}
if (w.kind === 'text') {
return (
<Field label={t('signage.widgets.theText')} className="col-span-2">
<Input value={w.text || ''} maxLength={200} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
</Field>
)
}
if (w.kind === 'date') {
return (
<Field label={t('signage.widgets.dateStyle')}>
<Dropdown value={w.date_style || 'long'} onChange={date_style => set({ date_style })}
options={[{ value: 'long', label: t('signage.widgets.dateLong') }, { value: 'short', label: t('signage.widgets.dateShort') }]} />
const format = w.date_format || (w.date_style === 'short' ? 'numeric' : 'long')
return (<>
<Field label={t(`${m}.dateFormat`)} className="col-span-2">
<Dropdown value={format} onChange={date_format => set({ date_format })} data-testid="signage-more-date-format"
options={DATE_FORMATS.map(x => ({ value: x, label: t(`${m}.dateFormats.${x}`) }))} />
</Field>
)
{['numeric', 'numeric_short', 'iso'].includes(format) && (
<Field label={t(`${m}.separator`)}>
<Segmented fill value={w.date_separator || (format === 'iso' ? '-' : '/')} onChange={date_separator => set({ date_separator })}
options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${m}.space`) : x }))} />
</Field>
)}
</>)
}
if (w.kind === 'clock') {
return (
return (<>
<Field label={t(`${m}.clockFormat`)}>
<Segmented fill value={w.clock_format || '24'} onChange={clock_format => set({ clock_format })} data-testid="signage-more-clock-format"
options={['24', '12'].map(x => ({ value: x, label: t(`${m}.clockFormats.${x}`) }))} />
</Field>
<Field label={t(`${m}.separator`)}>
<Segmented fill value={w.clock_separator || ':'} onChange={clock_separator => set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} />
</Field>
<Field label={t('signage.widgets.clockShows')}>
<Switch boxed className="h-control" checked={!!w.clock_seconds} onChange={on => set({ clock_seconds: on })} label={t('signage.widgets.seconds')} data-testid="signage-widget-seconds" />
</Field>
)
</>)
}
if (w.kind === 'qr') {
return (
@@ -323,7 +297,23 @@ function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, on
</div>
)
}
if (w.kind === 'message') return <MessageHint />
if (w.kind === 'message') {
return (
<div className="grid gap-3">
<Field label={t('signage.widgets.ownText')} hint={t('signage.widgets.enterHint')}>
<Textarea rows={2} value={w.text || ''} maxLength={500} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
</Field>
<MessageHint />
</div>
)
}
if (w.kind === 'text') {
return (
<Field label={t('signage.widgets.theText')} hint={t('signage.widgets.enterHint')}>
<Textarea rows={2} value={w.text || ''} maxLength={500} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
</Field>
)
}
if (w.kind === 'weather') {
return (
<div className="grid gap-3">
@@ -488,14 +478,14 @@ function StackFields({ w, set, media, onMedia, extras, path, depth, selected, on
? <Button variant="secondary" icon={<RotateCcw size={14} />} onClick={() => setW(fillPlace(x))} data-testid="signage-cell-fill">{t('signage.widgets.backInPlace')}</Button>
: <span className="h-control flex items-center text-label text-ink-2" data-testid="signage-cell-place">{t('signage.widgets.fillsPlace')}</span>}
</Field>
<AlignField w={x} set={setW} testid="signage-cell-align" />
{alignable(x, true) && <AlignField w={x} set={setW} testid="signage-cell-align" />}
<VerticalField w={x} set={setW} />
<InlineFields w={x} set={setW} />
</div>
)}
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
<LookFields w={x} set={setW} />
<MoreSettings w={x} set={setW} media={media} onMedia={onMedia} />
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
</div>
)
})}
@@ -417,8 +417,16 @@ export const LETTER_SPACINGS = [-0.05, -0.02, 0.02, 0.05, 0.1, 0.15, 0.2, 0.3]
// a widget's "More settings" (6R.17)
/** Has any of these been changed from the usual? (the dot on the toggle) */
export function moreChanged(w) {
return !!((w.opacity ?? 100) < 100 || w.rotation || (w.shadow && w.shadow !== 'none') || w.border_width || w.border_radius
|| (w.animation && w.animation !== 'none') || w.weight || w.highlight || (w.text_effect && w.text_effect !== 'none')
|| w.date_format || w.date_separator || w.clock_format === '12' || (w.clock_separator && w.clock_separator !== ':') || w.clock_blink
// owner 2026-11-23: text, colours, shadow and highlight are under "Text and colours" (a picture's
// border too), the date's and clock's formats among their main settings
const look = lookKind(w.kind)
return !!((w.opacity ?? 100) < 100 || w.rotation || (!look && w.shadow && w.shadow !== 'none')
|| (!FRAMED.includes(w.kind) && (w.border_width || w.border_radius))
|| (w.animation && w.animation !== 'none') || (w.text_effect && w.text_effect !== 'none') || w.clock_blink
|| (w.kind === 'qr' && w.media_id) || (w.fit && w.fit !== 'contain'))
}
/** The widgets with "Text and colours" (all but a menu, a stack and a shape: those have their own look). */
export const lookKind = kind => !['menu', 'stack', 'shape'].includes(kind)
/** The pictures whose border is under "Text and colours" (owner 2026-11-23). */
export const FRAMED = ['logo', 'gallery']