feat(signage): look rows that wrap, one colour field with opacity, badges' text, several widgets per stack part, pages up to 2200 px (owner review 4)
- Menu text look: each field names its part ("Headings size"), rows wrap in aligned columns on
alternating bands; names align left / right; line and letter spacing as lists (Auto default);
each field changes only itself (followers frozen before the other changes); badge colour +
badge text colour (auto: readableOn); "Reset the look" with a question.
- ColourField everywhere in signage: a Popover panel (new @xenia/ui Popover, portal, kept in the
window) with 12 presets, picker, opacity (#rrggbbaa) and typed code; HEX accepts 8 digits.
- Stacks: Cell.widgets (a stored `widget` still reads), several widgets per part laid across the
stack's direction; extras by path stack.part.place; Add a widget adds, each removable / ordered.
- Page rule: --x-page-max is 2200px (no longer follows the window height).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
||||
import { QRCodeSVG } from 'qrcode.react'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
||||
import { cellWidgets, fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
||||
|
||||
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
|
||||
export function Background({ bg, media }) {
|
||||
@@ -64,7 +64,7 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed
|
||||
{/* the list: the whole width, or narrower and placed left / centre / right (2026-11-21) */}
|
||||
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', width: `${c.board_width || 100}%`,
|
||||
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: c.heading_style?.colour || 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, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
||||
data-testid="signage-menu-list">
|
||||
@@ -100,7 +100,6 @@ export function MenuGroups({ c, groups }) {
|
||||
const { t } = useTranslation('terminal')
|
||||
const { formatMoney } = useFormat()
|
||||
const look = menuLook(c)
|
||||
const accent = c.accent_colour || '#f59e0b'
|
||||
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
|
||||
const nameFills = look.itemAlign !== 'left'
|
||||
return (
|
||||
@@ -123,7 +122,7 @@ export function MenuGroups({ c, groups }) {
|
||||
<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',
|
||||
<span style={{ ...look.badge, 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>}
|
||||
@@ -327,7 +326,7 @@ function MenuWidget({ board: b, menu, now }) {
|
||||
return (
|
||||
<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>}
|
||||
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: b.heading_style?.colour || accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
||||
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
|
||||
<MenuGroups c={b} groups={pages[page] || []} />
|
||||
</div>
|
||||
@@ -337,25 +336,32 @@ function MenuWidget({ board: b, menu, now }) {
|
||||
|
||||
/**
|
||||
* A stack (2026-11-21): parts side by side ("row") or one over the other ("column"), each its share
|
||||
* of the stack, showing a widget (filling the part) or a whole library slide.
|
||||
* of the stack, showing widgets (each filling its place; several share the part, one over the other
|
||||
* in a side-by-side stack and side by side in the other: owner review 4) or a whole library slide.
|
||||
*/
|
||||
function Stack({ w, path, ctx }) {
|
||||
const cells = w.cells || []
|
||||
const Embed = ctx.embed
|
||||
const across = w.direction === 'column' ? 'row' : 'column'
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: w.direction === 'column' ? 'column' : 'row', width: '100%', height: '100%' }}
|
||||
data-testid="signage-w-stack" data-direction={w.direction || 'row'}>
|
||||
{cells.map((c, j) => {
|
||||
const cp = `${path}.${j}`
|
||||
const slide = c.slide_id ? ctx.extras[cp]?.slide : null
|
||||
const body = c.widget ? widgetBody(c.widget, ctx, true, cp) : null
|
||||
const align = c.widget?.align && c.widget.align !== 'auto' ? c.widget.align : 'center'
|
||||
const ws = cellWidgets(c)
|
||||
const slide = !ws.length && c.slide_id ? ctx.extras[cp]?.slide : null
|
||||
return (
|
||||
<div key={j} style={{ flex: `${c.share || 1} 1 0%`, minWidth: 0, minHeight: 0, position: 'relative', overflow: 'hidden', containerType: 'size' }}
|
||||
data-testid="signage-stack-cell" data-share={c.share}>
|
||||
{body && (
|
||||
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: SELF[align], textAlign: align }}>{body}</div>
|
||||
)}
|
||||
<div key={j} style={{ flex: `${c.share || 1} 1 0%`, minWidth: 0, minHeight: 0, position: 'relative', overflow: 'hidden', containerType: 'size',
|
||||
display: 'flex', flexDirection: across }} data-testid="signage-stack-cell" data-share={c.share}>
|
||||
{ws.map((cw, k) => {
|
||||
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
||||
return (
|
||||
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size',
|
||||
display: 'flex', alignItems: 'center', justifyContent: SELF[align], textAlign: align }} data-testid="signage-stack-place">
|
||||
{widgetBody(cw, ctx, true, `${cp}.${k}`)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
{slide && Embed && <Embed slide={slide} media={ctx.media} venue={ctx.venue} now={ctx.now} />}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -321,7 +321,8 @@ const DOTS = { dotted: 'dotted', dashed: 'dashed', solid: 'solid' }
|
||||
* board's text size): headings, names and prices each their own size, colour, font, bold / italic /
|
||||
* underline and alignment (empty: the board's text size and font, the text colour for names and the
|
||||
* accent colour for headings and prices); the dots between name and price; line and letter spacing
|
||||
* (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape.
|
||||
* (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape;
|
||||
* the badges' colours (2026-11-21: their text the venue's, or white / black to read on them).
|
||||
*/
|
||||
export function menuLook(c = {}) {
|
||||
const base = c.text_size || 100
|
||||
@@ -345,6 +346,9 @@ export function menuLook(c = {}) {
|
||||
dots: d.style === 'none'
|
||||
? { borderBottom: 'none' }
|
||||
: { borderBottom: `${+(0.08 * (d.size || 100) / 100).toFixed(3)}em ${DOTS[d.style] || 'dotted'} ${d.colour || 'currentColor'}`, opacity: d.colour ? 1 : 0.35 },
|
||||
// badges: the accent (also the page dots), their text the venue's or one that reads on it
|
||||
badge: { background: accent, color: c.badge_text_colour || readableOn(accent) },
|
||||
title: c.heading_style?.colour || accent,
|
||||
lineHeight: c.line_height || 1.25,
|
||||
letterSpacing: c.letter_spacing != null ? `${c.letter_spacing}em` : 'normal',
|
||||
photo: { size: `${+(2.2 * (c.photo_size || 100) / 100).toFixed(3)}em`, radius: RADIUS[c.photo_shape] || RADIUS.rounded },
|
||||
@@ -354,6 +358,28 @@ export function menuLook(c = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
/** A stack part's widgets (a part stored before owner review 4 has one `widget`). */
|
||||
export function cellWidgets(c) {
|
||||
return c?.widgets?.length ? c.widgets : c?.widget ? [c.widget] : []
|
||||
}
|
||||
|
||||
/**
|
||||
* A text colour that reads on `hex` (#rgb, #rrggbb or #rrggbbaa; the alpha is ignored): white on a
|
||||
* dark colour, near-black on a light one (a badge's text when the venue chose none, 2026-11-21).
|
||||
*/
|
||||
export function readableOn(hex) {
|
||||
let h = String(hex || '').replace('#', '')
|
||||
if (h.length === 3 || h.length === 4) h = h.slice(0, 3).split('').map(x => x + x).join('')
|
||||
if (!/^[0-9a-f]{6}/i.test(h)) return '#111111'
|
||||
const [r, g, b] = [0, 2, 4].map(i => {
|
||||
const v = parseInt(h.slice(i, i + 2), 16) / 255
|
||||
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
|
||||
})
|
||||
const lum = 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||
// the text with the better contrast (WCAG): white beats near-black below ~0.18
|
||||
return lum < 0.18 ? '#ffffff' : '#111111'
|
||||
}
|
||||
|
||||
/** A page's widest price, in characters: the price column's width, so names and dots line up. */
|
||||
export function priceChars(groups, format) {
|
||||
let n = 0
|
||||
|
||||
@@ -192,3 +192,17 @@ test("a menu's look part by part: sizes against the board's text, colours fall b
|
||||
assert.deepEqual(menuLook({ dot_style: { style: 'none' } }).dots, { borderBottom: 'none' })
|
||||
assert.equal(priceChars([{ items: [{ price: 4.5 }, { price: 12 }, { price: null }] }], p => `€${p.toFixed(2)}`), 6)
|
||||
})
|
||||
|
||||
test('owner review 4: a part\'s widgets (one stored as `widget` too), badges that read', async () => {
|
||||
const { cellWidgets, menuLook, readableOn } = await import('../src/logic.js')
|
||||
assert.deepEqual(cellWidgets({ widgets: [{ kind: 'clock' }, { kind: 'date' }] }).map(w => w.kind), ['clock', 'date'])
|
||||
assert.deepEqual(cellWidgets({ widget: { kind: 'qr' } }).map(w => w.kind), ['qr'])
|
||||
assert.deepEqual(cellWidgets({ slide_id: 3 }), [])
|
||||
assert.equal(readableOn('#111827'), '#ffffff')
|
||||
assert.equal(readableOn('#1e3a8acc'), '#ffffff')
|
||||
assert.equal(readableOn('#f59e0b'), '#111111')
|
||||
assert.equal(readableOn('#fff'), '#111111')
|
||||
assert.deepEqual(menuLook({ accent_colour: '#1e3a8a' }).badge, { background: '#1e3a8a', color: '#ffffff' })
|
||||
assert.deepEqual(menuLook({ accent_colour: '#1e3a8a', badge_text_colour: '#fde68a' }).badge, { background: '#1e3a8a', color: '#fde68a' })
|
||||
assert.equal(menuLook({ accent_colour: '#123456', heading_style: { colour: '#ff0000' } }).title, '#ff0000')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user