feat(signage): reviews typed in by hand and their widget; Add a widget at the top of the widgets, the list in layers (new widgets on top)

Reviews (name, stars, text, date, where) under Signage -> Message & settings, shown
one at a time by the reviews widget (a minimum of stars, seconds each); not pulled
from Google (owner's choice). The widgets section: one "Add a widget" menu at its
top instead of a button per kind; the cards are layers, the top one drawn over the
others, so a new widget goes on top; the arrows bring forward / send backward.
Plan 6R.19, F-113.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 14:21:17 +02:00
co-authored by Claude Opus 5.5
parent f26e51273c
commit 189bd2777b
14 changed files with 339 additions and 52 deletions
+44 -1
View File
@@ -175,7 +175,7 @@ const plate = (w, pad) => ({
...(w.background_colour ? { background: w.background_colour, borderRadius: cq(1.2), ...(pad ? { padding: `${cq(0.8)} ${cq(1.6)}` } : {}) } : {}),
})
// a menu, a stack, a shape or a scrolling text in a corner or a bar has no box of its own: it gets one of this size (cqmin)
const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7] }
const BOXED = { menu: [48, 56], stack: [60, 36], shape: [18, 18], ticker: [80, 7], reviews: [56, 24] }
/**
* The widgets of a slide: in their corners and bars, or (moved and sized by hand: position
@@ -336,9 +336,52 @@ function widgetBody(w, ctx, fit, path) {
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text)
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text)
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text)
if (w.kind === 'reviews') {
const list = (venue?.reviews || []).filter(r => r.stars >= (w.reviews_min || 4))
if (!list.length) return null
const r = list[pageAt(list.length, w.reviews_seconds || 8, now.getTime())]
return boxed(<ReviewBody w={w} r={r} fmt={fmt} n={list.length} />, 'reviews')
}
return null
}
const STAR = '#fbbf24'
/**
* One of the venue's reviews (6R.19), the next one every few seconds: its stars, what they wrote,
* who and where. It fills its place: the text is sized from the place's size and the review's length.
*/
function ReviewBody({ w, r, fmt, n }) {
const box = useRef(null)
const [size, setSize] = useState(null)
useEffect(() => {
const el = box.current
if (!el || typeof ResizeObserver === 'undefined') return undefined
const ro = new ResizeObserver(() => setSize(s => (s && s.w === el.clientWidth && s.h === el.clientHeight ? s : { w: el.clientWidth, h: el.clientHeight })))
ro.observe(el)
return () => ro.disconnect()
}, [])
const ts = (w.text_size || 100) / 100
const chars = r.text.length + 30
const f = size ? Math.max(6, Math.min(size.h / 4.2, Math.sqrt((0.55 * size.w * size.h) / (chars * 0.55 * 1.45))) * Math.min(1, ts)) : 0
const who = [w.reviews_name !== false && r.name, r.source, r.date && fmt.formatDate(`${r.date}T12:00:00Z`, 'date')].filter(Boolean).join(' · ')
const font = { ...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}) }
return (
<div ref={box} style={{ width: '100%', height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: f * 0.35, ...font }}
data-testid="signage-w-reviews" data-count={n} data-name={r.name}>
{size && <>
{w.reviews_stars !== false && (
<div style={{ display: 'flex', gap: f * 0.15, justifyContent: 'inherit' }} aria-label={`${r.stars}/5`}>
{[1, 2, 3, 4, 5].map(i => <Star key={i} style={{ width: f * 1.1, height: f * 1.1, color: STAR, fill: i <= r.stars ? STAR : 'none', opacity: i <= r.stars ? 1 : 0.4 }} aria-hidden="true" />)}
</div>
)}
<div style={{ fontSize: f, lineHeight: 1.35, fontWeight: w.bold ? 700 : 500, ...(w.underline ? { textDecoration: 'underline' } : {}) }}>“{r.text}”</div>
{who && <div style={{ fontSize: f * 0.72, fontWeight: 700, opacity: 0.85 }}>— {who}</div>}
</>}
</div>
)
}
/** A shape (6R.15) filling its box: a rectangle (rounded corners) or circle as a box, the others as SVG corners; a fill or a gradient, a border. */
function ShapeBody({ w, id }) {
const fill = w.fill || '#f59e0b'