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
+22 -1
View File
@@ -256,7 +256,7 @@ class Widget(_Strict):
size: Literal["small", "medium", "large", "custom"] = "medium" size: Literal["small", "medium", "large", "custom"] = "medium"
box: Optional[Box] = None # position "custom" box: Optional[Box] = None # position "custom"
align: Literal["auto", "left", "center", "right"] = "auto" # inside its place; auto: by its corner / box align: Literal["auto", "left", "center", "right"] = "auto" # inside its place; auto: by its corner / box
media_id: Optional[int] = None # logo: a picture media_id: Optional[int] = None # logo: a picture; QR: a logo in its middle (6R.17)
text: Optional[str] = Field(default=None, max_length=500) # message: this text instead of the venue's; text, ticker, a countdown's / hours' title text: Optional[str] = Field(default=None, max_length=500) # message: this text instead of the venue's; text, ticker, a countdown's / hours' title
date_style: Literal["short", "long"] = "long" date_style: Literal["short", "long"] = "long"
clock_seconds: bool = False clock_seconds: bool = False
@@ -323,6 +323,27 @@ class Widget(_Strict):
gallery_seconds: int = Field(default=5, ge=3, le=120) gallery_seconds: int = Field(default=5, ge=3, le=120)
gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade" gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade"
gallery_fit: Literal["cover", "contain"] = "cover" gallery_fit: Literal["cover", "contain"] = "cover"
# more settings (6R.17), every widget: on the element that places it
opacity: int = Field(default=100, ge=10, le=100)
rotation: int = Field(default=0, ge=-180, le=180)
shadow: Literal["none", "soft", "strong", "glow"] = "none"
shadow_colour: Optional[str] = Field(default=None, pattern=HEX)
border_width: int = Field(default=0, ge=0, le=20) # tenths of a usual unit
border_colour: Optional[str] = Field(default=None, pattern=HEX)
border_radius: int = Field(default=0, ge=0, le=100) # tenths of a usual unit
animation: Literal["none", "fade", "rise", "drop", "slide-left", "slide-right", "zoom", "pop", "pulse", "float"] = "none"
animation_delay: int = Field(default=0, ge=0, le=50) # tenths of a second
fit: Literal["contain", "cover", "fill"] = "contain" # a logo / picture in its box
# texts
weight: Optional[int] = Field(default=None, ge=100, le=900) # None: as the widget usually is (bold switch)
highlight: Optional[str] = Field(default=None, pattern=HEX) # a marker behind the text
text_effect: Literal["none", "typewriter"] = "none"
# dates and clocks
date_format: Optional[Literal["long", "short", "weekday", "day_month", "weekday_day_month", "numeric", "numeric_short", "iso"]] = None
date_separator: Optional[Literal["/", ".", "-", " "]] = None
clock_format: Literal["24", "12"] = "24"
clock_separator: Literal[":", "."] = ":"
clock_blink: bool = False
@model_validator(mode="after") @model_validator(mode="after")
def _place(self): def _place(self):
+17
View File
@@ -99,3 +99,20 @@ def test_reviews_typed_in_by_hand(client, owner_h, screens, sent):
assert client.get("/api/signage/reviews", headers=owner_h).json()["reviews"][1]["name"] == "John" assert client.get("/api/signage/reviews", headers=owner_h).json()["reviews"][1]["name"] == "John"
assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 6, "text": "y"}]}).status_code == 422 assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 6, "text": "y"}]}).status_code == 422
assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 5, "text": ""}]}).status_code == 422 assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 5, "text": ""}]}).status_code == 422
def test_more_settings_of_widgets(client, owner_h, media_dir):
from tests.test_signage import playlist, slide
logo = up(client, owner_h, jpeg(200, 200)).json()
p = playlist(client, owner_h)
w = {"kind": "date", "opacity": 60, "rotation": -15, "shadow": "glow", "border_width": 4, "border_colour": "#ff0000", "border_radius": 20,
"animation": "pop", "animation_delay": 5, "weight": 300, "highlight": "#ffff0080", "text_effect": "typewriter",
"date_format": "numeric", "date_separator": "."}
q = {"kind": "qr", "media_id": logo["id"], "clock_format": "12", "clock_blink": True}
s = slide(client, owner_h, p["id"], "blank", content={"widgets": [w, q]})
got = s["content"]["widgets"][0]
assert {k: got[k] for k in w} == w
assert s["content"]["widgets"][1]["media_id"] == logo["id"]
for bad in ({"kind": "date", "opacity": 5}, {"kind": "date", "animation": "spin"}, {"kind": "date", "date_separator": "|"}, {"kind": "clock", "weight": 1000}):
r = client.post(f"/api/signage/playlists/{p['id']}/slides", headers=owner_h, json={"kind": "blank", "content": {"widgets": [bad]}})
assert err(r) == "signage.content_invalid", bad
@@ -24,10 +24,13 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
const timer = useRef(null) const timer = useRef(null)
const latest = useRef(area) 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(() => { useEffect(() => {
const mine = ++alive.current
api.calibrateScreen(screen.id, true).catch(err => toast.error(errorMessage(err, t))) 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 }, [screen.id]) // eslint-disable-line react-hooks/exhaustive-deps
// the TV's window size (it reports it when it starts and when it changes) // the TV's window size (it reports it when it starts and when it changes)
useEffect(() => { 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 { usePerformance } from './usePerformance'
import * as api from './signageApi' import * as api from './signageApi'
import MenuEditor from './MenuEditor' import MenuEditor from './MenuEditor'
import MoreSettings from './MoreSettings'
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields' import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
import { MediaPick, Section } from './SignageFields' import { MediaPick, Section } from './SignageFields'
import { import {
@@ -138,6 +139,7 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
<InlineFields w={w} set={patch => set(i, patch)} /> <InlineFields w={w} set={patch => set(i, patch)} />
</div> </div>
<LookFields w={w} set={patch => set(i, patch)} /> <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} <BelowFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0}
selected={selected} onSelect={onSelect} /> selected={selected} onSelect={onSelect} />
</div> </div>
@@ -463,6 +465,7 @@ function StackFields({ w, set, media, onMedia, extras, path, depth, selected, on
</div> </div>
)} )}
<LookFields w={x} set={setW} /> <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} /> <BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
</div> </div>
) )
@@ -410,3 +410,12 @@ export const MENU_LOOK_DEFAULTS = {
/** Line spacing (× the text) and letter spacing (em) offered beside "Auto". */ /** 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 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] 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). // The signage editor's helpers (plan step 5.6a).
import { test } from 'node:test' import { test } from 'node:test'
import assert from 'node:assert/strict' 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', () => { test('templates fill their texts in the manager\'s language and copy their content', () => {
const tpl = TEMPLATES.find(x => x.key === 'happyHour') 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: '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) 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)
})
+74
View File
@@ -1978,6 +1978,80 @@
"name": "Όνομα", "name": "Όνομα",
"source": "Πού", "source": "Πού",
"date": "Ημερομηνία" "date": "Ημερομηνία"
},
"more": {
"title": "Περισσότερες ρυθμίσεις",
"opacity": "Αδιαφάνεια",
"rotation": "Περιστροφή",
"angle": "Οποιαδήποτε γωνία",
"shadow": "Σκιά",
"shadows": {
"none": "Καμία",
"soft": "Απαλή",
"strong": "Έντονη",
"glow": "Λάμψη"
},
"shadowColour": "Χρώμα σκιάς",
"usual": "Όπως συνήθως",
"border": "Περίγραμμα",
"borderColour": "Χρώμα περιγράμματος",
"radius": "Στρογγυλεμένες γωνίες",
"animation": "Εμφανίζεται με",
"animations": {
"none": "Τίποτα (απλώς εκεί)",
"fade": "Σβήσιμο",
"rise": "Άνοδο",
"drop": "Πτώση",
"slide-left": "Κύλιση από δεξιά",
"slide-right": "Κύλιση από αριστερά",
"zoom": "Μεγέθυνση",
"pop": "Αναπήδηση",
"pulse": "Παλμό, συνέχεια",
"float": "Αιώρηση, συνέχεια"
},
"delay": "Μετά από",
"seconds": "{{n}} δ.",
"fits": {
"contain": "Ολόκληρο (χωράει μέσα)",
"cover": "Γεμίζει το πλαίσιο (κομμένο)",
"fill": "Τεντωμένο στο πλαίσιο"
},
"weight": "Πάχος",
"weights": {
"100": "Πολύ λεπτά",
"200": "Πολύ ελαφριά",
"300": "Ελαφριά",
"400": "Κανονικά",
"500": "Μεσαία",
"600": "Ημι-έντονα",
"700": "Έντονα",
"800": "Πολύ έντονα",
"900": "Μαύρα"
},
"highlight": "Επισήμανση",
"noHighlight": "Χωρίς επισήμανση",
"typing": "Όταν εμφανίζεται",
"typewriter": "Γράφεται γράμμα-γράμμα",
"dateFormat": "Μορφή ημερομηνίας",
"dateFormats": {
"long": "Κυριακή 22 Νοεμβρίου 2026",
"weekday_day_month": "Κυριακή 22 Νοεμβρίου",
"day_month": "22 Νοεμβρίου",
"weekday": "Κυριακή",
"numeric": "22/11/2026",
"numeric_short": "22/11",
"iso": "2026-11-22"
},
"separator": "Διαχωριστικό",
"space": "Κενό",
"clockFormat": "Ρολόι",
"clockFormats": {
"24": "24ωρο",
"12": "12ωρο (π.μ. / μ.μ.)"
},
"blink": "Διαχωριστικό",
"blinkLabel": "Αναβοσβήνει κάθε δευτερόλεπτο",
"qrLogo": "Λογότυπο στη μέση του κωδικού"
} }
}, },
"overview": { "overview": {
+74
View File
@@ -1978,6 +1978,80 @@
"name": "Name", "name": "Name",
"source": "Where", "source": "Where",
"date": "Date" "date": "Date"
},
"more": {
"title": "More settings",
"opacity": "Opacity",
"rotation": "Turn",
"angle": "Any angle",
"shadow": "Shadow",
"shadows": {
"none": "None",
"soft": "Soft",
"strong": "Strong",
"glow": "Glow"
},
"shadowColour": "Shadow colour",
"usual": "As usual",
"border": "Border",
"borderColour": "Border colour",
"radius": "Rounded corners",
"animation": "Comes in with",
"animations": {
"none": "Nothing (just there)",
"fade": "Fade",
"rise": "Rise",
"drop": "Drop",
"slide-left": "Slide from the right",
"slide-right": "Slide from the left",
"zoom": "Zoom",
"pop": "Pop",
"pulse": "Pulse, all the time",
"float": "Float, all the time"
},
"delay": "After",
"seconds": "{{n}} s",
"fits": {
"contain": "Whole (fits inside)",
"cover": "Fills the box (cropped)",
"fill": "Stretched to the box"
},
"weight": "Weight",
"weights": {
"100": "Thin",
"200": "Extra light",
"300": "Light",
"400": "Regular",
"500": "Medium",
"600": "Semi-bold",
"700": "Bold",
"800": "Extra bold",
"900": "Black"
},
"highlight": "Highlight",
"noHighlight": "No highlight",
"typing": "When it appears",
"typewriter": "Types itself out",
"dateFormat": "Date format",
"dateFormats": {
"long": "Sunday 22 November 2026",
"weekday_day_month": "Sunday 22 November",
"day_month": "22 November",
"weekday": "Sunday",
"numeric": "22/11/2026",
"numeric_short": "22/11",
"iso": "2026-11-22"
},
"separator": "Separator",
"space": "Space",
"clockFormat": "Clock",
"clockFormats": {
"24": "24 hours",
"12": "12 hours (am / pm)"
},
"blink": "Separator",
"blinkLabel": "Blinks every second",
"qrLogo": "A logo in the middle of the code"
} }
}, },
"overview": { "overview": {
+99 -20
View File
@@ -174,6 +174,45 @@ const plate = (w, pad) => ({
...(w.colour ? { color: w.colour } : {}), ...(w.colour ? { color: w.colour } : {}),
...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}), ...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}),
}) })
// ── a widget's more settings (6R.17): opacity, rotation, shadow, border, an entrance animation ──
const SHADOWS = { soft: [0.3, 1.2], strong: [0.6, 2.4], glow: [0, 2] }
/** Its look on the element that places it (wrapper): `base` = the transform its place already has. */
function fx(w, base) {
const out = {}
if (w.opacity != null && w.opacity < 100) out.opacity = w.opacity / 100
if (w.shadow && w.shadow !== 'none') {
const [y, blur] = SHADOWS[w.shadow] || SHADOWS.soft
out.filter = `drop-shadow(0 ${cq(y)} ${cq(blur)} ${w.shadow_colour || (w.shadow === 'glow' ? '#ffffffcc' : '#00000099')})`
}
if (w.border_width) out.border = `${cq(+(w.border_width / 10).toFixed(2))} solid ${w.border_colour || '#ffffff'}`
if (w.border_radius) out.borderRadius = cq(+(w.border_radius / 10).toFixed(2))
const t = [base, w.rotation ? `rotate(${w.rotation}deg)` : null].filter(Boolean).join(' ')
if (t) out.transform = t
return out
}
// entrance animations (on `translate` / `scale`, so its place's `transform` stays; an older TV only fades)
const ANIMATIONS = {
fade: [[{ opacity: 0 }, { opacity: 1 }], {}],
rise: [[{ opacity: 0, translate: '0 30%' }, { opacity: 1, translate: '0 0' }], {}],
drop: [[{ opacity: 0, translate: '0 -30%' }, { opacity: 1, translate: '0 0' }], {}],
'slide-left': [[{ opacity: 0, translate: '40% 0' }, { opacity: 1, translate: '0 0' }], {}],
'slide-right': [[{ opacity: 0, translate: '-40% 0' }, { opacity: 1, translate: '0 0' }], {}],
zoom: [[{ opacity: 0, scale: '0.6' }, { opacity: 1, scale: '1' }], {}],
pop: [[{ opacity: 0, scale: '0.3' }, { opacity: 1, scale: '1.12', offset: 0.7 }, { opacity: 1, scale: '1' }], {}],
pulse: [[{ scale: '1' }, { scale: '1.06' }, { scale: '1' }], { duration: 2000, iterations: Infinity }],
float: [[{ translate: '0 0' }, { translate: '0 -4%' }, { translate: '0 0' }], { duration: 3000, iterations: Infinity }],
}
/** A ref that starts its animation when the widget appears (again when the animation is changed). */
const animate = w => el => {
const name = w.animation && w.animation !== 'none' ? `${w.animation}:${w.animation_delay || 0}` : ''
if (!el || el.dataset.xAnim === name || !el.animate) return
el.dataset.xAnim = name
el.getAnimations?.().forEach(a => a.cancel())
const a = ANIMATIONS[w.animation]
const to = (w.opacity ?? 100) / 100 // it comes in to its own opacity
if (a) el.animate(a[0].map(f => (f.opacity === 1 ? { ...f, opacity: to } : f)), { duration: 800, easing: 'ease-out', fill: 'backwards', delay: (w.animation_delay || 0) * 100, ...a[1] })
}
// a menu, a stack, a shape or a scrolling text in a corner or a bar has no box of its own: it gets one of this size (cqmin) // a menu, a stack, a shape or a scrolling text 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], shape: [18, 18], ticker: [80, 7], reviews: [56, 24], gallery: [40, 30] } const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7], reviews: [56, 24], gallery: [40, 30] }
@@ -200,8 +239,8 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
style={{ ...pos, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: cq(3), padding: `${cq(2)} ${cq(4)}`, 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) }}> background: 'rgba(0,0,0,0.35)', color: colour || '#fff', minHeight: cq(9) }}>
{bar(where).map(([w, i, body]) => ( {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), <div key={i} data-widget={i} ref={animate(w)} style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w, true),
...(w.kind === 'ticker' ? { flex: 1, minWidth: 0, alignSelf: 'stretch', justifyContent: 'center' } : {}) }}>{body}</div> ...(w.kind === 'ticker' ? { flex: 1, minWidth: 0, alignSelf: 'stretch', justifyContent: 'center' } : {}), ...fx(w) }}>{body}</div>
))} ))}
</div> </div>
))} ))}
@@ -209,17 +248,17 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
if (w.position === 'custom' && TIGHT.includes(w.kind)) { if (w.position === 'custom' && TIGHT.includes(w.kind)) {
// as big as what it shows, from its box's top-left corner (it may run off the slide) // as big as what it shows, from its box's top-left corner (it may run off the slide)
return ( return (
<div key={i} data-widget={i} className="absolute" data-testid="signage-w-box" data-tight="" <div key={i} data-widget={i} ref={animate(w)} className="absolute" data-testid="signage-w-box" data-tight=""
style={{ left: `${w.box.x}%`, top: `${w.box.y}%`, width: 'max-content', color: colour || '#fff', display: 'flex', flexDirection: 'column', style={{ left: `${w.box.x}%`, top: `${w.box.y}%`, width: 'max-content', color: colour || '#fff', display: 'flex', flexDirection: 'column',
alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w, true) }}> alignItems: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w, true), ...fx(w) }}>
{body} {body}
</div> </div>
) )
} }
if (w.position === 'custom') { if (w.position === 'custom') {
return ( return (
<div key={i} data-widget={i} className="absolute" data-testid="signage-w-box" <div key={i} data-widget={i} ref={animate(w)} 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' }} {...CQ_BOX}> style={{ left: `${w.box.x}%`, top: `${w.box.y}%`, width: `${w.box.w}%`, height: `${w.box.h}%`, containerType: 'size', color: colour || '#fff', boxSizing: 'border-box', ...fx(w) }} {...CQ_BOX}>
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: VSELF[w.vertical] || 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w) }}> <div style={{ width: '100%', height: '100%', display: 'flex', alignItems: VSELF[w.vertical] || 'center', justifyContent: SELF[widgetAlign(w)], textAlign: widgetAlign(w), ...plate(w) }}>
{body} {body}
</div> </div>
@@ -228,7 +267,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
} }
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {} const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {}
return ( return (
<div key={i} data-widget={i} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true) }}> <div key={i} data-widget={i} ref={animate(w)} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true), ...fx(w, CORNER[w.position].transform) }}>
{body} {body}
</div> </div>
) )
@@ -259,12 +298,13 @@ function widgetBody(w, ctx, fit, path) {
const f = fitUnit(height, width) const f = fitUnit(height, width)
return n => f(n * Math.min(1, ts)) 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, const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: w.weight || (w.bold === false ? 400 : w.bold ? Math.max(weight, 800) : weight), lineHeight: 1.15,
...(w.highlight ? { background: w.highlight, padding: '0.05em 0.25em', borderRadius: '0.15em', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone' } : {}),
textShadow: w.background_colour ? undefined : `0 ${cq(0.2)} ${cq(0.8)} 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' } : {}) }) ...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}), ...(w.underline ? { textDecoration: 'underline' } : {}) })
const line = (str, testid, weight) => { const line = (str, testid, weight) => {
const u = unit(3.4 * 1.15, textWidth(str.length, 3.4)) const u = unit(3.4 * 1.15, textWidth(str.length, 3.4))
return <span style={text(u, 3.4, weight)} data-testid={testid}>{str}</span> return <span style={text(u, 3.4, weight)} data-testid={testid}>{w.text_effect === 'typewriter' ? <TypeText text={str} /> : str}</span>
} }
// a menu or a stack fills a box: its own, or (in a corner / bar) one of a usual size // 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 : ( const boxed = (body, kind) => (fit ? body : (
@@ -275,18 +315,28 @@ function widgetBody(w, ctx, fit, path) {
if (!m) return null if (!m) return null
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" /> 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 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={{ width: '100%', height: '100%', objectFit: w.fit || 'contain', objectPosition: OBJECT_POSITION[widgetAlign(w)] }} 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" /> : <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 (w.kind === 'name') {
if (!venue?.name) return null if (!venue?.name) return null
const u = unit(4.2 * 1.15, textWidth(venue.name.length, 4.2)) 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> return <span style={text(u, 4.2)} data-testid="signage-w-name">{w.text_effect === 'typewriter' ? <TypeText text={venue.name} /> : venue.name}</span>
} }
if (w.kind === 'date') return line(formatDate(now, w.date_style === 'short' ? 'date' : 'dateLong'), 'signage-w-date') if (w.kind === 'date') return line(dateText(fmt, now, w), 'signage-w-date')
if (w.kind === 'clock') { 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 const twelve = w.clock_format === '12'
return <span style={{ ...text(u, 4.6), fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">{formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')}</span> const u = unit(4.6 * 1.15, textWidth((w.clock_seconds ? 8 : 5) + (twelve ? 3 : 0), 4.6)) // its usual width: the size stays as the minutes turn
const raw = twelve ? fmt.formatDateTime(now, { hour: 'numeric', minute: '2-digit', ...(w.clock_seconds ? { second: '2-digit' } : {}), hour12: true })
: formatTime(now, w.clock_seconds ? 'timeSeconds' : 'time')
const sep = w.clock_separator || ':'
const parts = raw.split(/[:.]/)
const hide = w.clock_blink && now.getSeconds() % 2 === 1
return (
<span style={{ ...text(u, 4.6), fontVariantNumeric: 'tabular-nums' }} data-testid="signage-w-clock">
{parts.map((p, n) => <span key={n}>{n > 0 && <span style={{ opacity: hide ? 0 : 1 }}>{sep}</span>}{p}</span>)}
</span>
)
} }
if (w.kind === 'message') { if (w.kind === 'message') {
const msg = w.text || venue?.message const msg = w.text || venue?.message
@@ -296,12 +346,14 @@ function widgetBody(w, ctx, fit, path) {
if (w.kind === 'qr') { if (w.kind === 'qr') {
const link = x.link || w.link const link = x.link || w.link
if (!link) return null if (!link) return null
const logo = w.media_id ? media(w.media_id) : null // 6R.17: a logo in its middle
const caption = w.qr_caption ? 2.4 * 1.15 + 0.8 : 0 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)) const u = unit(16 + caption, Math.max(16, w.qr_caption ? textWidth(w.qr_caption.length, 2.4) : 0))
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}> <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
<div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}> <div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
<QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }} /> <QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }}
level={logo ? 'H' : 'M'} imageSettings={logo ? { src: logo.src, width: 64, height: 64, excavate: true } : undefined} />
</div> </div>
{w.qr_caption && <span style={text(u, 2.4)}>{w.qr_caption}</span>} {w.qr_caption && <span style={text(u, 2.4)}>{w.qr_caption}</span>}
</div> </div>
@@ -351,6 +403,33 @@ function widgetBody(w, ctx, fit, path) {
return null return null
} }
/** A text that types itself out when it appears (6R.17), about 18 letters a second. */
function TypeText({ text }) {
const [n, setN] = useState(0)
useEffect(() => {
setN(0)
const id = setInterval(() => setN(k => (k >= text.length ? (clearInterval(id), k) : k + 1)), 55)
return () => clearInterval(id)
}, [text])
// the rest is there but hidden, so the widget keeps its size while it types
return <>{text.slice(0, n)}<span style={{ visibility: 'hidden' }}>{text.slice(n)}</span></>
}
const DATE_FORMATS = {
long: 'dateLong', short: 'date', weekday: 'weekday',
day_month: { day: 'numeric', month: 'long' },
weekday_day_month: { weekday: 'long', day: 'numeric', month: 'long' },
numeric: { day: '2-digit', month: '2-digit', year: 'numeric' },
numeric_short: { day: '2-digit', month: '2-digit' },
}
/** A date widget's text (6R.17): its format, and the separator of a numeric one. */
function dateText(fmt, now, w) {
const f = w.date_format || (w.date_style === 'short' ? 'short' : 'long')
if (f === 'iso') return fmt.formatDateTime(now, { year: 'numeric', month: '2-digit', day: '2-digit' }).split(/\D+/).filter(Boolean).reverse().join(w.date_separator || '-')
const out = fmt.formatDateTime(now, DATE_FORMATS[f] || 'dateLong')
return (f === 'numeric' || f === 'numeric_short' || f === 'short') && w.date_separator ? out.split(/\D+/).filter(Boolean).join(w.date_separator) : out
}
const STAR = '#fbbf24' const STAR = '#fbbf24'
const GALLERY_IN = { const GALLERY_IN = {
fade: [{ opacity: 0 }, { opacity: 1 }], fade: [{ opacity: 0 }, { opacity: 1 }],
@@ -645,14 +724,14 @@ function Stack({ w, path, ctx }) {
...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }} ...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }}
{...CQ_BOX} data-testid="signage-stack-place" data-place={wp}> {...CQ_BOX} data-testid="signage-stack-place" data-place={wp}>
{body && (own && TIGHT.includes(cw.kind) ? ( {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', <div data-widget={wp} ref={animate(cw)} 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> alignItems: SELF[align], textAlign: align, ...plate(cw, true), ...fx(cw) }} data-testid="signage-w-box" data-tight="">{body}</div>
) : own ? ( ) : own ? (
<div data-widget={wp} style={{ position: 'absolute', left: `${cw.box.x}%`, top: `${cw.box.y}%`, width: `${cw.box.w}%`, height: `${cw.box.h}%`, <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) }} containerType: 'size', display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align, ...plate(cw), ...fx(cw) }}
{...CQ_BOX} data-testid="signage-w-box">{body}</div> {...CQ_BOX} ref={animate(cw)} 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> <div data-widget={wp} ref={animate(cw)} style={{ display: 'flex', maxWidth: '100%', maxHeight: '100%', ...(cw.kind === 'menu' || cw.kind === 'stack' ? { width: '100%', height: '100%' } : {}), ...plate(cw, true), ...fx(cw) }}>{body}</div>
))} ))}
</div> </div>
) )
+10 -2
View File
@@ -594,11 +594,13 @@ try {
const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } }) const wl = await api('POST', '/api/signage/playlists', { token: boss, body: { name: 'New widgets', orientation: 'landscape' } })
await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [ await api('POST', `/api/signage/playlists/${wl.id}/slides`, { token: boss, body: { kind: 'blank', duration_s: 60, content: { widgets: [
{ kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' }, { kind: 'shape', position: 'custom', box: { x: 2, y: 2, w: 10, h: 15 }, shape: 'star' },
{ kind: 'countdown', position: 'top-center', countdown_to: '2099-01-01T00:00', text: 'Opening in' }, { kind: 'countdown', position: 'top-center', countdown_to: '2099-01-01T00:00', text: 'Opening in', opacity: 60, rotation: 10, shadow: 'strong', animation: 'pop' },
{ kind: 'hours', position: 'top-left' }, { kind: 'wifi', position: 'bottom-right' }, { kind: 'contact', position: 'bottom-left' }, { kind: 'hours', position: 'top-left' }, { kind: 'wifi', position: 'bottom-right' }, { kind: 'contact', position: 'bottom-left' },
{ kind: 'ticker', position: 'top-bar', text: 'Fresh fish today' }, { kind: 'ticker', position: 'top-bar', text: 'Fresh fish today' },
{ kind: 'reviews', position: 'custom', box: { x: 30, y: 40, w: 40, h: 25 } }, { kind: 'reviews', position: 'custom', box: { x: 30, y: 40, w: 40, h: 25 } },
{ kind: 'gallery', position: 'custom', box: { x: 75, y: 30, w: 20, h: 20 }, gallery_source: 'folder', gallery_folder: dishes.id }] } } }) { kind: 'gallery', position: 'custom', box: { x: 75, y: 30, w: 20, h: 20 }, gallery_source: 'folder', gallery_folder: dishes.id },
{ kind: 'date', position: 'custom', box: { x: 5, y: 80, w: 20, h: 6 }, date_format: 'numeric', date_separator: '.' },
{ kind: 'clock', position: 'custom', box: { x: 30, y: 80, w: 20, h: 6 }, clock_format: '12', clock_separator: '.' }] } } })
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } }) await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: wl.id } })
const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'gallery'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1) const widgetsOn = async () => (await Promise.all(['shape', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'gallery'].map(k => tv.getByTestId(`signage-w-${k}`).count()))).every(n => n === 1)
r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV', r.check('6R.15: a shape, a countdown, the opening hours, Wi-Fi (from the identity), contact details and a scrolling text on the TV',
@@ -607,6 +609,12 @@ try {
&& await tv.getByTestId('signage-w-wifi').locator('svg').count() > 0) && await tv.getByTestId('signage-w-wifi').locator('svg').count() > 0)
r.check('6R.16: a gallery of a media folder shows its picture (kept on the TV)', await tv.getByTestId('signage-w-gallery').getAttribute('data-count') === '1' r.check('6R.16: a gallery of a media folder shows its picture (kept on the TV)', await tv.getByTestId('signage-w-gallery').getAttribute('data-count') === '1'
&& (await tv.getByTestId('signage-w-gallery').locator('img').getAttribute('src')).startsWith('blob:')) && (await tv.getByTestId('signage-w-gallery').locator('img').getAttribute('src')).startsWith('blob:'))
await sleep(1200) // its entrance (pop) is over
const cdBox = await tv.getByTestId('signage-w-countdown').evaluate(el => { const b = el.closest('[data-widget]'); const cs = getComputedStyle(b); return { o: cs.opacity, t: cs.transform, f: cs.filter } })
r.check('6R.17: More settings on the TV: opacity, turned, a shadow', cdBox.o === '0.6' && cdBox.t !== 'none' && cdBox.f.includes('drop-shadow'), JSON.stringify(cdBox))
const dateTxt = await tv.getByTestId('signage-w-date').textContent()
const clockTxt = await tv.getByTestId('signage-w-clock').textContent()
r.check('6R.17: a numeric date with dots, a 12-hour clock with a dot', /^\d\d\.\d\d\.\d{4}$/.test(dateTxt) && /^\d{1,2}\.\d\d\s?(am|pm|AM|PM|π\.μ\.|μ\.μ\.)$/i.test(clockTxt), `${dateTxt} | ${clockTxt}`)
r.check('6R.19: a review typed in by hand shows (the 2-star one is left out)', await tv.getByTestId('signage-w-reviews').getAttribute('data-count') === '1' r.check('6R.19: a review typed in by hand shows (the 2-star one is left out)', await tv.getByTestId('signage-w-reviews').getAttribute('data-count') === '1'
&& (await tv.getByTestId('signage-w-reviews').textContent()).includes('Best octopus')) && (await tv.getByTestId('signage-w-reviews').textContent()).includes('Best octopus'))
r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim())) r.check('6R.15: the countdown runs (days left to 2099)', /^\d+d \d\d:\d\d:\d\d$/.test((await tv.getByTestId('signage-w-countdown').textContent()).replace('Opening in', '').trim()))