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 <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,34 @@ Position = Literal["top-left", "top-center", "top-right", "bottom-left", "bottom
|
|||||||
|
|
||||||
|
|
||||||
Badge = Literal["new", "chef", "offer", "popular", "spicy", "vegetarian", "vegan"]
|
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):
|
class MenuList(_Strict):
|
||||||
@@ -107,6 +135,23 @@ class MenuList(_Strict):
|
|||||||
text_colour: str = Field(default="#ffffff", pattern=HEX)
|
text_colour: str = Field(default="#ffffff", pattern=HEX)
|
||||||
accent_colour: str = Field(default="#f59e0b", pattern=HEX) # prices, headings, badges
|
accent_colour: str = Field(default="#f59e0b", pattern=HEX) # prices, headings, badges
|
||||||
text_size: int = Field(default=100, ge=50, le=250)
|
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")
|
@field_validator("sales_point")
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -87,9 +87,18 @@ def resolve(db, content: dict, now=None, keep_hidden: bool = False) -> dict:
|
|||||||
def text(row, base, field):
|
def text(row, base, field):
|
||||||
return menu_languages.texts(base, menu_languages.of(row), field).get(lang, base) if lang else base
|
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):
|
def item(p):
|
||||||
image = media_store.image_of(p.media) if content.get("show_photos") else None
|
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,
|
"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,
|
"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,
|
"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 = {}
|
groups: dict = {}
|
||||||
for p in products:
|
for p in products:
|
||||||
groups.setdefault(p.primary_category_id, []).append(p)
|
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)]}
|
"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]))]
|
for cid, ps in sorted(groups.items(), key=lambda kv: cat_key(kv[0]))]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -95,3 +95,25 @@ def test_the_editor_previews_any_slide(client, owner_h, menu):
|
|||||||
m = r.json()["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 "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"
|
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
|
||||||
|
|||||||
@@ -10,15 +10,18 @@
|
|||||||
// crossed eye (a green eye on the ones shown): a click shows / hides it; seconds per page explained;
|
// 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,
|
// 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).
|
// 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 { 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 { MENU_LANGUAGES, SALES_POINTS } from '@xenia/access'
|
||||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||||
import { Dropdown, Field, IconButton, Input, Segmented, Select, Switch } from '@xenia/ui'
|
import { Dropdown, Field, IconButton, Input, Segmented, Select, Switch } from '@xenia/ui'
|
||||||
import client from '../../api/client'
|
import client from '../../api/client'
|
||||||
import { BADGES, boardOrder, moveGroup, moveItem, toggled } from './signageLogic'
|
import { BADGES, boardOrder, moveGroup, moveItem, toggled } from './signageLogic'
|
||||||
import { BackgroundField, ColourField, Range, Section } from './SignageFields'
|
import MenuLook from './MenuLook'
|
||||||
import { TextLook } from './SlideEditor'
|
import { BackgroundField, Range, Section } from './SignageFields'
|
||||||
import WidgetsEditor from './WidgetsEditor'
|
import WidgetsEditor from './WidgetsEditor'
|
||||||
|
|
||||||
let catalogue = null // categories and products, read once for every menu editor on the page
|
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 badges = c.badges || {}
|
||||||
const digits = v => Number(String(v).replace(/\D/g, ''))
|
const digits = v => Number(String(v).replace(/\D/g, ''))
|
||||||
const hidden = new Set(c.exclude_ids || [])
|
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 (
|
return (
|
||||||
<div className="grid gap-7" data-testid={testid}>
|
<div className="grid gap-7" data-testid={testid}>
|
||||||
@@ -120,7 +130,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
|||||||
<div key={`${g.category?.id ?? 'all'}`} className="grid gap-1" data-testid="signage-menu-group" data-name={g.category?.name ?? ''}>
|
<div key={`${g.category?.id ?? 'all'}`} className="grid gap-1" data-testid="signage-menu-group" data-name={g.category?.name ?? ''}>
|
||||||
{g.category && (
|
{g.category && (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<span className="text-label font-semibold text-ink flex-1">{g.category.name}</span>
|
<OwnName name={g.category.name} original={g.category.original} onSave={v => rename('category_names', g.category.id, v)}
|
||||||
|
className="text-label font-semibold text-ink" testid="signage-category-name" />
|
||||||
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={gi === 0} onClick={() => reorder(moveGroup(groups, gi, -1))} data-testid="signage-group-up"><ArrowUp size={14} /></IconButton>
|
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={gi === 0} onClick={() => reorder(moveGroup(groups, gi, -1))} data-testid="signage-group-up"><ArrowUp size={14} /></IconButton>
|
||||||
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={gi === groups.length - 1} onClick={() => reorder(moveGroup(groups, gi, 1))}><ArrowDown size={14} /></IconButton>
|
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={gi === groups.length - 1} onClick={() => reorder(moveGroup(groups, gi, 1))}><ArrowDown size={14} /></IconButton>
|
||||||
</div>
|
</div>
|
||||||
@@ -131,7 +142,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
|||||||
return (
|
return (
|
||||||
<li key={it.id} className="flex items-center gap-1.5 pl-2 rounded-control hover:bg-surface"
|
<li key={it.id} className="flex items-center gap-1.5 pl-2 rounded-control hover:bg-surface"
|
||||||
data-testid="signage-menu-row" data-id={it.id} data-hidden={off ? 'true' : undefined}>
|
data-testid="signage-menu-row" data-id={it.id} data-hidden={off ? 'true' : undefined}>
|
||||||
<span className={`flex-1 min-w-0 truncate text-label ${off ? 'text-ink-3 opacity-70' : it.available ? 'text-ink' : 'text-ink-3 line-through'}`}>{it.name}</span>
|
<OwnName name={it.name} original={it.original} onSave={v => 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 && <span className="text-caption text-ink-3">{t('signage.menu.hiddenTag')}</span>}
|
{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>}
|
{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}
|
<Select size="sm" value={badges[String(it.id)] || ''} aria-label={t('signage.menu.badge')} data-testid="signage-menu-badge" disabled={off}
|
||||||
@@ -208,9 +220,7 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
|||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
<TextLook c={c} setC={setC} align={false}>
|
<MenuLook c={c} setC={setC} />
|
||||||
<ColourField compact label={t('signage.accent')} value={c.accent_colour || '#f59e0b'} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
|
||||||
</TextLook>
|
|
||||||
{!board && <>
|
{!board && <>
|
||||||
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
||||||
misfit={misfit.includes(c.background?.media_id)} />
|
misfit={misfit.includes(c.background?.media_id)} />
|
||||||
@@ -220,3 +230,36 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A category's or product's name on the board, with a pencil (shown on hover or focus) to give it a
|
||||||
|
* name for this board only; the catalogue's name shows under it then, with a button to go back to it.
|
||||||
|
*/
|
||||||
|
function OwnName({ name, original, onSave, className = '', testid }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [edit, setEdit] = useState(null)
|
||||||
|
if (edit != null) {
|
||||||
|
const done = () => { onSave(edit); setEdit(null) }
|
||||||
|
return (
|
||||||
|
<span className="flex-1 min-w-0">
|
||||||
|
<Input size="sm" autoFocus value={edit} maxLength={80} aria-label={t('signage.menu.ownName')} data-testid={`${testid}-input`}
|
||||||
|
onChange={e => setEdit(e.target.value)} onBlur={done}
|
||||||
|
onKeyDown={e => { if (e.key === 'Enter') done(); if (e.key === 'Escape') setEdit(null) }} />
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<span className="group/name flex-1 min-w-0 flex items-center gap-1">
|
||||||
|
<span className="min-w-0 grid">
|
||||||
|
<span className={`truncate ${className}`} data-testid={testid}>{name}</span>
|
||||||
|
{original && <span className="truncate text-caption text-ink-3" title={t('signage.menu.catalogueName')}>{t('signage.menu.catalogueNameIs', { name: original })}</span>}
|
||||||
|
</span>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.menu.rename')} onClick={() => setEdit(name)} data-testid={`${testid}-edit`}
|
||||||
|
className="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 shrink-0"><Pencil size={13} /></IconButton>
|
||||||
|
{original && (
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.menu.renameBack')} onClick={() => onSave('')} data-testid={`${testid}-reset`}
|
||||||
|
className="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 shrink-0"><RotateCcw size={13} /></IconButton>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<div className={ROW} data-testid={`signage-look-${key}`}>
|
||||||
|
<RowLabel>{label}</RowLabel>
|
||||||
|
<Range label={t('signage.look.size')} value={size} min={50} max={300} step={10} suffix="%" onChange={onSize} testid={`signage-look-${key}-size`} />
|
||||||
|
<ColourField compact label={t('signage.look.colour')} value={colour} onChange={onColour} testid={`signage-look-${key}-colour`} />
|
||||||
|
<Field label={t('signage.look.font')}>
|
||||||
|
<Dropdown value={font} onChange={onFont} options={fontOptions(inherit)} data-testid={`signage-look-${key}-font`} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.look.style')}>
|
||||||
|
<TextToggles s={s} onChange={patch => setStyle(key, patch)} testid={`signage-look-${key}`} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.look.align')}>
|
||||||
|
<Segmented value={s.align || align} onChange={v => setStyle(key, { align: v })} fill data-testid={`signage-look-${key}-align`}
|
||||||
|
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-look-${key}-align-${v}` }))} />
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const d = style('dot_style')
|
||||||
|
return (
|
||||||
|
<Section title={t('signage.textLook')} testid="signage-text-look">
|
||||||
|
<div className="grid gap-5">
|
||||||
|
{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',
|
||||||
|
})}
|
||||||
|
<div className={ROW} data-testid="signage-look-dots">
|
||||||
|
<RowLabel>{t('signage.look.dots')}</RowLabel>
|
||||||
|
<Range label={t('signage.look.size')} value={d.size || 100} min={50} max={300} step={10} suffix="%" onChange={v => setStyle('dot_style', { size: v })} testid="signage-look-dots-size" />
|
||||||
|
<ColourField compact label={t('signage.look.colour')} value={d.colour || c.text_colour || MENU_COLOURS.text} onChange={v => setStyle('dot_style', { colour: v })} testid="signage-look-dots-colour" />
|
||||||
|
<Field label={t('signage.look.dotStyle')}>
|
||||||
|
<Dropdown value={d.style || 'dotted'} onChange={v => 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}`) }))} />
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
<div className={ROW} data-testid="signage-look-spacing">
|
||||||
|
<RowLabel>{t('signage.look.spacing')}</RowLabel>
|
||||||
|
<Field label={t('signage.look.lineHeight')}>
|
||||||
|
<Input inputMode="decimal" value={c.line_height ?? ''} placeholder={t('signage.look.auto')} data-testid="signage-look-line-height"
|
||||||
|
onChange={e => setC({ line_height: num(e.target.value, 0.8, 3) })} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.look.letterSpacing')}>
|
||||||
|
<Input inputMode="decimal" value={c.letter_spacing ?? ''} placeholder={t('signage.look.auto')} data-testid="signage-look-letter-spacing"
|
||||||
|
onChange={e => setC({ letter_spacing: num(e.target.value, -0.1, 0.5) })} />
|
||||||
|
</Field>
|
||||||
|
{c.show_photos ? <>
|
||||||
|
<Range label={t('signage.look.photoSize')} value={c.photo_size || 100} min={50} max={250} step={10} suffix="%" onChange={v => setC({ photo_size: v })} testid="signage-look-photo-size" />
|
||||||
|
<Field label={t('signage.look.photoShape')}>
|
||||||
|
<Dropdown value={c.photo_shape || 'rounded'} onChange={v => setC({ photo_shape: v })} data-testid="signage-look-photo-shape"
|
||||||
|
options={['square', 'rounded', 'round'].map(x => ({ value: x, label: t(`signage.look.shapes.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
</> : <><span className="hidden lg:block" /><span className="hidden lg:block" /></>}
|
||||||
|
<ColourField compact label={t('signage.look.accent')} value={accent} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
||||||
|
</div>
|
||||||
|
<p className="text-caption text-ink-3 -mt-2">{t('signage.look.hint')}</p>
|
||||||
|
</div>
|
||||||
|
</Section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function RowLabel({ children }) {
|
||||||
|
return <span className="col-span-2 lg:col-span-1 lg:h-control flex items-center text-label font-semibold text-ink">{children}</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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 (
|
||||||
|
<div className="h-control flex rounded-control border border-line bg-surface p-0.5 gap-0.5" role="group">
|
||||||
|
{items.map(([k, Icon, on]) => (
|
||||||
|
<button key={k} type="button" aria-pressed={on} aria-label={t(`signage.look.${k}`)} title={t(`signage.look.${k}`)}
|
||||||
|
onClick={() => onChange({ [k]: !on })} data-testid={`${testid}-${k}`}
|
||||||
|
className={`flex-1 grid place-items-center rounded-[calc(var(--x-radius-control)-2px)] transition-colors duration-fast
|
||||||
|
${on ? 'bg-accent-soft text-accent-ink' : 'text-ink-2 hover:bg-surface-2'}`}>
|
||||||
|
<Icon size={16} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -44,7 +44,7 @@ export default function SlidePreview({ slide, media, venue, orientation = 'lands
|
|||||||
</div>
|
</div>
|
||||||
{editor && slide && scale > 0 && WIDGET_HOSTS.includes(slide.kind) && (
|
{editor && slide && scale > 0 && WIDGET_HOSTS.includes(slide.kind) && (
|
||||||
<WidgetCanvas boxRef={box} widgets={slide.content?.widgets || []} selected={editor.selected} onSelect={editor.onSelect}
|
<WidgetCanvas boxRef={box} widgets={slide.content?.widgets || []} selected={editor.selected} onSelect={editor.onSelect}
|
||||||
onPlace={editor.onPlace} label={editor.label} />
|
onPlace={editor.onPlace} onRemove={editor.onRemove} label={editor.label} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
// position and size "custom" and its own box (% of the slide), which the TV draws the same.
|
// 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).
|
// 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
|
// 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 { useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { boxFromRect, moveBox, resizeBox, snapBox } from './signageLogic'
|
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)
|
// 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"] *'
|
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 { t } = useTranslation('manager')
|
||||||
const [rects, setRects] = useState({})
|
const [rects, setRects] = useState({})
|
||||||
const [guides, setGuides] = 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.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return
|
||||||
if (e.target instanceof Element && e.target.closest(OWN_KEYS)) return
|
if (e.target instanceof Element && e.target.closest(OWN_KEYS)) return
|
||||||
if (e.key === 'Escape') { onSelect(null); 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 step = e.shiftKey ? 2 : 0.5
|
||||||
const d = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] }[e.key]
|
const d = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] }[e.key]
|
||||||
if (!d) return
|
if (!d) return
|
||||||
@@ -86,7 +88,7 @@ export default function WidgetCanvas({ boxRef, widgets, selected, onSelect, onPl
|
|||||||
}
|
}
|
||||||
window.addEventListener('keydown', on)
|
window.addEventListener('keydown', on)
|
||||||
return () => window.removeEventListener('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
|
const sel = selected != null ? (widgets[selected]?.position === 'custom' && widgets[selected].box) || rects[selected] : null
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -10,10 +10,12 @@
|
|||||||
// tomorrow / the day after and in three styles; a menu widget (a board's list in its box); stacks:
|
// 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
|
// 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.
|
// 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).
|
// Up to 10 (the server's limit).
|
||||||
import { useEffect, useState } from 'react'
|
import { Fragment, useEffect, useRef, useState } from 'react'
|
||||||
import {
|
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,
|
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { evenShares, setShare } from '@xenia/signage'
|
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
|
* A stack's parts: side by side or one over the other, how many (2–6), their sizes (drag the lines
|
||||||
* one gives or takes from its neighbour, "even" splits them equally) and what it shows.
|
* 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 }) {
|
function StackFields({ w, set, media, onMedia, extras, path, depth }) {
|
||||||
const { t } = useTranslation('manager')
|
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 shares = cells.map(c => Math.round(c.share || 0))
|
||||||
const setCells = next => set({ cells: next })
|
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) => (k === j ? { ...c, ...patch } : c)))
|
||||||
|
const setShares = next => setCells(cells.map((c, k) => ({ ...c, share: next[k] })))
|
||||||
const count = n => {
|
const count = n => {
|
||||||
const even = evenShares(n)
|
const even = evenShares(n)
|
||||||
setCells(Array.from({ length: n }, (_, k) => ({ ...(cells[k] || {}), share: even[k] })))
|
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 })
|
else setCell(j, { widget: cellWidget(v), slide_id: null })
|
||||||
}
|
}
|
||||||
const kinds = [...CELL_KINDS, ...(depth === 0 ? ['hstack', 'vstack'] : [])]
|
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 (
|
return (
|
||||||
<div className="grid gap-3 rounded-control border border-line bg-surface p-3" data-testid="signage-stack-editor" data-depth={depth}>
|
<div className="grid gap-3 rounded-control border border-line bg-surface p-3" data-testid="signage-stack-editor" data-depth={depth}>
|
||||||
<div className={ROW}>
|
<div className={ROW}>
|
||||||
@@ -288,29 +297,26 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) {
|
|||||||
<Button variant="secondary" onClick={() => count(cells.length)} data-testid="signage-stack-even">{t('signage.widgets.stack.even')}</Button>
|
<Button variant="secondary" onClick={() => count(cells.length)} data-testid="signage-stack-even">{t('signage.widgets.stack.even')}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* the parts as they share the stack */}
|
<ShareBar column={w.direction === 'column'} shares={shares} labels={cells.map(label)} onChange={setShares} />
|
||||||
<div className={`flex ${w.direction === 'column' ? 'flex-col h-20 w-32' : 'h-8'} gap-0.5 rounded-control overflow-hidden`} aria-hidden="true">
|
<p className="text-caption text-ink-3 -mt-1">{t('signage.widgets.stack.barHint')}</p>
|
||||||
{cells.map((c, j) => (
|
|
||||||
<span key={j} style={{ flex: `${c.share || 1} 1 0%` }}
|
|
||||||
className="grid place-items-center bg-accent-soft text-accent-ink text-caption font-semibold tabular-nums min-w-0 min-h-0">{shares[j]}%</span>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
{cells.map((c, j) => {
|
{cells.map((c, j) => {
|
||||||
const cp = `${path}.${j}`
|
const cp = `${path}.${j}`
|
||||||
const v = shows(c)
|
const v = shows(c)
|
||||||
|
const setW = patch => setCell(j, { widget: { ...c.widget, ...patch } })
|
||||||
return (
|
return (
|
||||||
<div key={j} className="grid gap-3 rounded-control border border-line bg-surface-2 p-3" data-testid="signage-stack-cell-editor" data-index={j}>
|
<div key={j} className="grid gap-3 rounded-control border border-line bg-surface-2 p-3" data-testid="signage-stack-cell-editor" data-index={j}>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="text-label font-semibold text-ink">{t('signage.widgets.stack.partTitle', { n: j + 1 })}</span>
|
||||||
|
<span className="text-caption text-ink-3 tabular-nums" data-testid="signage-stack-share">{shares[j]}%</span>
|
||||||
|
</div>
|
||||||
<div className={ROW}>
|
<div className={ROW}>
|
||||||
<Field label={t('signage.widgets.stack.part', { n: j + 1 })}>
|
|
||||||
<Input inputMode="numeric" value={String(shares[j])} data-testid="signage-stack-share"
|
|
||||||
onChange={e => { const next = setShare(shares, j, e.target.value.replace(/\D/g, '')); setCells(cells.map((x, k) => ({ ...x, share: next[k] }))) }} />
|
|
||||||
</Field>
|
|
||||||
<Field label={t('signage.widgets.stack.shows')}>
|
<Field label={t('signage.widgets.stack.shows')}>
|
||||||
<Dropdown value={v} onChange={x => pick(j, x)} data-testid="signage-stack-shows"
|
<Dropdown value={v} onChange={x => pick(j, x)} data-testid="signage-stack-shows"
|
||||||
options={[{ value: '', label: t('signage.widgets.stack.nothing') },
|
options={[{ value: '', label: t('signage.widgets.stack.nothing') },
|
||||||
...kinds.map(k => ({ value: k, label: t(`signage.widgets.kinds.${k}`) })),
|
...kinds.map(k => ({ value: k, label: t(`signage.widgets.kinds.${k}`) })),
|
||||||
{ value: 'slide', label: t('signage.widgets.stack.aSlide') }]} />
|
{ value: 'slide', label: t('signage.widgets.stack.aSlide') }]} />
|
||||||
</Field>
|
</Field>
|
||||||
|
<div className="flex items-end"><AddToPart kinds={kinds} onPick={x => pick(j, x)} filled={!!v} /></div>
|
||||||
{c.slide_id != null || v === 'slide' ? (
|
{c.slide_id != null || v === 'slide' ? (
|
||||||
<Field label={t('signage.widgets.stack.slide')} className="col-span-2">
|
<Field label={t('signage.widgets.stack.slide')} className="col-span-2">
|
||||||
<Dropdown value={c.slide_id != null ? String(c.slide_id) : ''} onChange={x => setCell(j, { slide_id: x ? Number(x) : null })} data-testid="signage-stack-slide"
|
<Dropdown value={c.slide_id != null ? String(c.slide_id) : ''} onChange={x => 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') }]} />
|
: [{ value: '', label: t('signage.widgets.stack.noSlides') }]} />
|
||||||
</Field>
|
</Field>
|
||||||
) : c.widget && <>
|
) : c.widget && <>
|
||||||
{c.widget.kind !== 'stack' && <AlignField w={c.widget} set={patch => setCell(j, { widget: { ...c.widget, ...patch } })} testid="signage-cell-align" />}
|
{c.widget.kind !== 'stack' && <AlignField w={c.widget} set={setW} testid="signage-cell-align" />}
|
||||||
<InlineFields w={c.widget} set={patch => setCell(j, { widget: { ...c.widget, ...patch } })} />
|
<InlineFields w={c.widget} set={setW} />
|
||||||
</>}
|
</>}
|
||||||
</div>
|
</div>
|
||||||
{c.widget && (
|
{c.widget && <BelowFields w={c.widget} set={setW} media={media} onMedia={onMedia} extras={extras} path={cp} depth={depth + 1} />}
|
||||||
<BelowFields w={c.widget} set={patch => setCell(j, { widget: { ...c.widget, ...patch } })} media={media} onMedia={onMedia}
|
|
||||||
extras={extras} path={cp} depth={depth + 1} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 (
|
||||||
|
<div ref={bar} className={`flex ${column ? 'flex-col h-40 w-full max-w-md' : 'h-14 w-full'} rounded-control overflow-hidden border border-line select-none`}
|
||||||
|
data-testid="signage-stack-bar">
|
||||||
|
{shares.map((sh, j) => (
|
||||||
|
<Fragment key={j}>
|
||||||
|
<span style={{ flex: `${sh} 1 0%` }} className="min-w-0 min-h-0 grid place-items-center content-center gap-0.5 bg-accent-soft text-accent-ink px-1 text-center">
|
||||||
|
<span className="text-label font-semibold tabular-nums">{sh}%</span>
|
||||||
|
<span className="text-caption truncate max-w-full">{labels[j]}</span>
|
||||||
|
</span>
|
||||||
|
{j < shares.length - 1 && (
|
||||||
|
<span role="separator" tabIndex={0} aria-orientation={column ? 'horizontal' : 'vertical'} aria-valuenow={sh} aria-valuemin={5} aria-valuemax={95}
|
||||||
|
aria-label={t('signage.widgets.stack.line', { a: j + 1, b: j + 2 })} onPointerDown={e => 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} />
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "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 (
|
||||||
|
<div ref={box} className="relative">
|
||||||
|
<Button variant="secondary" icon={<Plus size={14} />} onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-stack-add">
|
||||||
|
{t(filled ? 'signage.widgets.stack.replace' : 'signage.widgets.stack.add')}
|
||||||
|
</Button>
|
||||||
|
{open && (
|
||||||
|
<div className="absolute z-30 left-0 top-full mt-1.5 w-[22rem] grid grid-cols-2 gap-1.5 p-2 rounded-card border border-line bg-surface shadow-lg" role="menu">
|
||||||
|
{[...kinds, 'slide'].map(k => {
|
||||||
|
const Icon = k === 'slide' ? BookImage : ICON[k]
|
||||||
|
return (
|
||||||
|
<button key={k} type="button" role="menuitem" onClick={() => choose(k)} data-testid={`signage-stack-add-${k}`}
|
||||||
|
className="flex items-center gap-2 px-2.5 py-2 rounded-control text-left text-label text-ink hover:bg-surface-2">
|
||||||
|
<Icon size={15} className="text-ink-2 shrink-0" aria-hidden="true" />
|
||||||
|
{k === 'slide' ? t('signage.widgets.stack.aSlide') : t(`signage.widgets.kinds.${k}`)}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -306,3 +306,6 @@ export function toggleMonthDay(line, key) {
|
|||||||
const md = line.month_days || []
|
const md = line.month_days || []
|
||||||
return { month_days: md.includes(key) ? md.filter(x => x !== key) : [...md, key], 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' }
|
||||||
|
|||||||
@@ -46,5 +46,9 @@ export function useWidgetEditor(setDraft, slideKey, label) {
|
|||||||
const ws = d?.content?.widgets || []
|
const ws = d?.content?.widgets || []
|
||||||
return { ...d, content: { ...d.content, widgets: ws.map((w, j) => (j === i ? placeWidget(w, box) : w)) } }
|
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 } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1438,7 +1438,12 @@
|
|||||||
"placeHint": "Σε όλο το πλάτος η λίστα γεμίζει την οθόνη: στενέψτε την για να τη μετακινήσετε.",
|
"placeHint": "Σε όλο το πλάτος η λίστα γεμίζει την οθόνη: στενέψτε την για να τη μετακινήσετε.",
|
||||||
"hiddenTag": "κρυμμένο",
|
"hiddenTag": "κρυμμένο",
|
||||||
"pageSecondsHint": "Όταν η λίστα δεν χωράει στην οθόνη, χωρίζεται σε σελίδες που εναλλάσσονται: κάθε σελίδα μένει τόσα δευτερόλεπτα.",
|
"pageSecondsHint": "Όταν η λίστα δεν χωράει στην οθόνη, χωρίζεται σε σελίδες που εναλλάσσονται: κάθε σελίδα μένει τόσα δευτερόλεπτα.",
|
||||||
"perPageWidgetHint": "Κενό: 8. Περισσότερα γυρίζουν σελίδα."
|
"perPageWidgetHint": "Κενό: 8. Περισσότερα γυρίζουν σελίδα.",
|
||||||
|
"ownName": "Όνομα σε αυτόν τον πίνακα",
|
||||||
|
"rename": "Άλλο όνομα σε αυτόν τον πίνακα",
|
||||||
|
"renameBack": "Πίσω στο όνομα του καταλόγου",
|
||||||
|
"catalogueName": "Το όνομα του καταλόγου (αυτό βλέπουν οι σερβιτόροι)",
|
||||||
|
"catalogueNameIs": "Κατάλογος: {{name}}"
|
||||||
},
|
},
|
||||||
"badges": {
|
"badges": {
|
||||||
"new": "Νέο",
|
"new": "Νέο",
|
||||||
@@ -1522,12 +1527,16 @@
|
|||||||
"column": "Το ένα κάτω από το άλλο",
|
"column": "Το ένα κάτω από το άλλο",
|
||||||
"parts": "Πόσα",
|
"parts": "Πόσα",
|
||||||
"even": "Ίση μοιρασιά",
|
"even": "Ίση μοιρασιά",
|
||||||
"part": "Τμήμα {{n}} (%)",
|
|
||||||
"shows": "Δείχνει",
|
"shows": "Δείχνει",
|
||||||
"nothing": "Τίποτα",
|
"nothing": "Τίποτα",
|
||||||
"aSlide": "Μια διαφάνεια από τις Διαφάνειες",
|
"aSlide": "Μια διαφάνεια από τις Διαφάνειες",
|
||||||
"slide": "Διαφάνεια",
|
"slide": "Διαφάνεια",
|
||||||
"noSlides": "Δεν υπάρχουν ακόμα διαφάνειες"
|
"noSlides": "Δεν υπάρχουν ακόμα διαφάνειες",
|
||||||
|
"barHint": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για να αλλάξετε το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια).",
|
||||||
|
"partTitle": "Τμήμα {{n}}",
|
||||||
|
"line": "Η γραμμή ανάμεσα στα τμήματα {{a}} και {{b}}",
|
||||||
|
"add": "Προσθήκη widget",
|
||||||
|
"replace": "Κάτι άλλο"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
@@ -1662,6 +1671,41 @@
|
|||||||
"keepHint": "Ένα αντίγραφο της διαφάνειας όπως είναι τώρα πηγαίνει στην καρτέλα Διαφάνειες, για άλλες λίστες ή για να προβάλλεται μόνη της σε μια οθόνη.",
|
"keepHint": "Ένα αντίγραφο της διαφάνειας όπως είναι τώρα πηγαίνει στην καρτέλα Διαφάνειες, για άλλες λίστες ή για να προβάλλεται μόνη της σε μια οθόνη.",
|
||||||
"keepYes": "Κράτηση",
|
"keepYes": "Κράτηση",
|
||||||
"kept": "Κρατήθηκε στις Διαφάνειες."
|
"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": {
|
"overview": {
|
||||||
|
|||||||
@@ -1438,7 +1438,12 @@
|
|||||||
"placeHint": "At the full width the list fills the screen: make it narrower to place it.",
|
"placeHint": "At the full width the list fills the screen: make it narrower to place it.",
|
||||||
"hiddenTag": "hidden",
|
"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.",
|
"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": {
|
"badges": {
|
||||||
"new": "New",
|
"new": "New",
|
||||||
@@ -1522,12 +1527,16 @@
|
|||||||
"column": "One over the other",
|
"column": "One over the other",
|
||||||
"parts": "How many",
|
"parts": "How many",
|
||||||
"even": "Split evenly",
|
"even": "Split evenly",
|
||||||
"part": "Part {{n}} (%)",
|
|
||||||
"shows": "Shows",
|
"shows": "Shows",
|
||||||
"nothing": "Nothing",
|
"nothing": "Nothing",
|
||||||
"aSlide": "A slide from Slides",
|
"aSlide": "A slide from Slides",
|
||||||
"slide": "Slide",
|
"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": {
|
"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.",
|
"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",
|
"keepYes": "Keep it",
|
||||||
"kept": "Kept in Slides."
|
"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": {
|
"overview": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
||||||
import { QRCodeSVG } from 'qrcode.react'
|
import { QRCodeSVG } from 'qrcode.react'
|
||||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
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. */
|
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
|
||||||
export function Background({ bg, media }) {
|
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'}>
|
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start' }} data-testid="signage-menu-board" data-align={c.board_align || 'left'}>
|
||||||
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: accent, lineHeight: 1.1,
|
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: accent, lineHeight: 1.1,
|
||||||
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
||||||
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, columnFill: 'auto' }}>
|
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
||||||
<MenuGroups c={c} groups={groups} accent={accent} />
|
data-testid="signage-menu-list">
|
||||||
|
<MenuGroups c={c} groups={groups} />
|
||||||
</div>
|
</div>
|
||||||
{pages.length > 1 && (
|
{pages.length > 1 && (
|
||||||
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
<div style={{ display: 'flex', gap: '1cqmin', justifyContent: 'center', paddingTop: '1cqmin' }} aria-hidden="true">
|
||||||
@@ -83,42 +84,63 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A board's groups of items (a menu slide's page, a menu widget's page). Sizes are em of the
|
* A board's groups of items (a menu slide's page, a menu widget's page). Sizes are em of the
|
||||||
* list's text, so the same rows fit a whole screen or a widget's box.
|
* list's text, so the same rows fit a whole screen or a widget's box. Each part has its own look
|
||||||
|
* (menuLook, owner review 3): headings, names and prices (size, colour, font, bold / italic /
|
||||||
|
* underline, alignment), the dots between them, line and letter spacing, photos' size and shape.
|
||||||
|
* Prices sit in a column as wide as the page's widest price, so names aligned right end at the
|
||||||
|
* same point and the dots are all equal.
|
||||||
*/
|
*/
|
||||||
export function MenuGroups({ c, groups, accent }) {
|
/** A list's own line and letter spacing (never the page's fixed line height). */
|
||||||
|
const listSpacing = c => {
|
||||||
|
const look = menuLook(c)
|
||||||
|
return { lineHeight: look.lineHeight, letterSpacing: look.letterSpacing }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MenuGroups({ c, groups }) {
|
||||||
const { t } = useTranslation('terminal')
|
const { t } = useTranslation('terminal')
|
||||||
const { formatMoney } = useFormat()
|
const { formatMoney } = useFormat()
|
||||||
return groups.map((g, i) => (
|
const look = menuLook(c)
|
||||||
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '0.5em' }}>
|
const accent = c.accent_colour || '#f59e0b'
|
||||||
{g.category && c.category_titles !== false && (
|
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
|
||||||
<h2 style={{ fontSize: '1.15em', color: accent, margin: '0 0 0.19em', fontWeight: 700, breakAfter: 'avoid' }}
|
const nameFills = look.itemAlign !== 'left'
|
||||||
data-testid="signage-menu-heading">{g.category.name}</h2>
|
return (
|
||||||
)}
|
<>
|
||||||
{g.items.map(it => (
|
{groups.map((g, i) => (
|
||||||
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
|
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '0.5em' }}>
|
||||||
style={{ display: 'flex', alignItems: 'center', gap: '0.47em', breakInside: 'avoid', padding: '0.16em 0',
|
{g.category && c.category_titles !== false && (
|
||||||
opacity: it.available ? 1 : 0.5 }}>
|
<h2 style={{ ...look.heading, lineHeight: 1.15, margin: '0 0 0.19em', breakAfter: 'avoid' }}
|
||||||
{c.show_photos && (it.image
|
data-testid="signage-menu-heading">{g.category.name}</h2>
|
||||||
? <img src={it.image} alt="" style={{ width: '2.2em', height: '2.2em', objectFit: 'cover', borderRadius: '0.3em', flexShrink: 0 }} />
|
)}
|
||||||
: <span style={{ width: '2.2em', height: '2.2em', flexShrink: 0 }} />)}
|
{g.items.map(it => (
|
||||||
<div style={{ flex: 1, minWidth: 0 }}>
|
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
|
||||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: '0.3em' }}>
|
style={{ display: 'flex', alignItems: 'center', gap: '0.47em', breakInside: 'avoid', padding: '0.16em 0',
|
||||||
<span style={{ textDecoration: it.available ? 'none' : 'line-through', fontWeight: 600 }}>{it.name}</span>
|
opacity: it.available ? 1 : 0.5 }}>
|
||||||
{it.badge && (
|
{c.show_photos && (it.image
|
||||||
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.5em', borderRadius: '99em',
|
? <img src={it.image} alt="" style={{ width: look.photo.size, height: look.photo.size, objectFit: 'cover', borderRadius: look.photo.radius, flexShrink: 0 }} />
|
||||||
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap' }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
: <span style={{ width: look.photo.size, height: look.photo.size, flexShrink: 0 }} />)}
|
||||||
)}
|
<div style={{ flex: 1, minWidth: 0 }}>
|
||||||
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: '0.3em' }}>
|
||||||
<span style={{ flex: 1, borderBottom: '0.08em dotted currentColor', opacity: 0.35, minWidth: '0.6em' }} />
|
<span style={{ ...look.item, textDecoration: it.available ? look.item.textDecoration : 'line-through',
|
||||||
{it.price != null && <span style={{ color: accent, fontVariantNumeric: 'tabular-nums', fontWeight: 700, whiteSpace: 'nowrap' }}
|
...(nameFills ? { flex: 1, minWidth: 0, textAlign: look.itemAlign } : {}) }} data-testid="signage-menu-name">{it.name}</span>
|
||||||
data-testid="signage-menu-price">{formatMoney(it.price)}</span>}
|
{it.badge && (
|
||||||
|
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.5em', borderRadius: '99em',
|
||||||
|
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4 }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
||||||
|
)}
|
||||||
|
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
||||||
|
{it.price != null && <>
|
||||||
|
<span style={{ ...look.dots, ...(nameFills ? { flex: '0 0 2em' } : { flex: 1, minWidth: '0.6em' }) }} data-testid="signage-menu-dots" />
|
||||||
|
<span style={{ ...look.price, fontVariantNumeric: 'tabular-nums', whiteSpace: 'nowrap', minWidth: priceW, textAlign: look.priceAlign }}
|
||||||
|
data-testid="signage-menu-price">{formatMoney(it.price)}</span>
|
||||||
|
</>}
|
||||||
|
</div>
|
||||||
|
{it.description && <div style={{ fontSize: '0.7em', opacity: 0.75, lineHeight: 1.25, textAlign: nameFills ? look.itemAlign : undefined }}>{it.description}</div>}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{it.description && <div style={{ fontSize: '0.7em', opacity: 0.75, lineHeight: 1.25 }}>{it.description}</div>}
|
))}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</>
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── widgets (5.5b; placed by hand on the editor's preview, text / menu / stacks: owner 2026-11-21) ──
|
// ── widgets (5.5b; placed by hand on the editor's preview, text / menu / stacks: owner 2026-11-21) ──
|
||||||
@@ -298,7 +320,7 @@ function MenuWidget({ board: b, menu, now }) {
|
|||||||
const page = pageAt(pages.length, b.page_seconds, now.getTime())
|
const page = pageAt(pages.length, b.page_seconds, now.getTime())
|
||||||
const cols = b.columns || 1
|
const cols = b.columns || 1
|
||||||
const scale = (b.text_size || 100) / 100
|
const scale = (b.text_size || 100) / 100
|
||||||
const rowH = b.show_photos ? 2.6 : b.show_descriptions ? 2.1 : 1.5
|
const rowH = (b.show_photos ? 2.6 * (b.photo_size || 100) / 100 : b.show_descriptions ? 2.1 : 1.5) * menuLook(b).rowScale
|
||||||
const lines = Math.ceil(per / cols) + (headings ? 1 : 0)
|
const lines = Math.ceil(per / cols) + (headings ? 1 : 0)
|
||||||
const fontSize = `calc(${scale} * min(${(100 / (lines * rowH + (b.title ? 2 : 0) + 0.8)).toFixed(3)}cqh, ${(100 / (cols * 15)).toFixed(3)}cqw))`
|
const fontSize = `calc(${scale} * min(${(100 / (lines * rowH + (b.title ? 2 : 0) + 0.8)).toFixed(3)}cqh, ${(100 / (cols * 15)).toFixed(3)}cqw))`
|
||||||
const accent = b.accent_colour || '#f59e0b'
|
const accent = b.accent_colour || '#f59e0b'
|
||||||
@@ -306,8 +328,8 @@ function MenuWidget({ board: b, menu, now }) {
|
|||||||
<div style={{ width: '100%', height: '100%', overflow: 'hidden', fontSize, color: b.text_colour || '#fff', fontFamily: FONTS[b.font] || FONTS.sans, textAlign: 'left' }}
|
<div style={{ width: '100%', height: '100%', overflow: 'hidden', fontSize, color: b.text_colour || '#fff', fontFamily: FONTS[b.font] || FONTS.sans, textAlign: 'left' }}
|
||||||
data-testid="signage-w-menu" data-page={page} data-pages={pages.length}>
|
data-testid="signage-w-menu" data-page={page} data-pages={pages.length}>
|
||||||
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
||||||
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto' }}>
|
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
|
||||||
<MenuGroups c={b} groups={pages[page] || []} accent={accent} />
|
<MenuGroups c={b} groups={pages[page] || []} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -243,7 +243,8 @@ export function boardPages(slide, rotation, w, h) {
|
|||||||
const c = slide.content || {}
|
const c = slide.content || {}
|
||||||
const widgets = c.widgets || []
|
const widgets = c.widgets || []
|
||||||
const bars = ['top-bar', 'bottom-bar'].filter(p => widgets.some(x => x.position === p)).length
|
const bars = ['top-bar', 'bottom-bar'].filter(p => widgets.some(x => x.position === p)).length
|
||||||
const rows = rowsPerColumn({ heightVmin: frameHeightVmin(rotation, w, h), textSize: c.text_size, photos: c.show_photos,
|
const look = menuLook(c)
|
||||||
|
const rows = rowsPerColumn({ heightVmin: frameHeightVmin(rotation, w, h), textSize: (c.text_size || 100) * look.rowScale, photos: c.show_photos,
|
||||||
descriptions: c.show_descriptions, title: !!c.title, bars })
|
descriptions: c.show_descriptions, title: !!c.title, bars })
|
||||||
const per = c.page_size || rows * (c.columns || 2)
|
const per = c.page_size || rows * (c.columns || 2)
|
||||||
return menuPages(visibleGroups(slide.menu?.groups), per, c.category_titles !== false)
|
return menuPages(visibleGroups(slide.menu?.groups), per, c.category_titles !== false)
|
||||||
@@ -308,3 +309,54 @@ export function fitUnit(height, width) {
|
|||||||
export function textWidth(chars, size) {
|
export function textWidth(chars, size) {
|
||||||
return Math.max(1, chars) * size * 0.6
|
return Math.max(1, chars) * size * 0.6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── a menu's look, part by part (owner review 3, 2026-11-21) ──────────────────
|
||||||
|
|
||||||
|
const WEIGHT = { heading: 700, item: 600, price: 700 }
|
||||||
|
const RADIUS = { square: '0', rounded: '0.3em', round: '50%' }
|
||||||
|
const DOTS = { dotted: 'dotted', dashed: 'dashed', solid: 'solid' }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How a menu's parts look, as CSS for MenuGroups (sizes in em of the list's text, which is the
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
export function menuLook(c = {}) {
|
||||||
|
const base = c.text_size || 100
|
||||||
|
const accent = c.accent_colour || '#f59e0b'
|
||||||
|
const text = c.text_colour || '#fff'
|
||||||
|
const part = (s = {}, kind, colour, scale) => ({
|
||||||
|
fontSize: `${+(((s.size || base) / base) * scale).toFixed(3)}em`,
|
||||||
|
color: s.colour || colour,
|
||||||
|
fontFamily: s.font ? FONTS[s.font] : undefined,
|
||||||
|
fontWeight: s.bold === false ? 400 : WEIGHT[kind],
|
||||||
|
fontStyle: s.italic ? 'italic' : undefined,
|
||||||
|
textDecoration: s.underline ? 'underline' : undefined,
|
||||||
|
})
|
||||||
|
const d = c.dot_style || {}
|
||||||
|
return {
|
||||||
|
heading: { ...part(c.heading_style, 'heading', accent, 1.15), textAlign: c.heading_style?.align || undefined },
|
||||||
|
item: part(c.item_style, 'item', text, 1),
|
||||||
|
itemAlign: c.item_style?.align || 'left',
|
||||||
|
price: part(c.price_style, 'price', accent, 1),
|
||||||
|
priceAlign: c.price_style?.align || 'right',
|
||||||
|
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 },
|
||||||
|
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 },
|
||||||
|
// how much taller a row is than the usual (for the pages' sums)
|
||||||
|
rowScale: Math.max(1, (c.price_style?.size || base) / base, (c.item_style?.size || base) / base, (c.heading_style?.size || base) / base)
|
||||||
|
* ((c.line_height || 1.25) / 1.25),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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
|
||||||
|
for (const g of groups || []) for (const it of g.items || []) if (it.price != null) n = Math.max(n, String(format(it.price)).length)
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|||||||
@@ -168,3 +168,27 @@ test('stacks: even shares and a part resized against its neighbour; hidden produ
|
|||||||
const pages = boardPages({ content: { columns: 1 }, menu: { groups } }, 0, 1920, 1080)
|
const pages = boardPages({ content: { columns: 1 }, menu: { groups } }, 0, 1920, 1080)
|
||||||
assert.deepEqual(pages.flat().flatMap(g => g.items.map(i => i.id)), [2])
|
assert.deepEqual(pages.flat().flatMap(g => g.items.map(i => i.id)), [2])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("a menu's look part by part: sizes against the board's text, colours fall back to text / accent (2026-11-21)", async () => {
|
||||||
|
const { menuLook, priceChars } = await import('../src/logic.js')
|
||||||
|
const plain = menuLook({ text_size: 100, text_colour: '#ffffff', accent_colour: '#f59e0b' })
|
||||||
|
assert.equal(plain.heading.fontSize, '1.15em')
|
||||||
|
assert.equal(plain.heading.color, '#f59e0b')
|
||||||
|
assert.equal(plain.item.color, '#ffffff')
|
||||||
|
assert.equal(plain.price.fontWeight, 700)
|
||||||
|
assert.equal(plain.lineHeight, 1.25)
|
||||||
|
assert.equal(plain.itemAlign, 'left')
|
||||||
|
assert.equal(plain.priceAlign, 'right')
|
||||||
|
const own = menuLook({ text_size: 200, heading_style: { size: 300, colour: '#ff0000', italic: true, align: 'center' }, price_style: { bold: false },
|
||||||
|
dot_style: { style: 'dashed', size: 200, colour: '#00ff00' }, line_height: 1.5, photo_shape: 'round', photo_size: 200, item_style: { size: 250 } })
|
||||||
|
assert.equal(own.heading.fontSize, '1.725em')
|
||||||
|
assert.equal(own.heading.fontStyle, 'italic')
|
||||||
|
assert.equal(own.heading.textAlign, 'center')
|
||||||
|
assert.equal(own.price.fontWeight, 400)
|
||||||
|
assert.equal(own.dots.borderBottom, '0.16em dashed #00ff00')
|
||||||
|
assert.equal(own.photo.radius, '50%')
|
||||||
|
assert.equal(own.photo.size, '4.4em')
|
||||||
|
assert.equal(own.rowScale, 1.5 * 1.2)
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
|||||||
+28
-2
@@ -320,15 +320,38 @@ try {
|
|||||||
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
||||||
await stackCard.getByTestId('signage-stack-shows').first().click()
|
await stackCard.getByTestId('signage-stack-shows').first().click()
|
||||||
await mgr.getByRole('option', { name: 'Clock', exact: true }).click()
|
await mgr.getByRole('option', { name: 'Clock', exact: true }).click()
|
||||||
await stackCard.getByTestId('signage-stack-share').first().fill('25')
|
// 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()
|
||||||
|
await mgr.mouse.move(ln.x + ln.width / 2, ln.y + ln.height / 2)
|
||||||
|
await mgr.mouse.down()
|
||||||
|
await mgr.mouse.move(bar.x + bar.width * 0.25, ln.y + ln.height / 2, { steps: 6 })
|
||||||
|
await mgr.mouse.up()
|
||||||
r.check('2026-11-21 (2): a horizontal stack: a clock in its first part, 25 / 75, on the preview',
|
r.check('2026-11-21 (2): a horizontal stack: a clock in its first part, 25 / 75, on the preview',
|
||||||
await waitFor(async () => {
|
await waitFor(async () => {
|
||||||
const cells = mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell')
|
const cells = mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell')
|
||||||
return (await cells.count()) === 2 && (await cells.first().getAttribute('data-share')) === '25'
|
return (await cells.count()) === 2 && (await cells.first().getAttribute('data-share')) === '25'
|
||||||
&& (await cells.first().getByTestId('signage-w-clock').count()) === 1
|
&& (await cells.first().getByTestId('signage-w-clock').count()) === 1
|
||||||
}, 6000, 300) === true)
|
}, 6000, 300) === true)
|
||||||
await stackCard.getByTestId('signage-widget-remove').click()
|
// "Add a widget" to the second part
|
||||||
|
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).getByTestId('signage-stack-add').click()
|
||||||
|
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)
|
||||||
|
// Delete removes the picked widget (picked on its card)
|
||||||
|
await stackCard.locator('span', { hasText: 'Horizontal stack' }).first().click()
|
||||||
|
await mgr.keyboard.press('Delete')
|
||||||
|
r.check('2026-11-21 (3): Delete removes the picked widget', await waitFor(async () => (await mgr.locator('[data-testid="signage-widget"][data-kind="stack"]').count()) === 0, 4000, 200) === true)
|
||||||
await textCard.getByTestId('signage-widget-remove').click()
|
await textCard.getByTestId('signage-widget-remove').click()
|
||||||
|
// this board's own name for a product; the names aligned right
|
||||||
|
await mgr.getByTestId('signage-item-name').first().hover()
|
||||||
|
await mgr.getByTestId('signage-item-name-edit').first().click()
|
||||||
|
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()
|
||||||
|
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)
|
||||||
// ── 2026-11-21: a widget moved and sized on the preview; the slide kept in the Slides library ──
|
// ── 2026-11-21: a widget moved and sized on the preview; the slide kept in the Slides library ──
|
||||||
await mgr.getByTestId('signage-preview-box').scrollIntoViewIfNeeded()
|
await mgr.getByTestId('signage-preview-box').scrollIntoViewIfNeeded()
|
||||||
await sleep(300)
|
await sleep(300)
|
||||||
@@ -349,6 +372,9 @@ try {
|
|||||||
await sleep(900)
|
await sleep(900)
|
||||||
const moved = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu').content.widgets.find(w => w.position === 'custom')
|
const moved = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu').content.widgets.find(w => w.position === 'custom')
|
||||||
r.check('2026-11-21: …saved with its own box', moved?.position === 'custom' && moved.size === 'custom' && moved.box?.w > 0 && moved.box?.h > 0, JSON.stringify(moved))
|
r.check('2026-11-21: …saved with its own box', moved?.position === 'custom' && moved.size === 'custom' && moved.box?.w > 0 && moved.box?.h > 0, JSON.stringify(moved))
|
||||||
|
const mc3 = (await api('GET', `/api/signage/playlists/${op.id}`, { token: boss })).slides.find(x => x.kind === 'menu').content
|
||||||
|
r.check('2026-11-21 (3): saved with a name for this board and the names aligned right',
|
||||||
|
Object.values(mc3.names || {}).includes('Signature dish') && mc3.item_style?.align === 'right', JSON.stringify({ names: mc3.names, item: mc3.item_style }))
|
||||||
await mgr.getByTestId('signage-keep-slide').click()
|
await mgr.getByTestId('signage-keep-slide').click()
|
||||||
await mgr.getByTestId('signage-keep-name').fill('Board to keep')
|
await mgr.getByTestId('signage-keep-name').fill('Board to keep')
|
||||||
await mgr.getByTestId('signage-keep-confirm').click()
|
await mgr.getByTestId('signage-keep-confirm').click()
|
||||||
|
|||||||
Reference in New Issue
Block a user