feat(signage): stacks, menu and text widgets, widget order (owner review 2)

- Stacks: horizontal / vertical, 2-6 parts with % shares; each part shows
  a widget, a stack one level deep, or a whole Slides-library slide
- Menu widget (a board's list in its box), text widget, weather for
  tomorrow / the day after and in picture / degrees / both styles
- Widgets' order (arrows, drag with a drop line), drawn in list order;
  arrow keys move the picked widget from its card too
- Server: extras by widget path (QR links, menus, embedded slides),
  POST /preview/slide, resolve(keep_hidden) so hidden products stay
  greyed in the editor's list; screens told when an embedded slide changes
- Editor rows tidied: framed sliders, colours as fields, text look on one
  row, Switch boxed toggles from its whole frame

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 09:44:23 +02:00
co-authored by Claude Opus 5.5
parent 83551714f7
commit 1b993e4573
23 changed files with 1231 additions and 377 deletions
+29 -1
View File
@@ -246,7 +246,13 @@ export function boardPages(slide, rotation, w, h) {
const rows = rowsPerColumn({ heightVmin: frameHeightVmin(rotation, w, h), textSize: c.text_size, photos: c.show_photos,
descriptions: c.show_descriptions, title: !!c.title, bars })
const per = c.page_size || rows * (c.columns || 2)
return menuPages(slide.menu?.groups || [], per, c.category_titles !== false)
return menuPages(visibleGroups(slide.menu?.groups), per, c.category_titles !== false)
}
/** A board's groups without the products hidden from it (the editor's list keeps them, marked
* `hidden`, 2026-11-21); groups left empty go too. */
export function visibleGroups(groups) {
return (groups || []).map(g => ({ ...g, items: (g.items || []).filter(i => !i.hidden) })).filter(g => g.items.length)
}
// ── widgets placed by hand (owner 2026-11-21) ─────────────────────────────────
@@ -254,6 +260,28 @@ export function boardPages(slide, rotation, w, h) {
/** The slide kinds that carry widgets. */
export const WIDGET_HOSTS = ['text', 'menu', 'blank']
/** A stack's parts' shares as whole percents adding up to 100 (2026-11-21). */
export function evenShares(n) {
const base = Math.floor(100 / n)
return Array.from({ length: n }, (_, i) => (i < 100 - base * n ? base + 1 : base))
}
/**
* A stack's part `i` set to `value` % (5…): the difference is taken from (or given to) the part
* after it (the one before, for the last part), which keeps at least 5 %; the shares still add up
* to 100. → the new shares.
*/
export function setShare(shares, i, value) {
const out = [...shares]
if (out.length < 2) return [100]
const j = i < out.length - 1 ? i + 1 : i - 1
const room = out[i] + out[j] - 5
const v = Math.max(5, Math.min(room, Math.round(Number(value) || 0)))
out[j] = out[i] + out[j] - v
out[i] = v
return out
}
/** How a widget lines up inside its place: its own choice, else by its corner / its box's side. */
export function widgetAlign(w) {
if (w?.align && w.align !== 'auto') return w.align