feat(signage): widget settings regrouped (main / Text and colours / More), alignment that lines up multi-line widgets, multi-line texts, gallery title, logos larger than the slide; calibration past the recognised resolution and shown the first time
Owner review 2026-11-23 of every widget: - A widget card is its main settings (the row and what needs room under it: pictures, a gallery's pictures or folder, weather details and place, a countdown's start and end, reviews' stars and author, a scrolling text's speed, a shape's colours and border, QR caption), then "Text and colours" (new LookFields.jsx: text colour, plate, font, style, size, weight, highlight, shadow, QR colours; a logo's / gallery's border), then More settings (opacity, rotation, animation, fit, typing, blink, QR logo; shadow / border only where there is no Text and colours). - Date format / separator and clock 12/24 / separator are main settings. - Alignment only where it lines something up; the TV now aligns the lines of a text, the hours (centre: days and times meet in the middle), contact rows, Wi-Fi (code left / right / above), the weather's column / card / list / hourly, reviews (stars too), a countdown, a QR caption. - Text and message: a 2-line textarea in its own row; Enter makes new lines (the TV sizes by the longest line and the number of lines). - Gallery: a title above or below the pictures (title_position). - A widget's box may reach 400 % of the slide (a logo zoomed in past the slide's edges saved again). - "Auto" stays "Auto" in Greek; scrolling text Left / Right; reviews' stars choice no longer clipped; countdown "When it ends" hint as an info tip (fields level). Calibration: an edge may go past the recognised window (down to -2000 px); the dialog's rows are centred, "Each click moves" sits above its choice, the window size is labelled "Recognised resolution" with what it means; the TV asks for its screen answer on every calibrate event and while calibrating (the outline shows the first time), the dialog sends "on" again after 1.5 s. NumberInput takes a leading minus when min < 0. E2E: waits for the Add-a-slide dialog to go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
// pixel by pixel (or in steps of 10 / 50 px), or a preset sets the largest box of a common shape in
|
||||
// the middle of the TV's window (it reports its size). Every change reaches the TV at once; closing
|
||||
// ends the calibration (the TV also stops by itself after 15 min).
|
||||
// Owner 2026-11-23: every row centred; "Each click moves" above its choice; the window size is
|
||||
// marked as the one the TV reported (recognised), and an edge may go past it (below 0 px) when the
|
||||
// TV's real picture is larger; "on" is sent again a moment after opening (the TV shows the outline
|
||||
// the first time).
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
@@ -15,6 +19,7 @@ import { ShapeMark } from './ShapeField'
|
||||
const EDGES = ['top', 'right', 'bottom', 'left']
|
||||
const PRESETS = ['full', '16:9', '16:10', '21:9', '32:9', '4:3', '9:16']
|
||||
const SAVE_MS = 200
|
||||
const OUT = 2000 // px an edge may reach past the recognised window
|
||||
|
||||
export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
const { t } = useTranslation('manager')
|
||||
@@ -30,7 +35,8 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
useEffect(() => {
|
||||
const mine = ++alive.current
|
||||
api.calibrateScreen(screen.id, true).catch(err => toast.error(errorMessage(err, t)))
|
||||
return () => { setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, false).catch(() => {}) }, 300) }
|
||||
const again = setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, true).catch(() => {}) }, 1500)
|
||||
return () => { clearTimeout(again); setTimeout(() => { if (alive.current === mine) api.calibrateScreen(screen.id, false).catch(() => {}) }, 300) }
|
||||
}, [screen.id]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||
// the TV's window size (it reports it when it starts and when it changes)
|
||||
useEffect(() => {
|
||||
@@ -54,15 +60,20 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
useEffect(() => () => clearTimeout(timer.current), [])
|
||||
const win = viewport ? { w: viewport.width, h: viewport.height } : null
|
||||
const pic = win ? pictureArea(win, area) : null
|
||||
const setEdge = (edge, v) => change({ ...area, [edge]: Math.max(0, Math.min(4000, v ?? 0)) })
|
||||
const setEdge = (edge, v) => change({ ...area, [edge]: Math.max(-OUT, Math.min(4000, v ?? 0)) })
|
||||
|
||||
// the diagram: the TV's window and the picture inside it, to scale
|
||||
// the diagram: the recognised window (dashed) and the picture, to scale; a picture reaching past
|
||||
// the window makes the drawing as large as both
|
||||
const bounds = win && pic ? {
|
||||
x: Math.min(0, pic.left), y: Math.min(0, pic.top),
|
||||
r: Math.max(win.w, pic.left + pic.width), b: Math.max(win.h, pic.top + pic.height),
|
||||
} : null
|
||||
const W = 320
|
||||
const H = win ? Math.round(W * win.h / win.w) : 180
|
||||
const k = win ? W / win.w : 0
|
||||
const H = bounds ? Math.round(W * (bounds.b - bounds.y) / (bounds.r - bounds.x)) : 180
|
||||
const k = bounds ? W / (bounds.r - bounds.x) : 0
|
||||
const edge = e => (
|
||||
<Field label={t(`signage.calibrate.edges.${e}`)} className="w-36">
|
||||
<NumberInput size="sm" value={area[e]} min={0} max={4000} step={step} suffix="px" onChange={v => setEdge(e, v)} data-testid={`signage-calibrate-${e}`} />
|
||||
<NumberInput size="sm" value={area[e]} min={-OUT} max={4000} step={step} suffix="px" onChange={v => setEdge(e, v)} data-testid={`signage-calibrate-${e}`} />
|
||||
</Field>
|
||||
)
|
||||
return (
|
||||
@@ -71,13 +82,17 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
<Button variant="secondary" onClick={() => change({ left: 0, top: 0, right: 0, bottom: 0 })} data-testid="signage-calibrate-reset">{t('signage.calibrate.reset')}</Button>
|
||||
<Button onClick={onClose} data-testid="signage-calibrate-done">{t('signage.calibrate.done')}</Button>
|
||||
</>}>
|
||||
<div className="grid gap-5" data-testid="signage-calibrate-dialog">
|
||||
<p className="text-label text-ink-2" data-testid="signage-calibrate-window">
|
||||
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
|
||||
</p>
|
||||
<div className="grid gap-2">
|
||||
<div className="grid gap-5 justify-items-center text-center" data-testid="signage-calibrate-dialog">
|
||||
<div className="grid gap-1 justify-items-center">
|
||||
<span className="text-caption font-medium text-ink-3 uppercase tracking-wide">{t('signage.calibrate.recognised')}</span>
|
||||
<p className="text-body-lg font-semibold text-ink tabular-nums" data-testid="signage-calibrate-window">
|
||||
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
|
||||
</p>
|
||||
{win && <p className="text-caption text-ink-3 max-w-md">{t('signage.calibrate.recognisedHint')}</p>}
|
||||
</div>
|
||||
<div className="grid gap-2 justify-items-center">
|
||||
<span className="text-label font-medium text-ink">{t('signage.calibrate.presets')}</span>
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
<div className="flex flex-wrap justify-center gap-1.5">
|
||||
{PRESETS.map(p => (
|
||||
<Button key={p} size="sm" variant="secondary" disabled={!win} onClick={() => change(presetInsets(win, p))} data-preset={p}
|
||||
icon={p === 'full' ? undefined : <ShapeMark shape={p} size={16} />}>
|
||||
@@ -86,7 +101,7 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<div className="grid gap-2 justify-items-center">
|
||||
<span className="text-label font-medium text-ink">{t('signage.calibrate.step')}</span>
|
||||
<Segmented value={step} onChange={setStep} options={[1, 10, 50].map(n => ({ value: n, label: `${n} px` }))} data-testid="signage-calibrate-step" />
|
||||
</div>
|
||||
@@ -94,13 +109,15 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
{edge('top')}
|
||||
<div className="flex items-center gap-3 flex-wrap justify-center">
|
||||
{edge('left')}
|
||||
<div className="relative rounded-control border border-line-strong bg-surface-2" style={{ width: W, height: H }} aria-hidden="true">
|
||||
{pic && (
|
||||
<div className="relative rounded-control bg-surface-2" style={{ width: W, height: H }} aria-hidden="true" data-testid="signage-calibrate-diagram">
|
||||
{pic && bounds && <>
|
||||
<div className="absolute border-2 border-accent bg-accent-soft grid place-items-center text-caption text-accent-ink tabular-nums"
|
||||
style={{ left: pic.left * k, top: pic.top * k, width: pic.width * k, height: pic.height * k }}>
|
||||
style={{ left: (pic.left - bounds.x) * k, top: (pic.top - bounds.y) * k, width: pic.width * k, height: pic.height * k }}>
|
||||
{Math.round(pic.width)} × {Math.round(pic.height)}
|
||||
</div>
|
||||
)}
|
||||
<div className="absolute border border-dashed border-line-strong rounded-[2px] pointer-events-none"
|
||||
style={{ left: -bounds.x * k, top: -bounds.y * k, width: win.w * k, height: win.h * k }} />
|
||||
</>}
|
||||
</div>
|
||||
{edge('right')}
|
||||
</div>
|
||||
@@ -109,7 +126,9 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||
<p className="text-label text-ink-2 text-center" data-testid="signage-calibrate-picture">
|
||||
{pic ? t('signage.calibrate.picture', { w: Math.round(pic.width), h: Math.round(pic.height), shape: shapeName(pic.width, pic.height) }) : ''}
|
||||
</p>
|
||||
<p className="text-caption text-ink-3 max-w-md">{t('signage.calibrate.edgesHint')}</p>
|
||||
{EDGES.some(e => area[e] > 0) && <p className="text-caption text-ink-3">{t('signage.calibrate.outside')}</p>}
|
||||
{EDGES.some(e => area[e] < 0) && <p className="text-caption text-warning-ink" data-testid="signage-calibrate-past">{t('signage.calibrate.past')}</p>}
|
||||
</div>
|
||||
</Dialog>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user