feat(signage): More settings for every widget (opacity, rotation, shadow, border, entrance animation, a logo's fit; text weight, highlight, typing out; date and clock formats; a logo in a QR code)

Folded under each widget card like Text and colours. The TV puts them on the element
that places the widget (fx), animations on translate / scale so its place's transform
stays (an older TV only fades); an entrance animates to the widget's own opacity.
Calibrating: a strict-mode remount no longer ends it. Plan 6R.17, F-115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:01:42 +02:00
co-authored by Claude Opus 5.5
parent 1eb7e5e3a9
commit 673113aff7
11 changed files with 444 additions and 26 deletions
@@ -24,10 +24,13 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
const timer = useRef(null)
const latest = useRef(area)
// on while open; off when closed
// on while open; off when closed (a moment later, so a remount, as React's strict mode does in
// development, never sends "off" after "on")
const alive = useRef(0)
useEffect(() => {
const mine = ++alive.current
api.calibrateScreen(screen.id, true).catch(err => toast.error(errorMessage(err, t)))
return () => { api.calibrateScreen(screen.id, false).catch(() => {}) }
return () => { 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(() => {
@@ -0,0 +1,121 @@
// "More settings" of a widget (6R.17, owner 2026-11-22), folded away like "Text and colours":
// 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`).
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 { MediaPick } from './SignageFields'
import { moreChanged, WIDGET_COLOURS } 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)
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"
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
<SlidersHorizontal size={15} aria-hidden="true" />{t(`${k}.title`)}
{moreChanged(w) && <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="11rem">
<Slider label={t(`${k}.opacity`)} value={w.opacity ?? 100} min={10} max={100} step={5} suffix="%" onChange={opacity => set({ opacity })} testId="signage-more-opacity" />
<Field label={t(`${k}.rotation`)}>
<Segmented fill value={[0, 90, 180, -90].includes(w.rotation || 0) ? (w.rotation || 0) : null} onChange={rotation => set({ rotation })}
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 })} />
<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}`) }))} />
</Field>
{w.animation && w.animation !== 'none' && !['pulse', 'float'].includes(w.animation) && (
<Field label={t(`${k}.delay`)}>
<Dropdown value={w.animation_delay || 0} onChange={v => set({ animation_delay: Number(v) })}
options={DELAYS.map(d => ({ value: d, label: t(`${k}.seconds`, { n: d / 10 }) }))} />
</Field>
)}
{w.kind === 'logo' && (
<Field label={t('signage.fit')}>
<Dropdown value={w.fit || 'contain'} onChange={fit => set({ fit })}
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>
<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"
onChange={item => { onMedia?.(item); set({ media_id: item.id }) }} onRemove={() => set({ media_id: null })} />
</div>
)}
</FieldRow>
)}
</div>
)
}
@@ -37,6 +37,7 @@ import MessageOfTheDay from './MessageOfTheDay'
import { usePerformance } from './usePerformance'
import * as api from './signageApi'
import MenuEditor from './MenuEditor'
import MoreSettings from './MoreSettings'
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
import { MediaPick, Section } from './SignageFields'
import {
@@ -138,6 +139,7 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
<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} />
</div>
@@ -463,6 +465,7 @@ function StackFields({ w, set, media, onMedia, extras, path, depth, selected, on
</div>
)}
<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>
)
@@ -410,3 +410,12 @@ export const MENU_LOOK_DEFAULTS = {
/** Line spacing (× the text) and letter spacing (em) offered beside "Auto". */
export const LINE_HEIGHTS = [0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2, 2.5]
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
|| (w.kind === 'qr' && w.media_id) || (w.fit && w.fit !== 'contain'))
}
+10 -1
View File
@@ -1,7 +1,7 @@
// The signage editor's helpers (plan step 5.6a).
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { fitsOrientation, mediaEntry, misfits, moved, slideBody, slideFromTemplate, TEMPLATES, totalSeconds, windowParts } from '../src/pages/signage/signageLogic.js'
import { fitsOrientation, moreChanged, mediaEntry, misfits, moved, slideBody, slideFromTemplate, TEMPLATES, totalSeconds, windowParts } from '../src/pages/signage/signageLogic.js'
test('templates fill their texts in the manager\'s language and copy their content', () => {
const tpl = TEMPLATES.find(x => x.key === 'happyHour')
@@ -119,3 +119,12 @@ test('owner review 6: a box off the slide (a strip stays), a tight box scaled ke
assert.equal(secondsMissing({ kind: 'blank', duration_s: 5, content: { widgets: [{ kind: 'stack', cells: [{ widgets: [{ kind: 'menu', board: { page_seconds: null } }] }] }] } }), true)
assert.equal(secondsMissing({ kind: 'menu', duration_s: 5, content: { page_seconds: 3 } }), false)
})
test("a widget's More settings: changed or as usual (6R.17)", () => {
assert.equal(moreChanged({ kind: 'clock' }), false)
assert.equal(moreChanged({ kind: 'clock', opacity: 100, shadow: 'none', animation: 'none', clock_separator: ':' }), false)
assert.equal(moreChanged({ kind: 'clock', clock_format: '12' }), true)
assert.equal(moreChanged({ kind: 'date', rotation: -15 }), true)
assert.equal(moreChanged({ kind: 'qr', media_id: 4 }), true)
assert.equal(moreChanged({ kind: 'logo', media_id: 4 }), false)
})