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:
2026-11-21 10:51:03 +02:00
co-authored by Claude Opus 5.5
parent 1b993e4573
commit e8c8ec825e
16 changed files with 642 additions and 81 deletions
+47 -3
View File
@@ -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": {
+47 -3
View File
@@ -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": {
+58 -36
View File
@@ -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 && <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>}
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, columnFill: 'auto' }}>
<MenuGroups c={c} groups={groups} accent={accent} />
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
data-testid="signage-menu-list">
<MenuGroups c={c} groups={groups} />
</div>
{pages.length > 1 && (
<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
* 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 { formatMoney } = useFormat()
return groups.map((g, i) => (
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '0.5em' }}>
{g.category && c.category_titles !== false && (
<h2 style={{ fontSize: '1.15em', color: accent, margin: '0 0 0.19em', fontWeight: 700, breakAfter: 'avoid' }}
data-testid="signage-menu-heading">{g.category.name}</h2>
)}
{g.items.map(it => (
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
style={{ display: 'flex', alignItems: 'center', gap: '0.47em', breakInside: 'avoid', padding: '0.16em 0',
opacity: it.available ? 1 : 0.5 }}>
{c.show_photos && (it.image
? <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 }} />)}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ display: 'flex', alignItems: 'baseline', gap: '0.3em' }}>
<span style={{ textDecoration: it.available ? 'none' : 'line-through', fontWeight: 600 }}>{it.name}</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' }} 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>}
<span style={{ flex: 1, borderBottom: '0.08em dotted currentColor', opacity: 0.35, minWidth: '0.6em' }} />
{it.price != null && <span style={{ color: accent, fontVariantNumeric: 'tabular-nums', fontWeight: 700, whiteSpace: 'nowrap' }}
data-testid="signage-menu-price">{formatMoney(it.price)}</span>}
const look = menuLook(c)
const accent = c.accent_colour || '#f59e0b'
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
const nameFills = look.itemAlign !== 'left'
return (
<>
{groups.map((g, i) => (
<div key={`${g.category?.id ?? 'all'}-${i}`} style={{ marginBottom: '0.5em' }}>
{g.category && c.category_titles !== false && (
<h2 style={{ ...look.heading, lineHeight: 1.15, margin: '0 0 0.19em', breakAfter: 'avoid' }}
data-testid="signage-menu-heading">{g.category.name}</h2>
)}
{g.items.map(it => (
<div key={it.id} data-testid="signage-menu-item" data-id={it.id} data-available={it.available ? 'true' : 'false'}
style={{ display: 'flex', alignItems: 'center', gap: '0.47em', breakInside: 'avoid', padding: '0.16em 0',
opacity: it.available ? 1 : 0.5 }}>
{c.show_photos && (it.image
? <img src={it.image} alt="" style={{ width: look.photo.size, height: look.photo.size, objectFit: 'cover', borderRadius: look.photo.radius, flexShrink: 0 }} />
: <span style={{ width: look.photo.size, height: look.photo.size, flexShrink: 0 }} />)}
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ display: 'flex', alignItems: 'baseline', gap: '0.3em' }}>
<span style={{ ...look.item, textDecoration: it.available ? look.item.textDecoration : 'line-through',
...(nameFills ? { flex: 1, minWidth: 0, textAlign: look.itemAlign } : {}) }} data-testid="signage-menu-name">{it.name}</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>
{it.description && <div style={{ fontSize: '0.7em', opacity: 0.75, lineHeight: 1.25 }}>{it.description}</div>}
</div>
))}
</div>
))}
</div>
))
</>
)
}
// ── 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 cols = b.columns || 1
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 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'
@@ -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' }}
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>}
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto' }}>
<MenuGroups c={b} groups={pages[page] || []} accent={accent} />
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
<MenuGroups c={b} groups={pages[page] || []} />
</div>
</div>
)
+53 -1
View File
@@ -243,7 +243,8 @@ export function boardPages(slide, rotation, w, h) {
const c = slide.content || {}
const widgets = c.widgets || []
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 })
const per = c.page_size || rows * (c.columns || 2)
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) {
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
}
+24
View File
@@ -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)
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)
})