From aaa09147788f5741bf66e5abfed6748418d9341d Mon Sep 17 00:00:00 2001 From: bonamin Date: Sat, 21 Nov 2026 12:53:14 +0200 Subject: [PATCH] feat(signage): look rows that wrap, one colour field with opacity, badges' text, several widgets per stack part, pages up to 2200 px (owner review 4) - Menu text look: each field names its part ("Headings size"), rows wrap in aligned columns on alternating bands; names align left / right; line and letter spacing as lists (Auto default); each field changes only itself (followers frozen before the other changes); badge colour + badge text colour (auto: readableOn); "Reset the look" with a question. - ColourField everywhere in signage: a Popover panel (new @xenia/ui Popover, portal, kept in the window) with 12 presets, picker, opacity (#rrggbbaa) and typed code; HEX accepts 8 digits. - Stacks: Cell.widgets (a stored `widget` still reads), several widgets per part laid across the stack's direction; extras by path stack.part.place; Add a widget adds, each removable / ordered. - Page rule: --x-page-max is 2200px (no longer follows the window height). Co-Authored-By: Claude Opus 5.5 --- docs/DESIGN.md | 3 +- local_backend/routers/signage.py | 47 ++-- local_backend/tests/test_signage_stacks.py | 32 ++- .../src/pages/signage/MenuLook.jsx | 200 +++++++++++------- .../src/pages/signage/SignageFields.jsx | 122 ++++++----- .../src/pages/signage/SlideEditor.jsx | 4 +- .../src/pages/signage/WidgetsEditor.jsx | 146 +++++++------ .../src/pages/signage/signageLogic.js | 40 +++- .../src/pages/signage/useSlideDraft.js | 3 +- manager_dashboard/tests/signage.test.mjs | 13 ++ packages/i18n/locales/el/manager.json | 64 ++++-- packages/i18n/locales/en/manager.json | 64 ++++-- packages/signage/src/Slides.jsx | 34 +-- packages/signage/src/logic.js | 28 ++- packages/signage/tests/logic.test.mjs | 14 ++ packages/ui/src/components.css | 9 + packages/ui/src/components/Page.jsx | 2 +- packages/ui/src/components/Popover.jsx | 65 ++++++ packages/ui/src/index.js | 1 + packages/ui/src/tokens.css | 7 +- tests/e2e/manager_layout.mjs | 8 +- tests/e2e/signage.mjs | 38 +++- 22 files changed, 663 insertions(+), 281 deletions(-) create mode 100644 packages/ui/src/components/Popover.jsx diff --git a/docs/DESIGN.md b/docs/DESIGN.md index dbe659f..583388e 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -16,7 +16,7 @@ Every page's root is `` from `@xenia/ui`. It provides: - **its own scrolling** (the shell's `
` never scrolls), -- **the width:** it fills the content area up to the width of a 16:9 screen (`--x-page-max` = `max(1280px, 100vh × 16/9)`). On a 1080p monitor the page fills the screen; on an ultrawide it stays 16:9 wide and is **centred**, +- **the width:** it fills the content area up to 2200 px (`--x-page-max`). On a 1080p monitor the page fills the screen; on an ultrawide it stays 2200 px wide and is **centred**. The width never depends on the window's height (owner 2026-11-21: a short window used to narrow the page), - **the padding and gaps** (`--x-page-pad`, `--x-page-gap`), the same on every page. ```jsx @@ -48,6 +48,7 @@ Every page is on `` except Inventory → Stock (a placeholder). Two-column | Filters / actions over a list | `Toolbar`, `ToolbarSpacer` | every control in it the same height; the search box grows | | Search | `SearchInput` | icon, clear button; `onChange(text)` | | Choose one / several | `Dropdown` (`multiple`) | **never a native ` setC({ line_height: num(e.target.value, 0.8, 3) })} /> - - - setC({ letter_spacing: num(e.target.value, -0.1, 0.5) })} /> - - {c.show_photos ? <> - setC({ photo_size: v })} testid="signage-look-photo-size" /> - - setC({ photo_shape: v })} data-testid="signage-look-photo-shape" - options={['square', 'rounded', 'round'].map(x => ({ value: x, label: t(`signage.look.shapes.${x}`) }))} /> + + {cell('size', setStyle('dot_style', { size: v })} testid="signage-look-dots-size" />)} + {cell('colour', setStyle('dot_style', { colour: v })} testid="signage-look-dots-colour" />)} + {cell('font', ( + + setStyle('dot_style', { style: v })} data-testid="signage-look-dots-style" + options={['dotted', 'dashed', 'solid', 'none'].map(x => ({ value: x, label: t(`signage.look.dotStyles.${x}`) }))} /> - : <>} - setC({ accent_colour: v })} testid="signage-accent" /> - -

{t('signage.look.hint')}

+ ))} + {cell('colour', )} + {cell('colour', setC({ badge_text_colour: v })} + testid="signage-badge-text" auto={{ label: t('signage.look.badgeTextAuto'), on: !c.badge_text_colour, pick: () => setC({ badge_text_colour: null }) }} />)} +
+ + {cell('font', ( + + setC({ line_height: v === '' ? null : Number(v) })} data-testid="signage-look-line-height" + options={choices(LINE_HEIGHTS, c.line_height, x => `${x}×`)} /> + + ))} + {cell('font', ( + + setC({ letter_spacing: v === '' ? null : Number(v) })} data-testid="signage-look-letter-spacing" + options={choices(LETTER_SPACINGS, c.letter_spacing, x => `${x > 0 ? '+' : ''}${Math.round(x * 100)}%`)} /> + + ))} + {c.show_photos && <> + {cell('size', setC({ photo_size: v })} testid="signage-look-photo-size" />)} + {cell('font', ( + + setC({ photo_shape: v })} data-testid="signage-look-photo-shape" + options={['square', 'rounded', 'round'].map(x => ({ value: x, label: t(`signage.look.shapes.${x}`) }))} /> + + ))} + } + +

{t('signage.look.hint')}

