feat(signage): menus play whole rounds, seconds fields with − / +, widget limit setting, widgets as big as their content (owner review 6)
- A menu board with pages plays whole rounds (menuMs rounds its seconds up); the editor says how long it really plays under "Seconds on screen", the card and the playlist total use it. - Seconds on screen / per page: shared NumberInput (− / +, may be emptied: an error under the field and Save blocked until filled; 1 s at least, server ge=1). - Performance (Signage -> Message & settings): widgets per slide (signage.max_widgets, 10 recommended, up to 50), checked by the server (signage.too_many_widgets) and the editor. - Text, clock, date, QR, weather, logo placed by hand: the box is exactly the content (its height x text size sets the size, the width follows; handles scale keeping the shape; text size grows the box); a slide's widget may run off the slide while 5 % stays on it. - Slider: the value as close to the slider as the frame's padding; floor and table-colour sliders use the shared Slider. Timeline cards' ring no longer clipped; larger playlist buttons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -475,13 +475,35 @@
|
||||
.x-field-row--wrapped { border-color: var(--x-line); background: var(--x-surface); }
|
||||
.x-field-row--wrapped.x-field-row--shade { background: var(--x-surface-2); }
|
||||
|
||||
/* ── NumberInput (2026-11-21): a whole number with − / + on its sides ──────────── */
|
||||
.x-number {
|
||||
display: flex; align-items: stretch; width: 100%; min-width: 0; min-height: var(--x-control-md); box-sizing: border-box;
|
||||
border: var(--x-border-width) solid var(--x-line-strong); border-radius: var(--x-radius-control); background: var(--x-surface); overflow: hidden;
|
||||
}
|
||||
.x-number--sm { min-height: var(--x-control-sm); }
|
||||
.x-number:hover:not(.x-number--disabled) { border-color: var(--x-ink-3); }
|
||||
.x-number--focus { border-color: var(--x-accent); box-shadow: var(--x-focus-ring); }
|
||||
.x-number--invalid { border-color: var(--x-danger); }
|
||||
.x-number--invalid.x-number--focus { box-shadow: 0 0 0 3px rgb(var(--x-danger-rgb) / 0.3); }
|
||||
.x-number--disabled { background: var(--x-surface-2); }
|
||||
.x-number__btn {
|
||||
flex-shrink: 0; width: var(--x-control-sm); display: grid; place-items: center; border: 0; background: none; color: var(--x-ink-2); cursor: pointer;
|
||||
}
|
||||
.x-number__btn:hover:not(:disabled) { background: var(--x-surface-2); color: var(--x-ink); }
|
||||
.x-number__btn:disabled { opacity: 0.4; cursor: default; }
|
||||
.x-number__input {
|
||||
flex: 1; min-width: 0; width: 100%; border: 0; outline: none; background: transparent; color: var(--x-ink);
|
||||
font: inherit; font-size: var(--x-text-body); text-align: center; font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.x-number__suffix { align-self: center; padding-right: var(--x-space-1); color: var(--x-ink-3); font-size: var(--x-text-label); }
|
||||
|
||||
/* ── Slider (2026-11-21): framed like a field, its value beside it ──────────────── */
|
||||
.x-slider {
|
||||
min-height: var(--x-control-md); display: flex; align-items: center; gap: var(--x-space-3); padding: 0 var(--x-space-3);
|
||||
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-control); background: var(--x-surface);
|
||||
}
|
||||
.x-slider__input { flex: 1; min-width: 0; accent-color: var(--x-accent); }
|
||||
.x-slider__value { width: 3rem; text-align: right; font-size: var(--x-text-label); color: var(--x-ink-2); font-variant-numeric: tabular-nums; }
|
||||
.x-slider__value { flex-shrink: 0; text-align: right; font-size: var(--x-text-label); color: var(--x-ink-2); font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ── ColourField (2026-11-21): a colour as a field; its panel over the page ──────── */
|
||||
.x-swatch {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { useState } from 'react'
|
||||
import { cx } from '../internal/cx.js'
|
||||
import { useLabels } from './labels.js'
|
||||
|
||||
const Icon = ({ d }) => (
|
||||
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" strokeWidth="2.25" strokeLinecap="round" aria-hidden="true"><path d={d} /></svg>
|
||||
)
|
||||
|
||||
/**
|
||||
* A whole number typed or stepped with − / + on its sides (2026-11-21), as tall as an input.
|
||||
* <NumberInput value={seconds} min={1} max={3600} onChange={setSeconds} suffix="s" />
|
||||
* The field may be emptied while typing: onChange(null). The form shows its own error for an empty
|
||||
* value and keeps it from being saved. A value over `max` is brought down; under `min`, brought up
|
||||
* when the field is left. Inside a <Field> it takes the field's id.
|
||||
*/
|
||||
export function NumberInput({ value, onChange, min = 0, max = Infinity, step = 1, suffix, size = 'md', invalid = false, disabled = false, className, id, ...rest }) {
|
||||
const labels = useLabels()
|
||||
const [focus, setFocus] = useState(false)
|
||||
const n = value === '' || value == null ? null : Number(value)
|
||||
const clamp = v => Math.min(max, Math.max(min, v))
|
||||
const stepBy = d => onChange?.(clamp((n ?? min) + d))
|
||||
return (
|
||||
<span className={cx('x-number', `x-number--${size}`, (invalid || rest['aria-invalid']) && 'x-number--invalid', focus && 'x-number--focus', disabled && 'x-number--disabled', className)}>
|
||||
<button type="button" className="x-number__btn" onClick={() => stepBy(-step)} disabled={disabled || (n != null && n <= min)} aria-label={labels.decrease} tabIndex={-1}>
|
||||
<Icon d="M5 12h14" />
|
||||
</button>
|
||||
<input id={id} type="text" inputMode="numeric" className="x-number__input" value={n == null ? '' : String(n)} disabled={disabled}
|
||||
aria-invalid={invalid || undefined}
|
||||
onChange={e => {
|
||||
const digits = e.target.value.replace(/\D/g, '')
|
||||
onChange?.(digits === '' ? null : Math.min(max, Number(digits)))
|
||||
}}
|
||||
onFocus={() => setFocus(true)}
|
||||
onBlur={() => { setFocus(false); if (n != null && n < min) onChange?.(min) }}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'ArrowUp') { e.preventDefault(); stepBy(step) }
|
||||
if (e.key === 'ArrowDown') { e.preventDefault(); stepBy(-step) }
|
||||
}}
|
||||
{...rest} />
|
||||
{suffix && <span className="x-number__suffix" aria-hidden="true">{suffix}</span>}
|
||||
<button type="button" className="x-number__btn" onClick={() => stepBy(step)} disabled={disabled || (n != null && n >= max)} aria-label={labels.increase} tabIndex={-1}>
|
||||
<Icon d="M12 5v14M5 12h14" />
|
||||
</button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -11,7 +11,8 @@ export function Slider({ label, value, min = 0, max = 100, step = 1, onChange, s
|
||||
<span className="x-slider">
|
||||
<input type="range" min={min} max={max} step={step} value={value} onChange={e => onChange?.(Number(e.target.value))}
|
||||
className="x-slider__input" aria-label={label} data-testid={testId} />
|
||||
<span className="x-slider__value">{value}{suffix}</span>
|
||||
{/* as wide as its widest value, no wider: the gap to it is the frame's padding (owner review 6) */}
|
||||
<span className="x-slider__value" style={{ minWidth: `${String(max).length + String(suffix).length}ch` }}>{value}{suffix}</span>
|
||||
</span>
|
||||
</Field>
|
||||
)
|
||||
|
||||
@@ -27,6 +27,7 @@ export { ColourField, Swatch } from './components/ColourField.jsx'
|
||||
export { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './components/colour.js'
|
||||
export { FieldRow } from './components/FieldRow.jsx'
|
||||
export { Slider } from './components/Slider.jsx'
|
||||
export { NumberInput } from './components/NumberInput.jsx'
|
||||
export { IconPicker } from './components/IconPicker.jsx'
|
||||
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
||||
|
||||
Reference in New Issue
Block a user