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
@@ -13,15 +13,19 @@
// Owner review 3 (2026-11-21): the look part by part (MenuLook: headings, names, prices, dots,
// spacing, photos); a pencil beside each category and product on the board gives it a name for
// this board only (the catalogue keeps its own: the waiters' names stay as they are).
// Owner review 5 (2026-11-21): several badges per product, from the venue's list (Message & settings),
// in the shared multiple-choice dropdown; the list placed up / middle / down as well as left / right.
import { useEffect, useMemo, useState } from 'react'
import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, Eye, EyeOff, Pencil, RotateCcw, X } from 'lucide-react'
import { AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Eye, EyeOff, Pencil, RotateCcw, X } from 'lucide-react'
import { MENU_LANGUAGES, SALES_POINTS } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Dropdown, Field, IconButton, Input, Segmented, Select, Switch } from '@xenia/ui'
import { useFormat, useLanguage, useTranslation } from '@xenia/i18n'
import { badgeName } from '@xenia/signage'
import { Dropdown, Field, IconButton, Input, Segmented, Slider, Switch } from '@xenia/ui'
import client from '../../api/client'
import { BADGES, boardOrder, moveGroup, moveItem, toggled } from './signageLogic'
import { boardOrder, moveGroup, moveItem, toggled } from './signageLogic'
import { useBadges } from './useBadges'
import MenuLook from './MenuLook'
import { BackgroundField, Range, Section } from './SignageFields'
import { BackgroundField, Section } from './SignageFields'
import WidgetsEditor from './WidgetsEditor'
let catalogue = null // categories and products, read once for every menu editor on the page
@@ -41,6 +45,9 @@ function useCatalogue() {
export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [], widget = null, onWidget, extras, board = false, testid = 'signage-menu-editor' }) {
const { t } = useTranslation('manager')
const { formatMoney } = useFormat()
const { language } = useLanguage()
const defs = useBadges()
const badgeOptions = defs.map(d => ({ value: d.key, label: badgeName(d, language === 'el' ? 'el' : 'en'), dot: d.colour }))
const c = slide.content || {}
const setC = patch => onChange({ ...slide, content: { ...c, ...patch } })
const { cats, products } = useCatalogue()
@@ -53,6 +60,13 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
const found = q.trim().length < 1 ? [] : products.filter(p => p.name.toLowerCase().includes(q.trim().toLowerCase()) && !listed.has(p.id)).slice(0, 8)
const reorder = next => setC(boardOrder(next))
const badges = c.badges || {}
const badgesOf = id => { const v = badges[String(id)]; return typeof v === 'string' ? [v] : v || [] }
const setBadgesOf = (id, list) => {
const next = { ...badges }
if (list.length) next[String(id)] = list.slice(0, 4)
else delete next[String(id)]
setC({ badges: next })
}
const digits = v => Number(String(v).replace(/\D/g, ''))
const hidden = new Set(c.exclude_ids || [])
// this board's own names: empty = the catalogue's again
@@ -146,14 +160,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
className={`text-label ${off ? 'text-ink-3 opacity-70' : it.available ? 'text-ink' : 'text-ink-3 line-through'}`} />
{off && <span className="text-caption text-ink-3">{t('signage.menu.hiddenTag')}</span>}
{it.price != null && <span className={`text-caption tabular-nums ${off ? 'text-ink-3 opacity-70' : 'text-ink-2'}`}>{formatMoney(it.price)}</span>}
<Select size="sm" value={badges[String(it.id)] || ''} aria-label={t('signage.menu.badge')} data-testid="signage-menu-badge" disabled={off}
onChange={e => {
const next = { ...badges }
if (e.target.value) next[String(it.id)] = e.target.value
else delete next[String(it.id)]
setC({ badges: next })
}}
options={[{ value: '', label: t('signage.menu.noBadge') }, ...BADGES.map(b => ({ value: b, label: t(`signage.badges.${b}`) }))]} />
<Dropdown multiple size="sm" value={badgesOf(it.id)} onChange={list => setBadgesOf(it.id, list)} allLabel={t('signage.menu.noBadge')}
aria-label={t('signage.menu.badge')} data-testid="signage-menu-badge" disabled={off} className="w-40 shrink-0" options={badgeOptions} />
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={ii === 0} onClick={() => reorder(moveItem(groups, gi, ii, -1))} data-testid="signage-item-up"><ArrowUp size={14} /></IconButton>
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={ii === g.items.length - 1} onClick={() => reorder(moveItem(groups, gi, ii, 1))}><ArrowDown size={14} /></IconButton>
<IconButton size="sm" variant="ghost" label={t(off ? 'signage.menu.showAgain' : 'signage.menu.hide')} data-testid="signage-item-hide" aria-pressed={off}
@@ -196,19 +204,24 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
{/* the layout: columns, how wide the list is and where it sits, the pages (2026-11-21) */}
<Section title={t('signage.menu.layout')}>
<div className={`grid gap-4 grid-cols-2 items-start ${board ? 'xl:grid-cols-3' : 'xl:grid-cols-5'}`}>
<div className={`grid gap-4 grid-cols-2 items-start ${board ? 'xl:grid-cols-3' : 'xl:grid-cols-6'}`}>
<Field label={t('signage.columns')}>
<Segmented value={String(c.columns || (board ? 1 : 2))} onChange={v => setC({ columns: Number(v) })} data-testid="signage-columns" fill
options={[1, 2, 3].map(n => ({ value: String(n), label: String(n), testId: `signage-columns-${n}` }))} />
</Field>
{!board && <>
<Range label={t('signage.menu.width')} value={c.board_width || 100} min={40} max={100} step={5} suffix="%"
onChange={v => setC({ board_width: v })} testid="signage-menu-width" />
<Slider label={t('signage.menu.width')} value={c.board_width || 100} min={40} max={100} step={5} suffix="%"
onChange={v => setC({ board_width: v })} testId="signage-menu-width" />
<Field label={t('signage.menu.place')} hint={(c.board_width || 100) >= 100 ? t('signage.menu.placeHint') : undefined}>
<Segmented value={c.board_align || 'left'} onChange={v => setC({ board_align: v })} data-testid="signage-menu-align" fill
options={[['left', AlignLeft], ['center', AlignCenter], ['right', AlignRight]].map(([v, Icon]) => (
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.aligns.${v}`), testId: `signage-menu-align-${v}` }))} />
</Field>
<Field label={t('signage.menu.vplace')} hint={t('signage.menu.vplaceHint')}>
<Segmented value={c.board_valign || 'top'} onChange={v => setC({ board_valign: v })} data-testid="signage-menu-valign" fill
options={[['top', AlignVerticalJustifyStart], ['middle', AlignVerticalJustifyCenter], ['bottom', AlignVerticalJustifyEnd]].map(([v, Icon]) => (
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.verticals.${v}`), testId: `signage-menu-valign-${v}` }))} />
</Field>
</>}
<Field label={t('signage.menu.perPage')} hint={t(board ? 'signage.menu.perPageWidgetHint' : 'signage.menu.perPageHint')}>
<Input inputMode="numeric" value={c.page_size ? String(c.page_size) : ''} placeholder={board ? '8' : t('signage.menu.auto')}