feat(signage): venue badges, widgets' own look, widgets placed inside stacks, Save and leave, shared controls (owner review 5)

- Badges: the venue's list (setting signage.badges: names el/en, colours, an icon from a food and
  drink set) edited under Signage -> "Message & settings"; sent with the venue to screens and
  previews; several badges per product (MenuList.badges lists, a single one still read) in the
  shared multiple Dropdown; a board's badge colour / text colour override them (None = each own).
- Widgets: colour, background plate, font, bold / italic / underline, text size, QR colours;
  widgets in a stack's part get every setting, vertical alignment, and a custom box inside their
  place, picked (stack, then widget) and dragged on the preview (selection by path "2.1.0").
- Menu slides: vertical alignment of the list (board_valign); "Where the list sits" is now
  "Horizontal alignment".
- Message of the day: one component in the settings tab, on the Overview and from its widget.
- Leaving a slide with changes: "Save and leave" (ConfirmDialog altLabel).
- @xenia/ui: ColourField (with colour.js helpers), FieldRow (framed only while wrapped), Slider,
  IconPicker, Segmented multiple; native selects on the Overview and signage replaced by Dropdown,
  the device settings' colour input by ColourField.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 14:17:27 +02:00
co-authored by Claude Opus 5.5
parent aaa0914778
commit aa3fe85053
51 changed files with 1378 additions and 432 deletions
@@ -1,20 +1,21 @@
// Signage → Message and weather (plan step 5.6c): the message of the day (one place for every
// screen, at once) and the weather's town (picked from a search; the weather needs internet, and
// without it the widget is simply hidden on the TVs).
// Signage → Message & settings (plan step 5.6c; renamed in owner review 5, 2026-11-21): the message
// of the day (one place for every screen, at once; also on the Overview), the weather's town (picked
// from a search; the weather needs internet, and without it the widget is simply hidden on the TVs)
// and the venue's badges for menu boards (BadgesSettings).
import { useCallback, useEffect, useState } from 'react'
import toast from 'react-hot-toast'
import { CloudOff, RefreshCw, Search } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useLanguage, useTranslation } from '@xenia/i18n'
import { Button, Field, Input, Select, Spinner } from '@xenia/ui'
import { Button, Dropdown, Field, Input, Spinner } from '@xenia/ui'
import BadgesSettings from './BadgesSettings'
import MessageOfTheDay from './MessageOfTheDay'
import * as api from './signageApi'
export default function SignageSettingsTab() {
const { t } = useTranslation('manager')
const { formatDateTime } = useFormat()
const { language: lang } = useLanguage()
const [message, setMessage] = useState(null)
const [savedMessage, setSavedMessage] = useState('')
const [status, setStatus] = useState(null)
const [q, setQ] = useState('')
const [places, setPlaces] = useState(null)
@@ -23,29 +24,25 @@ export default function SignageSettingsTab() {
const load = useCallback(async () => {
try {
const [m, w] = await Promise.all([api.getMessage(), api.weatherStatus()])
setMessage(m.text || ''); setSavedMessage(m.text || ''); setStatus(w)
const w = await api.weatherStatus()
setStatus(w)
if (w.place?.units) setUnits(w.place.units)
} catch (err) { toast.error(errorMessage(err, t)) }
} catch (err) { toast.error(errorMessage(err, t)); setStatus(s => s || {}) }
}, [t])
useEffect(() => { load() }, [load])
const act = async (fn, done) => {
setBusy(true)
try { const r = await fn(); if (done) toast.success(done); return r } catch (err) { toast.error(errorMessage(err, t)); return null } finally { setBusy(false) }
}
if (message === null) return <div className="flex justify-center p-6"><Spinner /></div>
if (status === null) return <div className="flex justify-center p-6"><Spinner /></div>
const w = status?.weather
return (
<div className="grid gap-5 max-w-3xl" data-testid="signage-settings">
<div className="grid gap-5 max-w-5xl" data-testid="signage-settings">
<section className="rounded-card border border-line bg-surface p-4 grid gap-3">
<h2 className="text-body font-semibold text-ink">{t('signage.settings.message')}</h2>
<p className="text-label text-ink-2">{t('signage.settings.messageHint')}</p>
<div className="flex gap-2 items-start">
<Input value={message} maxLength={200} onChange={e => setMessage(e.target.value)} className="flex-1" aria-label={t('signage.settings.message')} data-testid="signage-message" />
<Button disabled={busy || message.trim() === savedMessage.trim()} data-testid="signage-message-save"
onClick={() => act(() => api.putMessage(message.trim()), t('settings.saved')).then(r => { if (r) setSavedMessage(r.text || '') })}>{t('fees.save')}</Button>
</div>
<MessageOfTheDay />
</section>
<section className="rounded-card border border-line bg-surface p-4 grid gap-3" data-testid="signage-weather">
@@ -68,7 +65,7 @@ export default function SignageSettingsTab() {
<Input value={q} onChange={e => setQ(e.target.value)} placeholder={t('signage.settings.townPlaceholder')} data-testid="signage-weather-search" />
</Field>
<Field label={t('signage.settings.unitsLabel')}>
<Select value={units} onChange={e => setUnits(e.target.value)} options={['celsius', 'fahrenheit'].map(u => ({ value: u, label: t(`signage.settings.units.${u}`) }))} />
<Dropdown value={units} onChange={setUnits} options={['celsius', 'fahrenheit'].map(u => ({ value: u, label: t(`signage.settings.units.${u}`) }))} />
</Field>
<Button variant="secondary" icon={<Search size={16} />} disabled={busy || q.trim().length < 2} data-testid="signage-weather-find"
onClick={() => act(() => api.weatherPlaces(q.trim(), lang === 'el' ? 'el' : 'en')).then(r => r && setPlaces(r))}>{t('signage.settings.find')}</Button>
@@ -88,6 +85,8 @@ export default function SignageSettingsTab() {
))}
</div>
</section>
<BadgesSettings />
</div>
)
}