From e8c8ec825e443497167ac1162c94fea4b0761875 Mon Sep 17 00:00:00 2001 From: bonamin Date: Sat, 21 Nov 2026 10:51:03 +0200 Subject: [PATCH] feat(signage): menu look part by part, board-only names, stack bar, Delete key (owner review 3) - Menus (slides and widgets): headings / names / prices each with size, colour, font, bold / italic / underline and alignment; dots size, colour and style; line and letter spacing; photo size and shape (menuLook) - Names aligned right end together, prices in a page-wide column - Names for one board only (names, category_names) with a pencil on the board's list; the catalogue name stays for the waiters - Fixed: menu lists inherited the page's fixed line height (big text overlapped); a menu slide's list grew past the screen (no 2nd column) - Stacks: parts sized by dragging the lines on the bar; "Add a widget" - Delete / Backspace removes the picked widget Co-Authored-By: Claude Opus 5.5 --- local_backend/routers/signage.py | 45 ++++++ local_backend/services/signage_menu.py | 16 ++- local_backend/tests/test_signage_stacks.py | 22 +++ .../src/pages/signage/MenuEditor.jsx | 59 ++++++-- .../src/pages/signage/MenuLook.jsx | 124 ++++++++++++++++ .../src/pages/signage/SlidePreview.jsx | 2 +- .../src/pages/signage/WidgetCanvas.jsx | 8 +- .../src/pages/signage/WidgetsEditor.jsx | 136 +++++++++++++++--- .../src/pages/signage/signageLogic.js | 3 + .../src/pages/signage/useSlideDraft.js | 6 +- packages/i18n/locales/el/manager.json | 50 ++++++- packages/i18n/locales/en/manager.json | 50 ++++++- packages/signage/src/Slides.jsx | 94 +++++++----- packages/signage/src/logic.js | 54 ++++++- packages/signage/tests/logic.test.mjs | 24 ++++ tests/e2e/signage.mjs | 30 +++- 16 files changed, 642 insertions(+), 81 deletions(-) create mode 100644 manager_dashboard/src/pages/signage/MenuLook.jsx diff --git a/local_backend/routers/signage.py b/local_backend/routers/signage.py index 16f9061..8b72eca 100644 --- a/local_backend/routers/signage.py +++ b/local_backend/routers/signage.py @@ -76,6 +76,34 @@ Position = Literal["top-left", "top-center", "top-right", "bottom-left", "bottom Badge = Literal["new", "chef", "offer", "popular", "spicy", "vegetarian", "vegan"] +Align = Literal["left", "center", "right"] + + +class TextStyle(_Strict): + """How a menu's headings, product names or prices look (owner review 3, 2026-11-21). Empty + values follow the board: its text size and font, the text colour (names) or the accent colour + (headings, prices).""" + size: Optional[int] = Field(default=None, ge=50, le=300) # % like the board's text size + colour: Optional[str] = Field(default=None, pattern=HEX) + font: Optional[Font] = None + bold: bool = True + italic: bool = False + underline: bool = False + align: Optional[Align] = None # None: names left, prices right, headings as the list + + +class DotStyle(_Strict): + """The line between a product's name and its price.""" + size: int = Field(default=100, ge=50, le=300) + colour: Optional[str] = Field(default=None, pattern=HEX) # None: the text colour, faint + style: Literal["dotted", "dashed", "solid", "none"] = "dotted" + + +def _names(v: dict) -> dict: + if any(not k.isdigit() for k in v): + raise ValueError("names are keyed by id") + out = {k: " ".join(str(x).split())[:80] for k, x in v.items()} + return {k: x for k, x in out.items() if x} class MenuList(_Strict): @@ -107,6 +135,23 @@ class MenuList(_Strict): text_colour: str = Field(default="#ffffff", pattern=HEX) accent_colour: str = Field(default="#f59e0b", pattern=HEX) # prices, headings, badges text_size: int = Field(default=100, ge=50, le=250) + # the look of each part (owner review 3, 2026-11-21) + heading_style: TextStyle = Field(default_factory=TextStyle) + item_style: TextStyle = Field(default_factory=TextStyle) + price_style: TextStyle = Field(default_factory=TextStyle) + dot_style: DotStyle = Field(default_factory=DotStyle) + line_height: Optional[float] = Field(default=None, ge=0.8, le=3) # × the text; None = auto + letter_spacing: Optional[float] = Field(default=None, ge=-0.1, le=0.5) # em; None = auto + photo_size: int = Field(default=100, ge=50, le=250) + photo_shape: Literal["square", "rounded", "round"] = "rounded" + # this board's own names (the menu's "official" names; the catalogue keeps its own) + names: Dict[str, str] = Field(default_factory=dict) # product id → name + category_names: Dict[str, str] = Field(default_factory=dict) # category id → name + + @field_validator("names", "category_names") + @classmethod + def _own_names(cls, v): + return _names(v) @field_validator("sales_point") @classmethod diff --git a/local_backend/services/signage_menu.py b/local_backend/services/signage_menu.py index 917eb75..99a86b9 100644 --- a/local_backend/services/signage_menu.py +++ b/local_backend/services/signage_menu.py @@ -87,9 +87,18 @@ def resolve(db, content: dict, now=None, keep_hidden: bool = False) -> dict: def text(row, base, field): return menu_languages.texts(base, menu_languages.of(row), field).get(lang, base) if lang else base + own = content.get("names") or {} # this board's own names (2026-11-21) + own_cats = content.get("category_names") or {} + + def named(row, base, mine): + """(the name shown, the catalogue's name when the board has its own)""" + shown = text(row, base, "name") + return (mine, shown) if mine else (shown, None) + def item(p): image = media_store.image_of(p.media) if content.get("show_photos") else None - return {"id": p.id, "name": text(p, p.digital_name or p.name, "name"), + name, original = named(p, p.digital_name or p.name, own.get(str(p.id))) + return {"id": p.id, "name": name, **({"original": original} if original and keep_hidden else {}), "description": text(p, p.digital_description or p.description or None, "description") if content.get("show_descriptions") else None, "price": round(prices[p.id], 2) if p.id in prices else None, "available": bool(p.is_available), "image": image["card"] if image else None, @@ -99,7 +108,10 @@ def resolve(db, content: dict, now=None, keep_hidden: bool = False) -> dict: groups: dict = {} for p in products: groups.setdefault(p.primary_category_id, []).append(p) - out = [{"category": {"id": cid, "name": text(by_id[cid], by_id[cid].name, "name")} if cid in by_id else None, + def cat(cid): + name, original = named(by_id[cid], by_id[cid].name, own_cats.get(str(cid))) + return {"id": cid, "name": name, **({"original": original} if original and keep_hidden else {})} + out = [{"category": cat(cid) if cid in by_id else None, "items": [item(p) for p in sorted(ps, key=prod_key)]} for cid, ps in sorted(groups.items(), key=lambda kv: cat_key(kv[0]))] else: diff --git a/local_backend/tests/test_signage_stacks.py b/local_backend/tests/test_signage_stacks.py index 46678a4..07703c0 100644 --- a/local_backend/tests/test_signage_stacks.py +++ b/local_backend/tests/test_signage_stacks.py @@ -95,3 +95,25 @@ def test_the_editor_previews_any_slide(client, owner_h, menu): m = r.json()["menu"] assert "Beer" in [i["name"] for g in m["groups"] for i in g["items"] if i.get("hidden")] and m["count"] == 3 assert err(client.post("/api/signage/preview/slide", headers=owner_h, json={"kind": "text", "content": {"widgets": [stack()]}})) == "signage.content_invalid" + + +def test_a_board_has_its_own_names_and_the_look_of_each_part(client, owner_h, menu): + """Owner review 3 (2026-11-21): names only for this board (the catalogue keeps its own), the look + of headings, names, prices and the dots, spacing, photos.""" + content = {"category_ids": [menu["cats"]["drinks"]], "names": {str(menu["beer"].id): " Craft beer "}, "category_names": {str(menu["cats"]["drinks"]): "Bar"}, + "heading_style": {"size": 180, "colour": "#ff0000", "font": "serif", "align": "center", "italic": True}, + "price_style": {"align": "right", "bold": False}, "dot_style": {"style": "dashed", "size": 150}, + "line_height": 1.4, "letter_spacing": 0.05, "photo_size": 150, "photo_shape": "round"} + r = client.post("/api/signage/preview/slide", headers=owner_h, json={"kind": "menu", "content": content}) + assert r.status_code == 200, r.text + g = r.json()["menu"]["groups"][0] + assert g["category"] == {"id": menu["cats"]["drinks"], "name": "Bar", "original": "Drinks"} + assert g["items"][0]["name"] == "Craft beer" and g["items"][0]["original"] == "Beer" + p = playlist(client, owner_h) + s = slide(client, owner_h, p["id"], "menu", content=content) + c = s["content"] + assert c["names"] == {str(menu["beer"].id): "Craft beer"} and c["heading_style"]["italic"] and c["item_style"]["bold"] + assert c["price_style"] == {"size": None, "colour": None, "font": None, "bold": False, "italic": False, "underline": False, "align": "right"} + url = f"/api/signage/playlists/{p['id']}/slides" + for bad in ({"names": {"x": "a"}}, {"heading_style": {"size": 20}}, {"dot_style": {"style": "wavy"}}, {"line_height": 9}, {"photo_shape": "star"}): + assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": bad})) == "signage.content_invalid", bad diff --git a/manager_dashboard/src/pages/signage/MenuEditor.jsx b/manager_dashboard/src/pages/signage/MenuEditor.jsx index 329d7fe..d5de871 100644 --- a/manager_dashboard/src/pages/signage/MenuEditor.jsx +++ b/manager_dashboard/src/pages/signage/MenuEditor.jsx @@ -10,15 +10,18 @@ // crossed eye (a green eye on the ones shown): a click shows / hides it; seconds per page explained; // the text's look on one row. `board` mode: the same editor for a menu widget's list (no background, // widgets, width or place; its own products per page). +// 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). import { useEffect, useMemo, useState } from 'react' -import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, Eye, EyeOff, X } from 'lucide-react' +import { AlignCenter, AlignLeft, AlignRight, 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 client from '../../api/client' import { BADGES, boardOrder, moveGroup, moveItem, toggled } from './signageLogic' -import { BackgroundField, ColourField, Range, Section } from './SignageFields' -import { TextLook } from './SlideEditor' +import MenuLook from './MenuLook' +import { BackgroundField, Range, Section } from './SignageFields' import WidgetsEditor from './WidgetsEditor' let catalogue = null // categories and products, read once for every menu editor on the page @@ -52,6 +55,13 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [ const badges = c.badges || {} 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 + const rename = (key, id, name) => { + const next = { ...(c[key] || {}) } + if (name && name.trim()) next[String(id)] = name.trim() + else delete next[String(id)] + setC({ [key]: next }) + } return (
@@ -120,7 +130,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
{g.category && (
- {g.category.name} + rename('category_names', g.category.id, v)} + className="text-label font-semibold text-ink" testid="signage-category-name" /> reorder(moveGroup(groups, gi, -1))} data-testid="signage-group-up"> reorder(moveGroup(groups, gi, 1))}>
@@ -131,7 +142,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [ return (
  • - {it.name} + rename('names', it.id, v)} testid="signage-item-name" + className={`text-label ${off ? 'text-ink-3 opacity-70' : it.available ? 'text-ink' : 'text-ink-3 line-through'}`} /> {off && {t('signage.menu.hiddenTag')}} {it.price != null && {formatMoney(it.price)}} setEdit(e.target.value)} onBlur={done} + onKeyDown={e => { if (e.key === 'Enter') done(); if (e.key === 'Escape') setEdit(null) }} /> + + ) + } + return ( + + + {name} + {original && {t('signage.menu.catalogueNameIs', { name: original })}} + + setEdit(name)} data-testid={`${testid}-edit`} + className="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 shrink-0"> + {original && ( + onSave('')} data-testid={`${testid}-reset`} + className="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 shrink-0"> + )} + + ) +} diff --git a/manager_dashboard/src/pages/signage/MenuLook.jsx b/manager_dashboard/src/pages/signage/MenuLook.jsx new file mode 100644 index 0000000..cefaa14 --- /dev/null +++ b/manager_dashboard/src/pages/signage/MenuLook.jsx @@ -0,0 +1,124 @@ +// A menu's look, part by part (owner review 3, 2026-11-21), for menu slides and menu widgets alike: +// one row each for the headings, the product names and the prices (size, colour, font, bold / +// italic / underline, alignment), the dots between name and price (size, colour, style), and the +// spacing (line and letter spacing: empty = auto) with the photos' size and shape and the accent +// (badges, page dots). The names' row sets the board's own text size, colour and font; headings and +// prices follow them (the accent colour) until given their own. The player draws it (menuLook). +import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-react' +import { useTranslation } from '@xenia/i18n' +import { Dropdown, Field, Input, Segmented } from '@xenia/ui' +import { FONT_KEYS, MENU_COLOURS } from './signageLogic' +import { ColourField, Range, Section } from './SignageFields' + +const ROW = 'grid gap-3 items-end grid-cols-2 lg:grid-cols-[7rem_repeat(5,minmax(0,1fr))]' + +export default function MenuLook({ c, setC }) { + const { t } = useTranslation('manager') + const base = c.text_size || 100 + const accent = c.accent_colour || MENU_COLOURS.accent + const style = key => c[key] || {} + const setStyle = (key, patch) => setC({ [key]: { ...style(key), ...patch } }) + const fontOptions = inherit => [...(inherit ? [{ value: '', label: t('signage.look.sameFont') }] : []), ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))] + const num = (v, lo, hi) => { + const n = Number(String(v).replace(',', '.')) + return v === '' || Number.isNaN(n) ? null : Math.min(hi, Math.max(lo, n)) + } + + /** A row for headings / names / prices: size, colour, font, style, alignment. */ + const partRow = (key, label, { size, colour, font, onSize, onColour, onFont, inherit, align }) => { + const s = style(key) + return ( +
    + {label} + + + + + + + setStyle(key, patch)} testid={`signage-look-${key}`} /> + + + setStyle(key, { align: v })} fill data-testid={`signage-look-${key}-align`} + options={[['left', AlignLeft], ['center', AlignCenter], ['right', AlignRight]].map(([v, Icon]) => ( + { value: v, icon: +
    + ) + } + + const d = style('dot_style') + return ( +
    +
    + {partRow('heading_style', t('signage.look.headings'), { + size: style('heading_style').size || base, onSize: v => setStyle('heading_style', { size: v }), + colour: style('heading_style').colour || accent, onColour: v => setStyle('heading_style', { colour: v }), + font: style('heading_style').font || '', onFont: v => setStyle('heading_style', { font: v || null }), inherit: true, + align: c.board_align || 'left', + })} + {partRow('item_style', t('signage.look.names'), { + size: base, onSize: v => setC({ text_size: v }), + colour: c.text_colour || MENU_COLOURS.text, onColour: v => setC({ text_colour: v }), + font: c.font || 'sans', onFont: v => setC({ font: v }), inherit: false, align: 'left', + })} + {partRow('price_style', t('signage.look.prices'), { + size: style('price_style').size || base, onSize: v => setStyle('price_style', { size: v }), + colour: style('price_style').colour || accent, onColour: v => setStyle('price_style', { colour: v }), + font: style('price_style').font || '', onFont: v => setStyle('price_style', { font: v || null }), inherit: true, align: 'right', + })} +
    + {t('signage.look.dots')} + setStyle('dot_style', { size: v })} testid="signage-look-dots-size" /> + setStyle('dot_style', { colour: v })} testid="signage-look-dots-colour" /> + + 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}`) }))} /> + +
    +
    + {t('signage.look.spacing')} + + 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}`) }))} /> + + : <>} + setC({ accent_colour: v })} testid="signage-accent" /> +
    +

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

    +
    +
    + ) +} + +function RowLabel({ children }) { + return {children} +} + +/** Bold, italic, underline: three toggles as tall as a field. */ +function TextToggles({ s, onChange, testid }) { + const { t } = useTranslation('manager') + const items = [['bold', Bold, s.bold !== false], ['italic', Italic, !!s.italic], ['underline', Underline, !!s.underline]] + return ( +
    + {items.map(([k, Icon, on]) => ( + + ))} +
    + ) +} diff --git a/manager_dashboard/src/pages/signage/SlidePreview.jsx b/manager_dashboard/src/pages/signage/SlidePreview.jsx index 8042754..0545d3f 100644 --- a/manager_dashboard/src/pages/signage/SlidePreview.jsx +++ b/manager_dashboard/src/pages/signage/SlidePreview.jsx @@ -44,7 +44,7 @@ export default function SlidePreview({ slide, media, venue, orientation = 'lands
  • {editor && slide && scale > 0 && WIDGET_HOSTS.includes(slide.kind) && ( + onPlace={editor.onPlace} onRemove={editor.onRemove} label={editor.label} /> )}
    ) diff --git a/manager_dashboard/src/pages/signage/WidgetCanvas.jsx b/manager_dashboard/src/pages/signage/WidgetCanvas.jsx index c71515a..99a627a 100644 --- a/manager_dashboard/src/pages/signage/WidgetCanvas.jsx +++ b/manager_dashboard/src/pages/signage/WidgetCanvas.jsx @@ -5,7 +5,8 @@ // position and size "custom" and its own box (% of the slide), which the TV draws the same. // It lies over SlidePreview's box and finds each widget by its `data-widget` (@xenia/signage). // Owner review 2 (2026-11-21): the arrow keys move the picked widget wherever it was picked (here -// or on its card below), unless you are typing or using a control that takes the arrows itself. +// or on its card below), unless you are typing or using a control that takes the arrows itself; +// Delete (or Backspace) removes it (owner review 3; "Undo changes" brings it back). import { useEffect, useLayoutEffect, useRef, useState } from 'react' import { useTranslation } from '@xenia/i18n' import { boxFromRect, moveBox, resizeBox, snapBox } from './signageLogic' @@ -16,7 +17,7 @@ const SIZE = 14 // a handle, px // where the arrow keys belong to the control (typing, lists, sliders, choices) const OWN_KEYS = 'input, textarea, select, [contenteditable="true"], [role="slider"], [role="radio"], [role="option"], [role="listbox"], [role="combobox"], [role="menu"], [role="menuitem"], [role="tab"], [role="spinbutton"], [role="dialog"] *' -export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPlace, label }) { +export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPlace, onRemove, label }) { const { t } = useTranslation('manager') const [rects, setRects] = useState({}) const [guides, setGuides] = useState([]) @@ -76,6 +77,7 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return if (e.target instanceof Element && e.target.closest(OWN_KEYS)) return if (e.key === 'Escape') { onSelect(null); return } + if ((e.key === 'Delete' || e.key === 'Backspace') && onRemove) { e.preventDefault(); onRemove(selected); return } const step = e.shiftKey ? 2 : 0.5 const d = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] }[e.key] if (!d) return @@ -86,7 +88,7 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl } window.addEventListener('keydown', on) return () => window.removeEventListener('keydown', on) - }, [selected, widgets, rects, onPlace, onSelect]) + }, [selected, widgets, rects, onPlace, onSelect, onRemove]) const sel = selected != null ? (widgets[selected]?.position === 'custom' && widgets[selected].box) || rects[selected] : null return ( diff --git a/manager_dashboard/src/pages/signage/WidgetsEditor.jsx b/manager_dashboard/src/pages/signage/WidgetsEditor.jsx index 8a60591..15b6a34 100644 --- a/manager_dashboard/src/pages/signage/WidgetsEditor.jsx +++ b/manager_dashboard/src/pages/signage/WidgetsEditor.jsx @@ -10,10 +10,12 @@ // tomorrow / the day after and in three styles; a menu widget (a board's list in its box); stacks: // parts side by side or one over the other, each its share (%), showing a widget, another stack (one // 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). // Up to 10 (the server's limit). -import { useEffect, useState } from 'react' +import { Fragment, useEffect, useRef, useState } from 'react' import { - AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical, + 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' @@ -251,8 +253,10 @@ function MenuBoardFields({ w, set, extras, path }) { } /** - * A stack's parts: side by side or one over the other, how many (2–6), each its share (%; changing - * one gives or takes from its neighbour, "even" splits them equally) and what it shows. + * 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. */ function StackFields({ w, set, media, onMedia, extras, path, depth }) { const { t } = useTranslation('manager') @@ -261,6 +265,7 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) { 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 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] }))) @@ -272,6 +277,10 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) { else setCell(j, { widget: cellWidget(v), slide_id: null }) } 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}`) + } return (
    @@ -288,29 +297,26 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) {
    - {/* the parts as they share the stack */} - + +

    {t('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 } }) return (
    +
    + {t('signage.widgets.stack.partTitle', { n: j + 1 })} + {shares[j]}% +
    - - { const next = setShare(shares, j, e.target.value.replace(/\D/g, '')); setCells(cells.map((x, k) => ({ ...x, share: next[k] }))) }} /> - 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" @@ -318,17 +324,105 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) { : [{ value: '', label: t('signage.widgets.stack.noSlides') }]} /> ) : c.widget && <> - {c.widget.kind !== 'stack' && setCell(j, { widget: { ...c.widget, ...patch } })} testid="signage-cell-align" />} - setCell(j, { widget: { ...c.widget, ...patch } })} /> + {c.widget.kind !== 'stack' && } + }
    - {c.widget && ( - setCell(j, { widget: { ...c.widget, ...patch } })} media={media} onMedia={onMedia} - extras={extras} path={cp} depth={depth + 1} /> - )} + {c.widget && }
    ) })} ) } + +/** + * The stack's parts drawn to scale; the lines between them are dragged to change their sizes (the + * two parts beside a line share their room, each keeps at least 5 %), or focused and moved with the + * arrow keys (Shift: 5 %). + */ +function ShareBar({ column, shares, labels, onChange }) { + const { t } = useTranslation('manager') + const bar = useRef(null) + const drag = (e, j) => { + e.preventDefault() + const el = bar.current + if (!el) return + const r = el.getBoundingClientRect() + const len = column ? r.height : r.width + const p0 = column ? e.clientY : e.clientX + const start = [...shares] + const move = ev => { + const d = (((column ? ev.clientY : ev.clientX) - p0) / len) * 100 + onChange(setShare(start, j, start[j] + d)) + } + const up = () => { window.removeEventListener('pointermove', move); window.removeEventListener('pointerup', up) } + window.addEventListener('pointermove', move) + window.addEventListener('pointerup', up) + } + const key = (e, j) => { + const step = e.shiftKey ? 5 : 1 + const d = { ArrowLeft: -step, ArrowUp: -step, ArrowRight: step, ArrowDown: step }[e.key] + if (d == null) return + e.preventDefault() + e.stopPropagation() + onChange(setShare(shares, j, shares[j] + d)) + } + return ( +
    + {shares.map((sh, j) => ( + + + {sh}% + {labels[j]} + + {j < shares.length - 1 && ( + drag(e, j)} onKeyDown={e => key(e, j)} + className={`relative shrink-0 bg-accent outline-none focus-visible:ring-2 focus-visible:ring-accent ring-offset-1 ${column ? 'h-1.5 cursor-row-resize' : 'w-1.5 cursor-col-resize'} + after:absolute ${column ? 'after:-inset-y-2 after:inset-x-0' : 'after:-inset-x-2 after:inset-y-0'}`} + data-testid="signage-stack-line" data-index={j} /> + )} + + ))} +
    + ) +} + +/** "Add a widget" to a part: every widget (and a slide from the Slides library) in a small panel. */ +function AddToPart({ kinds, onPick, filled }) { + 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 choose = k => { onPick(k); setOpen(false) } + return ( +
    + + {open && ( +
    + {[...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 ca02450..bbc4940 100644 --- a/manager_dashboard/src/pages/signage/signageLogic.js +++ b/manager_dashboard/src/pages/signage/signageLogic.js @@ -306,3 +306,6 @@ export function toggleMonthDay(line, key) { const md = line.month_days || [] return { month_days: md.includes(key) ? md.filter(x => x !== key) : [...md, key], days: [] } } + +/** 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' } diff --git a/manager_dashboard/src/pages/signage/useSlideDraft.js b/manager_dashboard/src/pages/signage/useSlideDraft.js index e60ca6e..3626c9b 100644 --- a/manager_dashboard/src/pages/signage/useSlideDraft.js +++ b/manager_dashboard/src/pages/signage/useSlideDraft.js @@ -46,5 +46,9 @@ export function useWidgetEditor(setDraft, slideKey, label) { const ws = d?.content?.widgets || [] return { ...d, content: { ...d.content, widgets: ws.map((w, j) => (j === i ? placeWidget(w, box) : w)) } } }) - return { widget, setWidget, editor: { selected: widget, onSelect: setWidget, onPlace, label } } + const onRemove = i => { + setDraft(d => ({ ...d, content: { ...d.content, widgets: (d?.content?.widgets || []).filter((_, j) => j !== i) } })) + setWidget(null) + } + return { widget, setWidget, editor: { selected: widget, onSelect: setWidget, onPlace, onRemove, label } } } diff --git a/packages/i18n/locales/el/manager.json b/packages/i18n/locales/el/manager.json index 6f0d722..74ad7ee 100644 --- a/packages/i18n/locales/el/manager.json +++ b/packages/i18n/locales/el/manager.json @@ -1438,7 +1438,12 @@ "placeHint": "Σε όλο το πλάτος η λίστα γεμίζει την οθόνη: στενέψτε την για να τη μετακινήσετε.", "hiddenTag": "κρυμμένο", "pageSecondsHint": "Όταν η λίστα δεν χωράει στην οθόνη, χωρίζεται σε σελίδες που εναλλάσσονται: κάθε σελίδα μένει τόσα δευτερόλεπτα.", - "perPageWidgetHint": "Κενό: 8. Περισσότερα γυρίζουν σελίδα." + "perPageWidgetHint": "Κενό: 8. Περισσότερα γυρίζουν σελίδα.", + "ownName": "Όνομα σε αυτόν τον πίνακα", + "rename": "Άλλο όνομα σε αυτόν τον πίνακα", + "renameBack": "Πίσω στο όνομα του καταλόγου", + "catalogueName": "Το όνομα του καταλόγου (αυτό βλέπουν οι σερβιτόροι)", + "catalogueNameIs": "Κατάλογος: {{name}}" }, "badges": { "new": "Νέο", @@ -1522,12 +1527,16 @@ "column": "Το ένα κάτω από το άλλο", "parts": "Πόσα", "even": "Ίση μοιρασιά", - "part": "Τμήμα {{n}} (%)", "shows": "Δείχνει", "nothing": "Τίποτα", "aSlide": "Μια διαφάνεια από τις Διαφάνειες", "slide": "Διαφάνεια", - "noSlides": "Δεν υπάρχουν ακόμα διαφάνειες" + "noSlides": "Δεν υπάρχουν ακόμα διαφάνειες", + "barHint": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για να αλλάξετε το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια).", + "partTitle": "Τμήμα {{n}}", + "line": "Η γραμμή ανάμεσα στα τμήματα {{a}} και {{b}}", + "add": "Προσθήκη widget", + "replace": "Κάτι άλλο" } }, "tabs": { @@ -1662,6 +1671,41 @@ "keepHint": "Ένα αντίγραφο της διαφάνειας όπως είναι τώρα πηγαίνει στην καρτέλα Διαφάνειες, για άλλες λίστες ή για να προβάλλεται μόνη της σε μια οθόνη.", "keepYes": "Κράτηση", "kept": "Κρατήθηκε στις Διαφάνειες." + }, + "look": { + "headings": "Επικεφαλίδες", + "names": "Ονόματα προϊόντων", + "prices": "Τιμές", + "dots": "Τελείες", + "spacing": "Αποστάσεις", + "size": "Μέγεθος", + "colour": "Χρώμα", + "font": "Γραμματοσειρά", + "style": "Στυλ", + "align": "Στοίχιση", + "sameFont": "Όπως τα ονόματα", + "bold": "Έντονα", + "italic": "Πλάγια", + "underline": "Υπογράμμιση", + "dotStyle": "Γραμμή", + "dotStyles": { + "dotted": "Τελείες", + "dashed": "Παύλες", + "solid": "Γραμμή", + "none": "Καμία" + }, + "lineHeight": "Διάστιχο", + "letterSpacing": "Απόσταση γραμμάτων", + "auto": "Αυτόματο", + "photoSize": "Μέγεθος φωτογραφίας", + "photoShape": "Σχήμα φωτογραφίας", + "shapes": { + "square": "Τετράγωνο", + "rounded": "Στρογγυλεμένο", + "round": "Στρογγυλό" + }, + "accent": "Σήματα και τελείες σελίδων", + "hint": "Τα ονόματα προϊόντων ορίζουν το μέγεθος, το χρώμα και τη γραμματοσειρά του πίνακα· οι επικεφαλίδες και οι τιμές τα ακολουθούν (στο χρώμα έμφασης) μέχρι να αλλάξετε τα δικά τους. Με στοίχιση δεξιά τα ονόματα τελειώνουν στο ίδιο σημείο, με ίσες τελείες πριν τις τιμές. Διάστιχο: π.χ. 1.3 (× το κείμενο)· απόσταση γραμμάτων: π.χ. 0.05 (ενός γράμματος)· κενό = αυτόματο." } }, "overview": { diff --git a/packages/i18n/locales/en/manager.json b/packages/i18n/locales/en/manager.json index e3d06bb..1d24607 100644 --- a/packages/i18n/locales/en/manager.json +++ b/packages/i18n/locales/en/manager.json @@ -1438,7 +1438,12 @@ "placeHint": "At the full width the list fills the screen: make it narrower to place it.", "hiddenTag": "hidden", "pageSecondsHint": "When the list doesn't fit on the screen it is split into pages that take turns: each page stays this many seconds.", - "perPageWidgetHint": "Empty: 8. More than that turns pages." + "perPageWidgetHint": "Empty: 8. More than that turns pages.", + "ownName": "Name on this board", + "rename": "Name it differently on this board", + "renameBack": "Back to the catalogue's name", + "catalogueName": "The catalogue's name (the waiters see this one)", + "catalogueNameIs": "Catalogue: {{name}}" }, "badges": { "new": "New", @@ -1522,12 +1527,16 @@ "column": "One over the other", "parts": "How many", "even": "Split evenly", - "part": "Part {{n}} (%)", "shows": "Shows", "nothing": "Nothing", "aSlide": "A slide from Slides", "slide": "Slide", - "noSlides": "No slides in Slides yet" + "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).", + "partTitle": "Part {{n}}", + "line": "The line between parts {{a}} and {{b}}", + "add": "Add a widget", + "replace": "Put something else" } }, "tabs": { @@ -1662,6 +1671,41 @@ "keepHint": "A copy of the slide as it is now goes to the Slides tab, to reuse in other playlists or show alone on a screen.", "keepYes": "Keep it", "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", + "solid": "A line", + "none": "None" + }, + "lineHeight": "Line spacing", + "letterSpacing": "Letter spacing", + "auto": "Auto", + "photoSize": "Photo size", + "photoShape": "Photo shape", + "shapes": { + "square": "Square", + "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." } }, "overview": { diff --git a/packages/signage/src/Slides.jsx b/packages/signage/src/Slides.jsx index c1504ec..ad2e85c 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, menuPages, pageAt, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic' +import { 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 }) { @@ -66,8 +66,9 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start' }} data-testid="signage-menu-board" data-align={c.board_align || 'left'}> {c.title &&

    {c.title}

    } -
    - +
    +
    {pages.length > 1 && (