+ {confirmDialog} ) } -function RowLabel({ children }) { - return {children} +/** A row of the look: its fields keep their least width and wrap to a second line, in columns that + * line up from row to row; rows alternate shades. */ +function Band({ testid, children }) { + return ( +
+ {children} +
+ ) } /** Bold, italic, underline: three toggles as tall as a field. */ @@ -114,7 +160,7 @@ function TextToggles({ s, onChange, testid }) { {items.map(([k, Icon, on]) => ( diff --git a/manager_dashboard/src/pages/signage/SignageFields.jsx b/manager_dashboard/src/pages/signage/SignageFields.jsx index 02733ce..886932a 100644 --- a/manager_dashboard/src/pages/signage/SignageFields.jsx +++ b/manager_dashboard/src/pages/signage/SignageFields.jsx @@ -3,12 +3,13 @@ // a background (colour or photo with darkening), a slider with its value. // 2026-11-21 (owner review 2): the slider framed like the fields beside it; a colour as a field // (its swatch and code) that opens the ready colours and the picker, so it fits a row of fields. -import { useEffect, useRef, useState } from 'react' +// Owner review 4: that colour field everywhere, its panel over the page, see-through colours. +import { useCallback, useRef, useState } from 'react' import { AlertTriangle, Film, ImageIcon, X } from 'lucide-react' import { useTranslation } from '@xenia/i18n' -import { Button, Dropdown, Field, IconButton } from '@xenia/ui' +import { Button, Dropdown, Field, IconButton, Input, Popover } from '@xenia/ui' import MediaPicker from '../media/MediaPicker' -import { COLOUR_PRESETS } from './signageLogic' +import { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './signageLogic' /** A part of the slide editor: its title over a thin line, then its fields (DESIGN.md §3). */ export function Section({ title, aside, children, testid, className = '' }) { @@ -69,66 +70,71 @@ export function MediaPick({ kind = 'image', value, entry, onChange, onRemove, mi ) } -/** A colour the venue chooses for its TV (stored as #rrggbb: data, not a theme colour): a few - * ready colours with one click, and the picker for any other (2026-11-21). `compact`: a field - * (swatch and code) that opens them, as tall and as wide as the fields beside it. */ -export function ColourField({ label, value, onChange, testid, presets = COLOUR_PRESETS, compact = false }) { +/** + * A colour the venue chooses for its TV (data, not a theme colour: #rrggbb, or #rrggbbaa when + * see-through): a field (its swatch and code) that opens a small panel over the page (owner review + * 4, 2026-11-21: every signage colour): twelve ready colours, then the picker, the opacity and the + * code typed by hand. Each field changes only its own colour. `auto` ({ label, on, pick }): a first + * choice that lets the TV choose (a badge's text: white or black, whichever reads). + */ +export function ColourField({ label, value, onChange, testid, presets = COLOUR_PRESETS, auto, className }) { + const { t } = useTranslation('manager') + const [open, setOpen] = useState(false) + const [typed, setTyped] = useState(null) + const btn = useRef(null) const v = (value || '#000000').toLowerCase() - if (compact) return + const { rgb, alpha } = splitAlpha(v) + const close = useCallback(() => { setOpen(false); setTyped(null) }, []) return ( -
- {label} - - {presets.map(c => ( -
+ <> + + + + + {auto && ( + + )} +
+ {presets.map(c => ( + + ))} +
+
+ {t('signage.colourPick.custom')} +
+ { setTyped(null); onChange(joinAlpha(e.target.value, alpha)) }} data-testid={testid} aria-label={label} + className="w-10 h-control shrink-0 rounded-control border border-line bg-surface cursor-pointer p-0.5" /> + { setTyped(e.target.value); const c = typedColour(e.target.value); if (c) onChange(c) }} onBlur={() => setTyped(null)} /> +
+ +
+
+ ) } -function ColourPick({ label, value, onChange, testid, presets }) { - const [open, setOpen] = useState(false) - const box = useRef(null) - useEffect(() => { - if (!open) return undefined - const away = e => { if (!box.current?.contains(e.target)) setOpen(false) } - const esc = e => { if (e.key === 'Escape') setOpen(false) } - window.addEventListener('pointerdown', away) - window.addEventListener('keydown', esc) - return () => { window.removeEventListener('pointerdown', away); window.removeEventListener('keydown', esc) } - }, [open]) +/** A colour's swatch, over a checkerboard so a see-through colour shows as one. */ +function Swatch({ colour, className = '' }) { return ( - -
- - {open && ( -
-
- {presets.map(c => ( -
- -
- )} -
-
+
{bg.kind === 'colour' - ? set({ colour })} testid={`${testid}-colour`} /> + ? set({ colour })} testid={`${testid}-colour`} className="max-w-xs" /> : (
{ onMedia(item); setC({ media_id: item.id }) }} testid="signage-picture" />
{fit} - setC({ background_colour: v })} /> + setC({ background_colour: v })} testid="signage-around" className="max-w-xs" />
)} @@ -162,7 +162,7 @@ export function TextLook({ c, setC, align = true, children }) { setC({ text_size: v })} testid="signage-text-size" /> - setC({ text_colour: v })} testid="signage-text-colour" /> + setC({ text_colour: v })} testid="signage-text-colour" /> {children}
diff --git a/manager_dashboard/src/pages/signage/WidgetsEditor.jsx b/manager_dashboard/src/pages/signage/WidgetsEditor.jsx index 15b6a34..8302538 100644 --- a/manager_dashboard/src/pages/signage/WidgetsEditor.jsx +++ b/manager_dashboard/src/pages/signage/WidgetsEditor.jsx @@ -12,15 +12,16 @@ // level deep) or a whole slide from the Slides library. // Owner review 3 (2026-11-21): a stack's parts sized by dragging the lines between them on its bar; // "Add a widget" beside what a part shows; Delete removes the picked widget (WidgetCanvas). +// Owner review 4 (2026-11-21): a part holds several widgets, added with "Add a widget". // Up to 10 (the server's limit). import { Fragment, useEffect, useRef, useState } from 'react' import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical, ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed, } from 'lucide-react' -import { evenShares, setShare } from '@xenia/signage' +import { cellWidgets, evenShares, setShare } from '@xenia/signage' import { useTranslation } from '@xenia/i18n' -import { Button, Dropdown, Field, IconButton, Input, Segmented, Switch } from '@xenia/ui' +import { Button, Dropdown, Field, IconButton, Input, Popover, Segmented, Switch } from '@xenia/ui' import * as api from './signageApi' import MenuEditor from './MenuEditor' import { MediaPick, Section } from './SignageFields' @@ -255,8 +256,9 @@ function MenuBoardFields({ w, set, extras, path }) { /** * A stack's parts: side by side or one over the other, how many (2–6), their sizes (drag the lines * between them on the bar, or focus one and use the arrow keys; "Split evenly"), and what each - * shows: a widget (picked from the list or with "Add a widget"), another stack (one level deep), - * a slide from the Slides library, or nothing. + * shows: widgets added with "Add a widget" (several share the part, owner review 4: one over the + * other in a side-by-side stack, side by side in the other; each with its settings, moved up or + * down, removed), another stack (one level deep), or a slide from the Slides library. */ function StackFields({ w, set, media, onMedia, extras, path, depth }) { const { t } = useTranslation('manager') @@ -264,22 +266,27 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) { const cells = w.cells || [] const shares = cells.map(c => Math.round(c.share || 0)) const setCells = next => set({ cells: next }) - const setCell = (j, patch) => setCells(cells.map((c, k) => (k === j ? { ...c, ...patch } : c))) + const setCell = (j, patch) => setCells(cells.map((c, k) => { + if (k !== j) return c + const { widget: _old, ...rest } = { ...c, ...patch } // a part stored with one `widget`: now `widgets` + return rest + })) const setShares = next => setCells(cells.map((c, k) => ({ ...c, share: next[k] }))) const count = n => { const even = evenShares(n) setCells(Array.from({ length: n }, (_, k) => ({ ...(cells[k] || {}), share: even[k] }))) } - const shows = c => (c.slide_id ? 'slide' : c.widget ? (c.widget.kind === 'stack' ? (c.widget.direction === 'column' ? 'vstack' : 'hstack') : c.widget.kind) : '') - const pick = (j, v) => { - if (!v) setCell(j, { widget: null, slide_id: null }) - else if (v === 'slide') setCell(j, { widget: null, slide_id: slides[0]?.id ?? null }) - else setCell(j, { widget: cellWidget(v), slide_id: null }) + const setWidgets = (j, list) => setCell(j, { widgets: list, slide_id: null }) + const add = (j, v) => { + if (v === 'slide') setCell(j, { widgets: [], slide_id: slides[0]?.id ?? null }) + else setWidgets(j, [...cellWidgets(cells[j]), cellWidget(v)]) } const kinds = [...CELL_KINDS, ...(depth === 0 ? ['hstack', 'vstack'] : [])] const label = c => { - const v = shows(c) - return !v ? t('signage.widgets.stack.nothing') : v === 'slide' ? (slides.find(x => x.id === c.slide_id)?.name || t('signage.widgets.stack.slide')) : t(`signage.widgets.kinds.${v}`) + const ws = cellWidgets(c) + if (ws.length) return ws.map(x => kindLabel(t, x)).join(' · ') + if (c.slide_id != null) return slides.find(x => x.id === c.slide_id)?.name || t('signage.widgets.stack.slide') + return t('signage.widgets.stack.nothing') } return (
@@ -298,37 +305,59 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) {
-

{t('signage.widgets.stack.barHint')}

+

{t(w.direction === 'column' ? 'signage.widgets.stack.barHintColumn' : 'signage.widgets.stack.barHint')}

{cells.map((c, j) => { const cp = `${path}.${j}` - const v = shows(c) - const setW = patch => setCell(j, { widget: { ...c.widget, ...patch } }) + const ws = cellWidgets(c) + const slide = !ws.length && c.slide_id != null + const setOne = (k, patch) => setWidgets(j, ws.map((x, m) => (m === k ? { ...x, ...patch } : x))) + const moveOne = (k, to) => { if (to >= 0 && to < ws.length) setWidgets(j, moved(ws, k, to)) } return (
-
+
{t('signage.widgets.stack.partTitle', { n: j + 1 })} {shares[j]}% + {!ws.length && !slide && · {t('signage.widgets.stack.nothing')}} + + add(j, v)} />
-
- - pick(j, x)} data-testid="signage-stack-shows" - options={[{ value: '', label: t('signage.widgets.stack.nothing') }, - ...kinds.map(k => ({ value: k, label: t(`signage.widgets.kinds.${k}`) })), - { value: 'slide', label: t('signage.widgets.stack.aSlide') }]} /> - -
pick(j, x)} filled={!!v} />
- {c.slide_id != null || v === 'slide' ? ( - - setCell(j, { slide_id: x ? Number(x) : null })} data-testid="signage-stack-slide" + {slide && ( +
+ + setCell(j, { slide_id: x ? Number(x) : null })} data-testid="signage-stack-slide" options={slides.length ? slides.map(s => ({ value: String(s.id), label: s.name })) - : [{ value: '', label: t('signage.widgets.stack.noSlides') }]} /> + : [{ value: String(c.slide_id), label: t('signage.widgets.stack.noSlides') }]} /> - ) : c.widget && <> - {c.widget.kind !== 'stack' && } - - } -
- {c.widget && } + setCell(j, { slide_id: null })} data-testid="signage-stack-slide-remove"> + + +
+ )} + {ws.map((x, k) => { + const Icon = iconOf(x) + const setW = patch => setOne(k, patch) + return ( +
+
+
+ {x.kind !== 'stack' && ( +
+ + +
+ )} + +
+ ) + })}
) })} @@ -390,39 +419,30 @@ function ShareBar({ column, shares, labels, onChange }) { ) } -/** "Add a widget" to a part: every widget (and a slide from the Slides library) in a small panel. */ -function AddToPart({ kinds, onPick, filled }) { +/** "Add a widget" to a part: every widget (and a slide from the Slides library) in a small panel + * over the page; widgets add up, a slide takes the part's place. */ +function AddToPart({ kinds, onPick }) { const { t } = useTranslation('manager') const [open, setOpen] = useState(false) - const box = useRef(null) - useEffect(() => { - if (!open) return undefined - const away = e => { if (!box.current?.contains(e.target)) setOpen(false) } - const esc = e => { if (e.key === 'Escape') setOpen(false) } - window.addEventListener('pointerdown', away) - window.addEventListener('keydown', esc) - return () => { window.removeEventListener('pointerdown', away); window.removeEventListener('keydown', esc) } - }, [open]) + const btn = useRef(null) const choose = k => { onPick(k); setOpen(false) } return ( -
- - {open && ( -
- {[...kinds, 'slide'].map(k => { - const Icon = k === 'slide' ? BookImage : ICON[k] - return ( - - ) - })} -
- )} -
+ setOpen(false)} role="menu" className="w-[22rem] grid grid-cols-2 gap-1.5 p-2" data-testid="signage-stack-add-menu"> + {[...kinds, 'slide'].map(k => { + const Icon = k === 'slide' ? BookImage : ICON[k] + return ( + + ) + })} + + ) } diff --git a/manager_dashboard/src/pages/signage/signageLogic.js b/manager_dashboard/src/pages/signage/signageLogic.js index bbc4940..b9c92c6 100644 --- a/manager_dashboard/src/pages/signage/signageLogic.js +++ b/manager_dashboard/src/pages/signage/signageLogic.js @@ -206,8 +206,33 @@ export function slideFromSaved(saved) { return { kind: saved.kind, ...slideBody(saved), content: JSON.parse(JSON.stringify(saved.content || {})) } } -/** Colours offered with one click beside the colour picker (the venue's TV: data, not the theme). */ -export const COLOUR_PRESETS = ['#ffffff', '#111827', '#fde68a', '#f59e0b', '#ef4444', '#22c55e', '#38bdf8', '#a78bfa', '#f472b6'] +/** Colours offered with one click in the colour picker (the venue's TV: data, not the theme): + * two rows of six (owner review 4, 2026-11-21). */ +export const COLOUR_PRESETS = [ + '#ffffff', '#d1d5db', '#6b7280', '#111827', '#000000', '#fde68a', + '#f59e0b', '#ef4444', '#f472b6', '#a78bfa', '#38bdf8', '#22c55e', +] + +/** A colour as its #rrggbb and its opacity (0–100 %): #rrggbbaa is see-through (2026-11-21). */ +export function splitAlpha(hex) { + const h = String(hex || '#000000').toLowerCase() + const rgb = /^#[0-9a-f]{6}/.test(h) ? h.slice(0, 7) : '#000000' + const a = /^#[0-9a-f]{8}$/.test(h) ? Math.round((parseInt(h.slice(7, 9), 16) / 255) * 100) : 100 + return { rgb, alpha: a } +} + +/** #rrggbb with an opacity: #rrggbb when it is solid, #rrggbbaa otherwise. */ +export function joinAlpha(rgb, alpha) { + const a = Math.max(0, Math.min(100, Math.round(alpha))) + return a >= 100 ? rgb : `${rgb}${Math.round((a / 100) * 255).toString(16).padStart(2, '0')}` +} + +/** A colour typed by hand: #rgb, #rrggbb or #rrggbbaa (the # optional) → #rrggbb(aa), or null. */ +export function typedColour(text) { + let h = String(text || '').trim().toLowerCase().replace(/^#/, '') + if (/^[0-9a-f]{3}$/.test(h)) h = h.split('').map(x => x + x).join('') + return /^[0-9a-f]{6}([0-9a-f]{2})?$/.test(h) ? `#${h}` : null +} // ── widgets moved and sized on the preview (2026-11-21) ────────────────────── @@ -309,3 +334,14 @@ 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' } + +/** A menu's look as new ("Reset the look", owner review 4): every part back to the board's. */ +export const MENU_LOOK_DEFAULTS = { + font: 'sans', text_size: 100, text_colour: MENU_COLOURS.text, accent_colour: MENU_COLOURS.accent, badge_text_colour: null, + heading_style: {}, item_style: {}, price_style: {}, dot_style: {}, + line_height: null, letter_spacing: null, photo_size: 100, photo_shape: 'rounded', +} + +/** 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] diff --git a/manager_dashboard/src/pages/signage/useSlideDraft.js b/manager_dashboard/src/pages/signage/useSlideDraft.js index 3626c9b..0c918ac 100644 --- a/manager_dashboard/src/pages/signage/useSlideDraft.js +++ b/manager_dashboard/src/pages/signage/useSlideDraft.js @@ -7,7 +7,8 @@ import { placeWidget } from './signageLogic' // what doesn't change what the server adds (where things sit, how they look): left out of the key const LOOK = new Set(['box', 'position', 'size', 'align', 'background', 'text_colour', 'accent_colour', 'font', 'text_size', - 'board_width', 'board_align', 'title', 'body', 'vertical', 'columns', 'page_seconds', 'direction', 'share', 'clock_seconds', 'date_style']) + 'board_width', 'board_align', 'title', 'body', 'vertical', 'columns', 'page_seconds', 'direction', 'share', 'clock_seconds', 'date_style', + 'heading_style', 'item_style', 'price_style', 'dot_style', 'line_height', 'letter_spacing', 'photo_size', 'photo_shape', 'badge_text_colour']) /** * The draft as the server resolves it for the preview (2026-11-21): a menu board's products diff --git a/manager_dashboard/tests/signage.test.mjs b/manager_dashboard/tests/signage.test.mjs index 9e02057..6d8f25a 100644 --- a/manager_dashboard/tests/signage.test.mjs +++ b/manager_dashboard/tests/signage.test.mjs @@ -101,3 +101,16 @@ test('the Slides library: what is saved, and a copy for a playlist', async () => copy.content.widgets[0].kind = 'clock' assert.equal(saved.content.widgets[0].kind, 'name') // a copy, never the kept slide }) + +test('a colour with its opacity: #rrggbbaa, typed by hand (owner review 4)', async () => { + const { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } = await import('../src/pages/signage/signageLogic.js') + assert.equal(COLOUR_PRESETS.length, 12) + assert.deepEqual(splitAlpha('#FF0000'), { rgb: '#ff0000', alpha: 100 }) + assert.deepEqual(splitAlpha('#ff000080'), { rgb: '#ff0000', alpha: 50 }) + assert.equal(joinAlpha('#ff0000', 100), '#ff0000') + assert.equal(joinAlpha('#ff0000', 50), '#ff000080') + assert.equal(joinAlpha('#ff0000', 0), '#ff000000') + assert.equal(typedColour('abc'), '#aabbcc') + assert.equal(typedColour(' #11223344 '), '#11223344') + assert.equal(typedColour('#12345'), null) +}) diff --git a/packages/i18n/locales/el/manager.json b/packages/i18n/locales/el/manager.json index 74ad7ee..c59a7e1 100644 --- a/packages/i18n/locales/el/manager.json +++ b/packages/i18n/locales/el/manager.json @@ -1527,16 +1527,19 @@ "column": "Το ένα κάτω από το άλλο", "parts": "Πόσα", "even": "Ίση μοιρασιά", - "shows": "Δείχνει", "nothing": "Τίποτα", - "aSlide": "Μια διαφάνεια από τις Διαφάνειες", "slide": "Διαφάνεια", "noSlides": "Δεν υπάρχουν ακόμα διαφάνειες", - "barHint": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για να αλλάξετε το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια).", + "barHint": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια). Τα widgets ενός τμήματος μπαίνουν το ένα κάτω από το άλλο.", "partTitle": "Τμήμα {{n}}", "line": "Η γραμμή ανάμεσα στα τμήματα {{a}} και {{b}}", "add": "Προσθήκη widget", - "replace": "Κάτι άλλο" + "barHintColumn": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια). Τα widgets ενός τμήματος μπαίνουν δίπλα-δίπλα.", + "aSlideInstead": "Μια διαφάνεια από τις Διαφάνειες (αντί για τα widgets)", + "removeSlide": "Αφαίρεση της διαφάνειας από αυτό το τμήμα", + "removeWidget": "Αφαίρεση αυτού του widget", + "before": "Μετακίνηση πριν", + "after": "Μετακίνηση μετά" } }, "tabs": { @@ -1673,21 +1676,10 @@ "kept": "Κρατήθηκε στις Διαφάνειες." }, "look": { - "headings": "Επικεφαλίδες", - "names": "Ονόματα προϊόντων", - "prices": "Τιμές", - "dots": "Τελείες", - "spacing": "Αποστάσεις", - "size": "Μέγεθος", - "colour": "Χρώμα", - "font": "Γραμματοσειρά", - "style": "Στυλ", - "align": "Στοίχιση", "sameFont": "Όπως τα ονόματα", "bold": "Έντονα", "italic": "Πλάγια", "underline": "Υπογράμμιση", - "dotStyle": "Γραμμή", "dotStyles": { "dotted": "Τελείες", "dashed": "Παύλες", @@ -1704,8 +1696,46 @@ "rounded": "Στρογγυλεμένο", "round": "Στρογγυλό" }, - "accent": "Σήματα και τελείες σελίδων", - "hint": "Τα ονόματα προϊόντων ορίζουν το μέγεθος, το χρώμα και τη γραμματοσειρά του πίνακα· οι επικεφαλίδες και οι τιμές τα ακολουθούν (στο χρώμα έμφασης) μέχρι να αλλάξετε τα δικά τους. Με στοίχιση δεξιά τα ονόματα τελειώνουν στο ίδιο σημείο, με ίσες τελείες πριν τις τιμές. Διάστιχο: π.χ. 1.3 (× το κείμενο)· απόσταση γραμμάτων: π.χ. 0.05 (ενός γράμματος)· κενό = αυτόματο." + "hint": "Κάθε πεδίο αλλάζει μόνο τον εαυτό του. Οι επικεφαλίδες και οι τιμές ξεκινούν με το μέγεθος και τη γραμματοσειρά των ονομάτων («Όπως τα ονόματα»). Το χρώμα των σημάτων χρωματίζει και τις τελείες σελίδας. Τα ονόματα με δεξιά στοίχιση τελειώνουν όλα στο ίδιο σημείο, με ίσες τελείες πριν από τις τιμές.", + "f": { + "heading": { + "size": "Μέγεθος επικεφαλίδων", + "colour": "Χρώμα επικεφαλίδων", + "font": "Γραμματοσειρά επικεφαλίδων", + "style": "Στυλ επικεφαλίδων", + "align": "Στοίχιση επικεφαλίδων" + }, + "item": { + "size": "Μέγεθος ονομάτων", + "colour": "Χρώμα ονομάτων", + "font": "Γραμματοσειρά ονομάτων", + "style": "Στυλ ονομάτων", + "align": "Στοίχιση ονομάτων" + }, + "price": { + "size": "Μέγεθος τιμών", + "colour": "Χρώμα τιμών", + "font": "Γραμματοσειρά τιμών", + "style": "Στυλ τιμών", + "align": "Στοίχιση τιμών" + }, + "dots": { + "size": "Μέγεθος τελειών", + "colour": "Χρώμα τελειών", + "line": "Γραμμή τελειών" + } + }, + "badgeColour": "Χρώμα σημάτων", + "badgeText": "Κείμενο σημάτων", + "badgeTextAuto": "Αυτόματο", + "reset": "Επαναφορά εμφάνισης", + "resetTitle": "Επαναφορά της εμφάνισης αυτού του μενού;", + "resetBody": "Κάθε μέγεθος, χρώμα, γραμματοσειρά, στυλ, στοίχιση και διάστιχο γυρίζει στην αρχή. Τα προϊόντα, η σειρά και τα ονόματά τους μένουν. Η «Αναίρεση αλλαγών» τα φέρνει πίσω μέχρι να αποθηκεύσετε." + }, + "colourPick": { + "custom": "Δικό σας χρώμα", + "code": "Κωδικός χρώματος", + "opacity": "Αδιαφάνεια" } }, "overview": { diff --git a/packages/i18n/locales/en/manager.json b/packages/i18n/locales/en/manager.json index 1d24607..4a86445 100644 --- a/packages/i18n/locales/en/manager.json +++ b/packages/i18n/locales/en/manager.json @@ -1527,16 +1527,19 @@ "column": "One over the other", "parts": "How many", "even": "Split evenly", - "shows": "Shows", "nothing": "Nothing", - "aSlide": "A slide from Slides", "slide": "Slide", "noSlides": "No slides in Slides yet", - "barHint": "Drag the lines between the parts to size them (or focus a line and use the arrow keys).", + "barHint": "Drag the lines between the parts to size them (or focus a line and use the arrow keys). Widgets in one part sit one over the other.", "partTitle": "Part {{n}}", "line": "The line between parts {{a}} and {{b}}", "add": "Add a widget", - "replace": "Put something else" + "barHintColumn": "Drag the lines between the parts to size them (or focus a line and use the arrow keys). Widgets in one part sit side by side.", + "aSlideInstead": "A slide from Slides (instead of the widgets)", + "removeSlide": "Take the slide out of this part", + "removeWidget": "Remove this widget", + "before": "Move before", + "after": "Move after" } }, "tabs": { @@ -1673,21 +1676,10 @@ "kept": "Kept in Slides." }, "look": { - "headings": "Headings", - "names": "Product names", - "prices": "Prices", - "dots": "Dots", - "spacing": "Spacing", - "size": "Size", - "colour": "Colour", - "font": "Font", - "style": "Style", - "align": "Alignment", "sameFont": "As the names", "bold": "Bold", "italic": "Italic", "underline": "Underline", - "dotStyle": "Line", "dotStyles": { "dotted": "Dots", "dashed": "Dashes", @@ -1704,8 +1696,46 @@ "rounded": "Rounded", "round": "Round" }, - "accent": "Badges and page dots", - "hint": "Product names set the board's text size, colour and font; headings and prices follow them (in the accent colour) until you change theirs. Names aligned right all end at the same point, with equal dots before the prices. Line spacing: e.g. 1.3 (× the text); letter spacing: e.g. 0.05 (of a letter); empty = auto." + "hint": "Each field changes only itself. Headings and prices start in the names' size and font (\"As the names\"). The badges' colour also colours the page dots. Names aligned right all end at the same point, with equal dots before the prices.", + "f": { + "heading": { + "size": "Headings size", + "colour": "Headings colour", + "font": "Headings font", + "style": "Headings style", + "align": "Headings alignment" + }, + "item": { + "size": "Names size", + "colour": "Names colour", + "font": "Names font", + "style": "Names style", + "align": "Names alignment" + }, + "price": { + "size": "Prices size", + "colour": "Prices colour", + "font": "Prices font", + "style": "Prices style", + "align": "Prices alignment" + }, + "dots": { + "size": "Dots size", + "colour": "Dots colour", + "line": "Dots line" + } + }, + "badgeColour": "Badges colour", + "badgeText": "Badges text", + "badgeTextAuto": "Automatic", + "reset": "Reset the look", + "resetTitle": "Reset the look of this menu?", + "resetBody": "Every size, colour, font, style, alignment and spacing goes back to the start. The products, their order and names stay. \"Undo changes\" brings it back until you save." + }, + "colourPick": { + "custom": "Your own colour", + "code": "Colour code", + "opacity": "Opacity" } }, "overview": { diff --git a/packages/signage/src/Slides.jsx b/packages/signage/src/Slides.jsx index ad2e85c..9f78203 100644 --- a/packages/signage/src/Slides.jsx +++ b/packages/signage/src/Slides.jsx @@ -5,7 +5,7 @@ import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react' import { QRCodeSVG } from 'qrcode.react' import { useFormat, useTranslation } from '@xenia/i18n' -import { fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic' +import { cellWidgets, fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic' /** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */ export function Background({ bg, media }) { @@ -64,7 +64,7 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed {/* the list: the whole width, or narrower and placed left / centre / right (2026-11-21) */}
- {c.title &&

{c.title}

}
@@ -100,7 +100,6 @@ export function MenuGroups({ c, groups }) { const { t } = useTranslation('terminal') const { formatMoney } = useFormat() const look = menuLook(c) - const accent = c.accent_colour || '#f59e0b' const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em` const nameFills = look.itemAlign !== 'left' return ( @@ -123,7 +122,7 @@ export function MenuGroups({ c, groups }) { {it.name} {it.badge && ( - {t(`signage.badges.${it.badge}`)} )} {!it.available && {t('signage.soldOut')}} @@ -327,7 +326,7 @@ function MenuWidget({ board: b, menu, now }) { return (
- {b.title &&
{b.title}
} + {b.title &&
{b.title}
}
@@ -337,25 +336,32 @@ function MenuWidget({ board: b, menu, now }) { /** * A stack (2026-11-21): parts side by side ("row") or one over the other ("column"), each its share - * of the stack, showing a widget (filling the part) or a whole library slide. + * of the stack, showing widgets (each filling its place; several share the part, one over the other + * in a side-by-side stack and side by side in the other: owner review 4) or a whole library slide. */ function Stack({ w, path, ctx }) { const cells = w.cells || [] const Embed = ctx.embed + const across = w.direction === 'column' ? 'row' : 'column' return (
{cells.map((c, j) => { const cp = `${path}.${j}` - const slide = c.slide_id ? ctx.extras[cp]?.slide : null - const body = c.widget ? widgetBody(c.widget, ctx, true, cp) : null - const align = c.widget?.align && c.widget.align !== 'auto' ? c.widget.align : 'center' + const ws = cellWidgets(c) + const slide = !ws.length && c.slide_id ? ctx.extras[cp]?.slide : null return ( -
- {body && ( -
{body}
- )} +
+ {ws.map((cw, k) => { + const align = cw.align && cw.align !== 'auto' ? cw.align : 'center' + return ( +
+ {widgetBody(cw, ctx, true, `${cp}.${k}`)} +
+ ) + })} {slide && Embed && }
) diff --git a/packages/signage/src/logic.js b/packages/signage/src/logic.js index 14729ce..a1f0ed4 100644 --- a/packages/signage/src/logic.js +++ b/packages/signage/src/logic.js @@ -321,7 +321,8 @@ const DOTS = { dotted: 'dotted', dashed: 'dashed', solid: 'solid' } * board's text size): headings, names and prices each their own size, colour, font, bold / italic / * underline and alignment (empty: the board's text size and font, the text colour for names and the * accent colour for headings and prices); the dots between name and price; line and letter spacing - * (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape. + * (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape; + * the badges' colours (2026-11-21: their text the venue's, or white / black to read on them). */ export function menuLook(c = {}) { const base = c.text_size || 100 @@ -345,6 +346,9 @@ export function menuLook(c = {}) { dots: d.style === 'none' ? { borderBottom: 'none' } : { borderBottom: `${+(0.08 * (d.size || 100) / 100).toFixed(3)}em ${DOTS[d.style] || 'dotted'} ${d.colour || 'currentColor'}`, opacity: d.colour ? 1 : 0.35 }, + // badges: the accent (also the page dots), their text the venue's or one that reads on it + badge: { background: accent, color: c.badge_text_colour || readableOn(accent) }, + title: c.heading_style?.colour || accent, lineHeight: c.line_height || 1.25, letterSpacing: c.letter_spacing != null ? `${c.letter_spacing}em` : 'normal', photo: { size: `${+(2.2 * (c.photo_size || 100) / 100).toFixed(3)}em`, radius: RADIUS[c.photo_shape] || RADIUS.rounded }, @@ -354,6 +358,28 @@ export function menuLook(c = {}) { } } +/** A stack part's widgets (a part stored before owner review 4 has one `widget`). */ +export function cellWidgets(c) { + return c?.widgets?.length ? c.widgets : c?.widget ? [c.widget] : [] +} + +/** + * A text colour that reads on `hex` (#rgb, #rrggbb or #rrggbbaa; the alpha is ignored): white on a + * dark colour, near-black on a light one (a badge's text when the venue chose none, 2026-11-21). + */ +export function readableOn(hex) { + let h = String(hex || '').replace('#', '') + if (h.length === 3 || h.length === 4) h = h.slice(0, 3).split('').map(x => x + x).join('') + if (!/^[0-9a-f]{6}/i.test(h)) return '#111111' + const [r, g, b] = [0, 2, 4].map(i => { + const v = parseInt(h.slice(i, i + 2), 16) / 255 + return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4 + }) + const lum = 0.2126 * r + 0.7152 * g + 0.0722 * b + // the text with the better contrast (WCAG): white beats near-black below ~0.18 + return lum < 0.18 ? '#ffffff' : '#111111' +} + /** A page's widest price, in characters: the price column's width, so names and dots line up. */ export function priceChars(groups, format) { let n = 0 diff --git a/packages/signage/tests/logic.test.mjs b/packages/signage/tests/logic.test.mjs index 311a941..ca62e70 100644 --- a/packages/signage/tests/logic.test.mjs +++ b/packages/signage/tests/logic.test.mjs @@ -192,3 +192,17 @@ test("a menu's look part by part: sizes against the board's text, colours fall b assert.deepEqual(menuLook({ dot_style: { style: 'none' } }).dots, { borderBottom: 'none' }) assert.equal(priceChars([{ items: [{ price: 4.5 }, { price: 12 }, { price: null }] }], p => `€${p.toFixed(2)}`), 6) }) + +test('owner review 4: a part\'s widgets (one stored as `widget` too), badges that read', async () => { + const { cellWidgets, menuLook, readableOn } = await import('../src/logic.js') + assert.deepEqual(cellWidgets({ widgets: [{ kind: 'clock' }, { kind: 'date' }] }).map(w => w.kind), ['clock', 'date']) + assert.deepEqual(cellWidgets({ widget: { kind: 'qr' } }).map(w => w.kind), ['qr']) + assert.deepEqual(cellWidgets({ slide_id: 3 }), []) + assert.equal(readableOn('#111827'), '#ffffff') + assert.equal(readableOn('#1e3a8acc'), '#ffffff') + assert.equal(readableOn('#f59e0b'), '#111111') + assert.equal(readableOn('#fff'), '#111111') + assert.deepEqual(menuLook({ accent_colour: '#1e3a8a' }).badge, { background: '#1e3a8a', color: '#ffffff' }) + assert.deepEqual(menuLook({ accent_colour: '#1e3a8a', badge_text_colour: '#fde68a' }).badge, { background: '#1e3a8a', color: '#fde68a' }) + assert.equal(menuLook({ accent_colour: '#123456', heading_style: { colour: '#ff0000' } }).title, '#ff0000') +}) diff --git a/packages/ui/src/components.css b/packages/ui/src/components.css index 19e4b11..f311236 100644 --- a/packages/ui/src/components.css +++ b/packages/ui/src/components.css @@ -465,6 +465,15 @@ box-shadow: var(--x-shadow-popover); outline: none; animation: x-fade-in var(--x-duration-fast) var(--x-ease); } +/* ── Popover (2026-11-21): a small panel under a button, kept inside the window ── */ +.x-popover { + position: fixed; z-index: var(--x-z-popover); box-sizing: border-box; + max-width: calc(100vw - 16px); overflow: auto; + background: var(--x-surface); color: var(--x-ink); color-scheme: var(--x-color-scheme); + border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-card); + box-shadow: var(--x-shadow-popover); outline: none; + animation: x-fade-in var(--x-duration-fast) var(--x-ease); +} .x-dropdown__search { padding: var(--x-space-2); border-bottom: var(--x-border-width) solid var(--x-line); } .x-dropdown__list { list-style: none; margin: 0; padding: var(--x-space-1); overflow-y: auto; min-height: 0; } .x-dropdown__option { diff --git a/packages/ui/src/components/Page.jsx b/packages/ui/src/components/Page.jsx index 810476b..52e9353 100644 --- a/packages/ui/src/components/Page.jsx +++ b/packages/ui/src/components/Page.jsx @@ -2,7 +2,7 @@ import { cx } from '../internal/cx.js' /** * The page rule (2026-11-20): every app page's root. It scrolls on its own, fills the area up to - * a 16:9 screen's width (--x-page-max) and is centred beyond it (ultrawides), with the same + * 2200 px (--x-page-max: a 1080p screen is filled; the window's height never narrows it) and is centred beyond it (ultrawides), with the same * padding and gaps everywhere. Never put padding, max-width or overflow on a page's root yourself. * * diff --git a/packages/ui/src/components/Popover.jsx b/packages/ui/src/components/Popover.jsx new file mode 100644 index 0000000..89c4e62 --- /dev/null +++ b/packages/ui/src/components/Popover.jsx @@ -0,0 +1,65 @@ +import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react' +import { cx } from '../internal/cx.js' +import { Portal } from '../internal/Portal.jsx' + +const GAP = 6 +const MARGIN = 8 + +/** + * A small floating panel under a button (2026-11-21): a colour picker, an "Add…" menu. Drawn over + * everything (portal, fixed), like the Dropdown's list: below its button, above when there's no + * room, and always kept inside the window, so it never makes a page or a section scroll sideways. + * Closes on a click outside (the button excluded) and on Escape. + * + * const btn = useRef(null) + * + * setOpen(false)} role="menu">… + */ +export function Popover({ open, anchor, onClose, className, style, children, role = 'dialog', ...rest }) { + const panel = useRef(null) + const [pos, setPos] = useState(null) + + const place = useCallback(() => { + const b = anchor?.current?.getBoundingClientRect() + const p = panel.current?.getBoundingClientRect() + if (!b || !p) return + const below = window.innerHeight - b.bottom - GAP - MARGIN + const above = b.top - GAP - MARGIN + const up = p.height > below && above > below + const left = Math.min(Math.max(MARGIN, b.left), Math.max(MARGIN, window.innerWidth - MARGIN - p.width)) + const top = up ? Math.max(MARGIN, b.top - GAP - p.height) : b.bottom + GAP + setPos({ left, top, maxHeight: Math.max(160, up ? above : below) }) + }, [anchor]) + + useLayoutEffect(() => { if (open) place(); else setPos(null) }, [open, place]) + + useEffect(() => { + if (!open) return undefined + const away = e => { + if (panel.current?.contains(e.target) || anchor?.current?.contains(e.target)) return + onClose?.() + } + const esc = e => { if (e.key === 'Escape') { e.stopPropagation(); onClose?.() } } + const onScroll = e => { if (!panel.current?.contains(e.target)) place() } + document.addEventListener('pointerdown', away) + window.addEventListener('keydown', esc) + window.addEventListener('resize', place) + window.addEventListener('scroll', onScroll, true) + return () => { + document.removeEventListener('pointerdown', away) + window.removeEventListener('keydown', esc) + window.removeEventListener('resize', place) + window.removeEventListener('scroll', onScroll, true) + } + }, [open, anchor, onClose, place]) + + if (!open) return null + return ( + +
+ {children} +
+
+ ) +} diff --git a/packages/ui/src/index.js b/packages/ui/src/index.js index dd54599..27f7eea 100644 --- a/packages/ui/src/index.js +++ b/packages/ui/src/index.js @@ -22,6 +22,7 @@ export { EmptyState } from './components/EmptyState.jsx' export { Spinner } from './components/Spinner.jsx' export { Field, Input, Textarea, Select } from './components/Field.jsx' export { Dropdown } from './components/Dropdown.jsx' +export { Popover } from './components/Popover.jsx' export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx' export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx' export { Switch } from './components/Switch.jsx' diff --git a/packages/ui/src/tokens.css b/packages/ui/src/tokens.css index 93a6041..8fe6d3a 100644 --- a/packages/ui/src/tokens.css +++ b/packages/ui/src/tokens.css @@ -588,9 +588,10 @@ --x-pad-card: 20px; --x-pad-card-y: 14px; /* a card's header row and list rows */ - /* Pages (the page rule, 2026-11-20): a page fills its area up to a 16:9 screen's width and - is centred beyond it, so ultrawides keep a 16:9 page instead of stretched content. */ - --x-page-max: max(1280px, calc(100vh * 16 / 9)); + /* Pages (the page rule, 2026-11-20; owner 2026-11-21): a page fills its area up to 2200 px + (a 1080p screen is filled) and is centred beyond it, so ultrawides don't stretch the content. + A fixed width: a short window never makes the page narrower. */ + --x-page-max: 2200px; --x-page-pad: 24px; --x-page-gap: 20px; --x-page-form-max: 880px; /* forms and settings that read badly when stretched */ diff --git a/tests/e2e/manager_layout.mjs b/tests/e2e/manager_layout.mjs index 7a3d006..619e089 100644 --- a/tests/e2e/manager_layout.mjs +++ b/tests/e2e/manager_layout.mjs @@ -1,5 +1,5 @@ // The page rule (2026-11-20): every manager page is a that scrolls on its own, fills a -// 1080p screen and stays at 16:9 width, centred, on an ultrawide. For each page, at 1920×1080 +// 1080p screen and stays at 2200 px (never narrowed by a short window), centred, on an ultrawide. For each page, at 1920×1080 // and 3440×1440: the page body exists, fills the content area (1080p) or is capped and centred // (ultrawide), and the page scrolls when its content is taller than the screen. Screenshots of a // few key screens (and the open dropdowns / the day summary) go to out/manager-layout/. @@ -37,7 +37,7 @@ const vite = spawn('npx', ['vite', '--port', '5191', '--strictPort'], { stdio: ['ignore', log, log], env: { ...process.env, XENIA_BACKEND: backend.url }, }) const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {}) -const r = reporter('manager layout (the page rule): fills 1080p, 16:9 and centred on ultrawides, scrolls') +const r = reporter('manager layout (the page rule): fills 1080p, 2200 px and centred on ultrawides, scrolls') const name = p => p.replace(/[/?=]/g, '-') try { await waitHttp(APP) @@ -71,7 +71,7 @@ try { const a = { left: s.left, right: s.left + scroll.clientWidth, width: scroll.clientWidth } // a form page (settings) is centred at its own width const form = body.classList.contains('x-page__body--form') - return { form, left: b.left - a.left, right: a.right - b.right, width: b.width, area: a.width, cap: Math.max(1280, innerHeight * 16 / 9), + return { form, left: b.left - a.left, right: a.right - b.right, width: b.width, area: a.width, cap: 2200, scrolls: scroll.scrollHeight <= scroll.clientHeight + 1 || getComputedStyle(scroll).overflowY === 'auto' } }) if (!m) { bad.push(`${p}: no `); continue } @@ -80,7 +80,7 @@ try { if (!centred || !fills || !m.scrolls) bad.push(`${p}: ${JSON.stringify(m)}`) if (SHOTS.includes(p)) await page.screenshot({ path: path.join(DIR, `${name(p)}-${screen.id}.png`) }) } - r.check(`${screen.id}: every page fills its area up to 16:9, centred, and scrolls`, bad.length === 0, bad.join('\n')) + r.check(`${screen.id}: every page fills its area up to 2200 px, centred, and scrolls`, bad.length === 0, bad.join('\n')) // Products (2026-11-21): the page doesn't scroll, its two panes do, each on its own await page.goto(`${APP}/management/products`) diff --git a/tests/e2e/signage.mjs b/tests/e2e/signage.mjs index 7c3040c..b2b6375 100644 --- a/tests/e2e/signage.mjs +++ b/tests/e2e/signage.mjs @@ -318,8 +318,8 @@ try { await waitFor(async () => (await textCard.getByTestId('signage-widget-position').textContent()).includes('Custom'), 4000, 200) === true) await mgr.getByTestId('signage-widget-add-hstack').click() const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]') - await stackCard.getByTestId('signage-stack-shows').first().click() - await mgr.getByRole('option', { name: 'Clock', exact: true }).click() + await stackCard.getByTestId('signage-stack-cell-editor').first().getByTestId('signage-stack-add').click() + await mgr.getByTestId('signage-stack-add-clock').click() // the parts sized by dragging the line between them on the bar (owner review 3) const bar = await stackCard.getByTestId('signage-stack-bar').first().boundingBox() const ln = await stackCard.getByTestId('signage-stack-line').first().boundingBox() @@ -338,6 +338,17 @@ try { await mgr.getByTestId('signage-stack-add-date').click() r.check('2026-11-21 (3): "Add a widget" puts a date in the second part', await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1).getByTestId('signage-w-date').count()) === 1, 6000, 300) === true) + // owner review 4: a second widget in the same part, then one removed + await stackCard.getByTestId('signage-stack-cell-editor').nth(1).getByTestId('signage-stack-add').click() + await mgr.getByTestId('signage-stack-add-text').click() + await stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="text"]').getByTestId('signage-widget-own-text').fill('Two in one') + const part2 = () => mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1) + r.check('2026-11-21 (4): a part holds two widgets (a date and a text), one over the other', + await waitFor(async () => (await part2().getByTestId('signage-stack-place').count()) === 2 && (await part2().getByTestId('signage-w-text').count()) === 1 + && (await part2().getByTestId('signage-w-date').count()) === 1, 6000, 300) === true) + await stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="date"]').getByTestId('signage-stack-part-remove').click() + r.check('2026-11-21 (4): …and one of them removed', + await waitFor(async () => (await part2().getByTestId('signage-stack-place').count()) === 1 && (await part2().getByTestId('signage-w-date').count()) === 0, 6000, 300) === true) // Delete removes the picked widget (picked on its card) await stackCard.locator('span', { hasText: 'Horizontal stack' }).first().click() await mgr.keyboard.press('Delete') @@ -349,6 +360,29 @@ try { await mgr.getByTestId('signage-item-name-input').fill('Signature dish') await mgr.getByTestId('signage-item-name-input').press('Enter') await mgr.getByTestId('signage-look-item_style-align-right').click() + // owner review 4: each look field changes only itself; the colour panel stays inside the window + r.check('2026-11-21 (4): names align left or right only', (await mgr.getByTestId('signage-look-item_style-align-center').count()) === 0) + const setRange = (loc, v) => loc.evaluate((el, x) => { + Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(el, String(x)) + el.dispatchEvent(new Event('input', { bubbles: true })) + }, v) + const headSize = async () => mgr.getByTestId('signage-look-heading_style-size').inputValue() + const before = await headSize() + await setRange(mgr.getByTestId('signage-look-item_style-size'), 180) + const headColour = async () => (await mgr.getByTestId('signage-look-heading_style-colour-open').textContent()).trim() + const colourBefore = await headColour() + await mgr.getByTestId('signage-accent-open').click() + const panel = await mgr.getByTestId('signage-accent-panel').boundingBox() + const vw = await mgr.evaluate(() => innerWidth) + r.check('2026-11-21 (4): the colour panel opens inside the window (12 ready colours)', + panel && panel.x >= 0 && panel.x + panel.width <= vw && (await mgr.getByTestId('signage-accent-preset').count()) === 12, JSON.stringify(panel)) + await mgr.getByTestId('signage-accent-preset').nth(10).click() + r.check('2026-11-21 (4): the names size and the badges colour leave the headings as they were', + (await headSize()) === before && (await headColour()) === colourBefore, `${before} → ${await headSize()}, ${colourBefore} → ${await headColour()}`) + await mgr.getByTestId('signage-look-dots-colour-open').click() + await setRange(mgr.getByTestId('signage-look-dots-colour-opacity'), 50) + r.check('2026-11-21 (4): a see-through colour (#rrggbbaa)', /^#[0-9a-f]{8}$/.test((await mgr.getByTestId('signage-look-dots-colour-open').textContent()).trim())) + await mgr.keyboard.press('Escape') r.check('2026-11-21 (3): a product named for this board only shows on the preview, the catalogue name under it in the list', await waitFor(async () => (await mgr.getByTestId('signage-preview').getByText('Signature dish').count()) > 0 && (await mgr.getByTestId('signage-menu-board').getByText(/Catalogue:/).count()) > 0, 6000, 300) === true)