Files
xenia-pos-local/manager_dashboard/src/pages/signage/SlidePreview.jsx
T
bonaminandClaude Opus 5.5 e8c8ec825e 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>
2026-11-21 10:51:03 +02:00

52 lines
2.5 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// A slide drawn exactly as the TV draws it (@xenia/signage), in a box of the playlist's shape
// (plan step 5.6a). The slide is laid out on a full-size 1920 × 1080 (or 1080 × 1920) frame and
// scaled down to the box, so text, rows and menu pages match a real TV, not a small window.
// `editor` = { selected, onSelect, onPlace, label } (2026-11-21): the widgets can be picked, moved
// and sized on it (WidgetCanvas).
import { useEffect, useRef, useState } from 'react'
import { boardPages, SlideView, WIDGET_HOSTS } from '@xenia/signage'
import WidgetCanvas from './WidgetCanvas'
const LONG = 1920
const SHORT = 1080
export default function SlidePreview({ slide, media, venue, orientation = 'landscape', page = 0, playing = false, className = '', testid = 'signage-preview', editor = null }) {
const [now, setNow] = useState(() => new Date())
const box = useRef(null)
const [scale, setScale] = useState(0)
useEffect(() => {
const id = setInterval(() => setNow(new Date()), 1000)
return () => clearInterval(id)
}, [])
const tall = orientation === 'portrait'
const w = tall ? SHORT : LONG
const h = tall ? LONG : SHORT
useEffect(() => {
const el = box.current
if (!el) return undefined
const measure = () => setScale(el.clientWidth / w)
measure()
const ro = new ResizeObserver(measure)
ro.observe(el)
return () => ro.disconnect()
}, [w])
const pages = slide?.kind === 'menu' ? boardPages(slide, 0, w, h) : null
return (
<div ref={box} className={`relative rounded-control ${className}`} data-testid={testid} data-orientation={orientation}
style={{ aspectRatio: tall ? '9 / 16' : '16 / 9' }}>
{/* the slide is clipped to its frame; the editor's handles may stick out of it */}
<div className="absolute inset-0 overflow-hidden rounded-control bg-black">
{slide && scale > 0 && (
<div style={{ position: 'absolute', top: 0, left: 0, width: w, height: h, transform: `scale(${scale})`, transformOrigin: 'top left', containerType: 'size' }}>
<SlideView slide={slide} media={media} venue={venue} now={now} pages={pages} page={Math.min(page, (pages?.length || 1) - 1)} playing={playing} />
</div>
)}
</div>
{editor && slide && scale > 0 && WIDGET_HOSTS.includes(slide.kind) && (
<WidgetCanvas boxRef={box} widgets={slide.content?.widgets || []} selected={editor.selected} onSelect={editor.onSelect}
onPlace={editor.onPlace} onRemove={editor.onRemove} label={editor.label} />
)}
</div>
)
}