feat(signage): new widgets (shape, scrolling text, countdown, opening hours, Wi-Fi, contact details); the venue's opening hours on the server, edited on the Schedule page

Shapes: rectangle, circle, triangle, polygon, star or own corners, fill or gradient,
border. Countdown: to a time every day or a date, from now / a span before / a set
time, in venue time (the slide shows what is left right now). Opening hours, Wi-Fi
(with a join-the-network code) and contact details read the venue's identity and
opening hours (GET/PUT /api/identity/hours; Schedule -> Opening hours, shaded on its
timeline); the editor warns with a link when they're missing. Plan 6R.15, F-112.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 13:24:54 +02:00
co-authored by Claude Opus 5.5
parent 2a38602d45
commit f26e51273c
22 changed files with 1002 additions and 46 deletions
@@ -0,0 +1,173 @@
// The settings of the widgets added in 6R.15 (owner 2026-11-22): a shape, a scrolling text, a
// countdown, the opening hours, the guests' Wi-Fi and the contact details. The last three read the
// venue (Settings → Identity, the Schedule page's opening hours): when that is missing the card says
// so with a link to where it is set. Used by WidgetsEditor (its row and the part under it).
import { Link } from 'react-router-dom'
import { useTranslation } from '@xenia/i18n'
import { ColourField, Dropdown, Field, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
import { useHours, useIdentity } from '../../shell/useIdentity'
import { CONTACT_KEYS, WIDGET_COLOURS } from './signageLogic'
const SHAPES = ['rectangle', 'circle', 'triangle', 'polygon', 'star', 'custom']
const isDate = v => !!v && v.length > 5
/** On the widget's row (where / size / alignment): its main choices. */
export function MoreInlineFields({ w, set }) {
const { t } = useTranslation('manager')
const k = 'signage.widgets'
if (w.kind === 'shape') {
return (<>
<Field label={t(`${k}.shape.kind`)}>
<Dropdown value={w.shape || 'rectangle'} onChange={shape => set({ shape })} data-testid="signage-widget-shape"
options={SHAPES.map(x => ({ value: x, label: t(`${k}.shape.kinds.${x}`) }))} />
</Field>
{(w.shape === 'polygon' || w.shape === 'star') && (
<Field label={t(w.shape === 'star' ? `${k}.shape.points` : `${k}.shape.sides`)}>
<NumberInput value={w.shape_sides ?? 6} min={3} max={12} onChange={v => set({ shape_sides: v ?? 3 })} data-testid="signage-widget-shape-sides" />
</Field>
)}
</>)
}
if (w.kind === 'ticker') {
return (<>
<Field label={t(`${k}.ticker.text`)} className="col-span-2">
<Input value={w.text || ''} maxLength={500} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-ticker-text" />
</Field>
<Field label={t(`${k}.ticker.direction`)}>
<Segmented fill value={w.ticker_direction || 'left'} onChange={ticker_direction => set({ ticker_direction })}
options={['left', 'right'].map(v => ({ value: v, label: t(`${k}.ticker.directions.${v}`) }))} />
</Field>
</>)
}
if (w.kind === 'countdown') {
const to = w.countdown_to || ''
return (<>
<Field label={t(`${k}.countdown.title`)}>
<Input value={w.text || ''} maxLength={80} placeholder={t(`${k}.countdown.titlePlaceholder`)} onChange={e => set({ text: e.target.value || null })} />
</Field>
<Field label={t(`${k}.countdown.ends`)}>
<Segmented fill value={isDate(to) ? 'date' : 'daily'} data-testid="signage-widget-countdown-mode"
onChange={m => set({ countdown_to: m === 'date' ? `${new Date().toISOString().slice(0, 10)}T${to.slice(-5) || '17:00'}` : (to.slice(-5) || '17:00') })}
options={['daily', 'date'].map(v => ({ value: v, label: t(`${k}.countdown.modes.${v}`) }))} />
</Field>
<Field label={t(isDate(to) ? `${k}.countdown.at` : `${k}.countdown.everyDayAt`)}>
<Input type={isDate(to) ? 'datetime-local' : 'time'} value={to} data-testid="signage-widget-countdown-to"
onChange={e => set({ countdown_to: e.target.value ? e.target.value.slice(0, isDate(to) ? 16 : 5) : null })} />
</Field>
</>)
}
if (w.kind === 'hours') {
return (<>
<Field label={t(`${k}.hours.style`)}>
<Segmented fill value={w.hours_style || 'week'} onChange={hours_style => set({ hours_style })} data-testid="signage-widget-hours-style"
options={['week', 'today'].map(v => ({ value: v, label: t(`${k}.hours.styles.${v}`) }))} />
</Field>
<Field label={t(`${k}.countdown.title`)}>
<Input value={w.text || ''} maxLength={80} placeholder={t(`${k}.hours.titlePlaceholder`)} onChange={e => set({ text: e.target.value || null })} />
</Field>
</>)
}
if (w.kind === 'wifi') {
return (
<Field label={t(`${k}.wifi.shows`)} className="col-span-2">
<div className="flex gap-2 flex-wrap">
<Switch boxed className="h-control" checked={w.wifi_qr !== false} onChange={on => set({ wifi_qr: on })} label={t(`${k}.wifi.qr`)} data-testid="signage-widget-wifi-qr" />
<Switch boxed className="h-control" checked={w.wifi_password !== false} onChange={on => set({ wifi_password: on })} label={t(`${k}.wifi.password`)} />
</div>
</Field>
)
}
if (w.kind === 'contact') {
return (
<Field label={t(`${k}.contact.shows`)} className="col-span-2">
<Dropdown multiple value={w.contact_fields || ['phone', 'website', 'instagram']} onChange={contact_fields => set({ contact_fields })} data-testid="signage-widget-contact-fields"
allLabel={t(`${k}.contact.none`)} options={CONTACT_KEYS.map(x => ({ value: x, label: t(`identity.contact.${x}`) }))} />
</Field>
)
}
return null
}
/** Under the row: what needs more room, and what the venue still has to set. */
export function MoreBelowFields({ w, set }) {
const { t } = useTranslation('manager')
const { data: identity } = useIdentity()
const { data: hours } = useHours()
const k = 'signage.widgets'
if (w.kind === 'shape') {
return (
<div className="grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]">
{w.shape === 'custom' && (
<Field label={t(`${k}.shape.custom`)} hint={t(`${k}.shape.customHint`)} className="col-span-2">
<Input value={w.shape_points || ''} maxLength={600} placeholder="50,0 100,100 0,100" onChange={e => set({ shape_points: e.target.value || null })} data-testid="signage-widget-shape-points" />
</Field>
)}
<ColourField label={t(`${k}.shape.fill`)} value={w.fill || WIDGET_COLOURS.shape} onChange={fill => set({ fill })} testId="signage-widget-fill" />
<ColourField label={t(`${k}.shape.fillTo`)} value={w.fill_to || WIDGET_COLOURS.shape} onChange={fill_to => set({ fill_to })} testId="signage-widget-fill-to"
auto={{ label: t(`${k}.shape.oneColour`), on: !w.fill_to, pick: () => set({ fill_to: null }) }} />
{w.fill_to && <Slider label={t(`${k}.shape.angle`)} value={w.fill_angle ?? 180} min={0} max={345} step={15} suffix="°" onChange={fill_angle => set({ fill_angle })} />}
<ColourField label={t(`${k}.shape.stroke`)} value={w.stroke || WIDGET_COLOURS.text} onChange={stroke => set({ stroke, stroke_width: w.stroke_width || 4 })} testId="signage-widget-stroke"
auto={{ label: t(`${k}.shape.noStroke`), on: !w.stroke || !w.stroke_width, pick: () => set({ stroke: null, stroke_width: 0 }) }} />
{w.stroke && w.stroke_width > 0 && <Slider label={t(`${k}.shape.strokeWidth`)} value={w.stroke_width} min={1} max={20} onChange={stroke_width => set({ stroke_width })} />}
{w.shape === 'star' && <Slider label={t(`${k}.shape.inner`)} value={w.shape_inner ?? 45} min={15} max={90} step={5} suffix="%" onChange={shape_inner => set({ shape_inner })} />}
{(w.shape || 'rectangle') === 'rectangle' && <Slider label={t(`${k}.shape.radius`)} value={w.radius || 0} min={0} max={50} suffix="%" onChange={radius => set({ radius })} />}
</div>
)
}
if (w.kind === 'ticker') {
return <Slider label={t(`${k}.ticker.speed`)} value={w.ticker_speed || 4} min={1} max={10} onChange={ticker_speed => set({ ticker_speed })} testId="signage-widget-ticker-speed" />
}
if (w.kind === 'countdown') {
const start = w.countdown_start || 'now'
return (
<div className="grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]">
<Field label={t(`${k}.countdown.starts`)}>
<Dropdown value={start} onChange={countdown_start => set({ countdown_start, ...(countdown_start === 'at' && !w.countdown_at ? { countdown_at: (w.countdown_to || '15:00').slice(-5) } : {}) })}
data-testid="signage-widget-countdown-start" options={['now', 'before', 'at'].map(v => ({ value: v, label: t(`${k}.countdown.startModes.${v}`) }))} />
</Field>
{start === 'before' && (
<Field label={t(`${k}.countdown.minutesBefore`)}>
<NumberInput value={w.countdown_before ?? 120} min={1} max={10080} suffix={t(`${k}.countdown.min`)} onChange={v => set({ countdown_before: v ?? 1 })} data-testid="signage-widget-countdown-before" />
</Field>
)}
{start === 'at' && (
<Field label={t(`${k}.countdown.startsAt`)}>
<Input type={isDate(w.countdown_to) ? 'datetime-local' : 'time'} value={w.countdown_at || ''} onChange={e => set({ countdown_at: e.target.value || null })} />
</Field>
)}
{start !== 'now' && (
<Field label={t(`${k}.countdown.waiting`)}>
<Dropdown value={w.countdown_waiting || 'full'} onChange={countdown_waiting => set({ countdown_waiting })}
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`)}>
<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>
)
}
if (w.kind === 'hours') {
return (
<div className="grid gap-3">
<Switch checked={w.hours_group !== false} onChange={hours_group => set({ hours_group })} label={t(`${k}.hours.group`)} description={t(`${k}.hours.groupHint`)} />
{hours && !hours.set && (
<Notice tone="warning" title={t(`${k}.hours.missing`)} data-testid="signage-widget-hours-missing">
<Link to="/management/schedule?hours=1" className="text-accent-ink font-medium underline">{t(`${k}.hours.setThem`)}</Link>
</Notice>
)}
</div>
)
}
if (w.kind === 'wifi' || w.kind === 'contact') {
const missing = w.kind === 'wifi' ? identity && !identity.wifi?.ssid : identity && !(w.contact_fields || ['phone', 'website', 'instagram']).some(x => identity.contact?.[x])
return missing
? (
<Notice tone="warning" title={t(`${k}.${w.kind}.missing`)} data-testid={`signage-widget-${w.kind}-missing`}>
<Link to="/settings?tab=identity" className="text-accent-ink font-medium underline">{t(`${k}.fromIdentity`)}</Link>
</Notice>
)
: <p className="text-caption text-ink-3 -mt-2">{t(`${k}.${w.kind}.hint`)} <Link to="/settings?tab=identity" className="text-accent-ink underline">{t(`${k}.fromIdentity`)}</Link></p>
}
return null
}
@@ -18,11 +18,14 @@
// has every setting a slide's widget has, aligned both ways in its place or moved and sized there on
// the preview (Custom); the message of the day changed from its widget. The picked widget is a path
// ("2", "2.1.0": see WidgetCanvas).
// 6R.15 (owner 2026-11-22): a shape, a scrolling text, a countdown, the opening hours, Wi-Fi and contact
// details (MoreWidgetFields).
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
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,
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
CalendarClock, Contact, MoveHorizontal, Shapes, Timer, Wifi,
} from 'lucide-react'
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
import { useTranslation } from '@xenia/i18n'
@@ -31,12 +34,14 @@ import MessageOfTheDay from './MessageOfTheDay'
import { usePerformance } from './usePerformance'
import * as api from './signageApi'
import MenuEditor from './MenuEditor'
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
import { MediaPick, Section } from './SignageFields'
import {
CELL_KINDS, cellWidget, fillPlace, FONT_KEYS, WIDGET_COLOURS, 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 }
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
shape: Shapes, ticker: MoveHorizontal, countdown: Timer, hours: CalendarClock, wifi: Wifi, contact: 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))]'
@@ -177,7 +182,7 @@ 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']
const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact']
/**
* A widget's own look (owner review 5), folded under "Text and colours": its colour (text and
@@ -187,7 +192,7 @@ const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather']
function LookFields({ w, set }) {
const { t } = useTranslation('manager')
const [open, setOpen] = useState(false)
if (w.kind === 'menu' || w.kind === 'stack') return null
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)
@@ -218,7 +223,7 @@ function LookFields({ w, set }) {
</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 === '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" />
</>}
@@ -249,6 +254,7 @@ function MessageHint() {
/** The options only some widgets have, on the same row as where / size / alignment. */
function InlineFields({ w, set }) {
const { t } = useTranslation('manager')
if (['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact'].includes(w.kind)) return <MoreInline w={w} set={set} />
if (w.kind === 'message') {
return (
<Field label={t('signage.widgets.ownText')} className="col-span-2">
@@ -305,6 +311,7 @@ function InlineFields({ w, set }) {
/** What needs more room, under the row: the picture, hints, the QR's own link, a menu's list, a stack's parts. */
function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, onSelect }) {
const { t } = useTranslation('manager')
if (['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact'].includes(w.kind)) return <MoreBelow w={w} set={set} />
if (w.kind === 'logo') {
return <MediaPick kind="image" value={w.media_id} entry={media[String(w.media_id)]} testid="signage-widget-logo"
onChange={item => { onMedia(item); set({ media_id: item.id }) }} />
@@ -137,9 +137,9 @@ export function mediaLookup(map) {
// ── menu boards and widgets (5.6b) ───────────────────────────────────────────
export const WIDGET_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu']
export const WIDGET_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu', 'shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact']
/** What a stack's part can show (2026-11-21): a widget, a stack one level deep, a library slide. */
export const CELL_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu']
export const CELL_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'menu', 'shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact']
/** A new widget of a kind ('hstack' / 'vstack': a stack side by side / one over the other), where it
* usually goes: a menu or a stack in a box of its own (they fill a box). */
@@ -151,16 +151,24 @@ export function newWidget(kind) {
if (kind === 'menu') {
return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 55, y: 10, w: 40, h: 80 }, board: { select: 'all', columns: 1, sales_point: 'in_store' } }
}
return { kind, position: kind === 'message' || kind === 'text' ? 'bottom-bar' : 'top-right', size: 'medium', align: 'auto',
...(kind === 'text' ? { text: '' } : {}) }
if (kind === 'shape') return { kind, position: 'custom', size: 'custom', align: 'auto', box: { x: 40, y: 30, w: 20, h: 35 }, shape: 'rectangle', radius: 10 }
return { kind, position: NEW_PLACE[kind] || 'top-right', size: 'medium', align: 'auto',
...(kind === 'text' || kind === 'ticker' ? { text: '' } : {}), ...(kind === 'countdown' ? { countdown_to: '17:00' } : {}) }
}
/** The contact details a contact widget can show (routers/identity.py Contact, signage ContactKey). */
export const CONTACT_KEYS = ['phone', 'phone2', 'email', 'address', 'website', 'google', 'facebook', 'instagram', 'tiktok', 'tripadvisor', 'whatsapp', 'viber']
// where a new widget goes (6R.15 kinds; the others top right, texts in the bottom bar)
const NEW_PLACE = { message: 'bottom-bar', text: 'bottom-bar', ticker: 'bottom-bar', countdown: 'top-center', hours: 'top-left', wifi: 'bottom-right', contact: 'bottom-left' }
/** A widget put in a stack's part: only what it shows (a part has no corner, size or box). */
export function cellWidget(kind) {
if (kind === 'hstack' || kind === 'vstack') {
return { kind: 'stack', direction: kind === 'hstack' ? 'row' : 'column', align: 'auto', cells: [{ share: 50 }, { share: 50 }] }
}
return { kind, align: 'auto', ...(kind === 'menu' ? { board: { select: 'all', columns: 1, sales_point: 'in_store' } } : {}), ...(kind === 'text' ? { text: '' } : {}) }
return { kind, align: 'auto', ...(kind === 'menu' ? { board: { select: 'all', columns: 1, sales_point: 'in_store' } } : {}), ...(kind === 'text' || kind === 'ticker' ? { text: '' } : {}),
...(kind === 'countdown' ? { countdown_to: '17:00' } : {}) }
}
/** The weather's days, as one choice: from (0 today, 1 tomorrow, 2 the day after) and how many. */
@@ -388,7 +396,7 @@ export function toggleMonthDay(line, key) {
/** A menu's colours until the venue picks its own (the TV's data, as the player draws them). */
export const MENU_COLOURS = { accent: '#f59e0b', text: '#ffffff', newBadge: '#38bdf8' }
/** A widget's colours before the venue picks its own (owner review 5). */
export const WIDGET_COLOURS = { text: '#ffffff', plate: '#00000080', qr: '#000000', qrBackground: '#ffffff' }
export const WIDGET_COLOURS = { text: '#ffffff', plate: '#00000080', qr: '#000000', qrBackground: '#ffffff', shape: '#f59e0b' }
/** A menu's look as new ("Reset the look", owner review 4): every part back to the board's. */
export const MENU_LOOK_DEFAULTS = {