feat(manager): the signage editor: playlists, the timeline, slides with a live preview, templates (platform-v2 step 5.6a)
Management → Signage: playlists (name, landscape / portrait, default transition, duplicate, delete with the screens it plays on); the timeline (drag or arrows to reorder, duplicate, remove, on / off, time and when it shows at a glance, a round's total time); a slide's settings (name, seconds or a video to its end, transition, days / hours / dates, the picture or video, fit, text, alignment, font, colour, size, background colour or photo with darkening; a menu board's title, columns and colours) with a live preview drawn by @xenia/signage at 1920 × 1080 and scaled down; new slides empty or from templates (promotion, announcement, happy hour 17-19, welcome, menu board, video); a warning on the slide and its card when a picture or video doesn't fit the playlist's shape. Unit tests (4), e2e signage.mjs builds a playlist in the manager and the TV plays it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { boardPages, SlideView } from '@xenia/signage'
|
||||
|
||||
const LONG = 1920
|
||||
const SHORT = 1080
|
||||
|
||||
export default function SlidePreview({ slide, media, venue, orientation = 'landscape', page = 0, playing = false, className = '', testid = 'signage-preview' }) {
|
||||
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 overflow-hidden rounded-control bg-black ${className}`} data-testid={testid} data-orientation={orientation}
|
||||
style={{ aspectRatio: tall ? '9 / 16' : '16 / 9' }}>
|
||||
{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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user