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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user