|
|
|
@@ -0,0 +1,121 @@
|
|
|
|
|
// "More settings" of a widget (6R.17, owner 2026-11-22), folded away like "Text and colours":
|
|
|
|
|
// for every widget its opacity, rotation (steps or any angle), shadow, border and an entrance
|
|
|
|
|
// animation; a logo's fit; for texts the weight, a highlight behind them and typing themselves out;
|
|
|
|
|
// date and clock formats; a logo in the middle of a QR code. The TV draws them (Slides.jsx `fx`,
|
|
|
|
|
// `animate`, `dateText`).
|
|
|
|
|
import { useState } from 'react'
|
|
|
|
|
import { ChevronDown, SlidersHorizontal } from 'lucide-react'
|
|
|
|
|
import { useTranslation } from '@xenia/i18n'
|
|
|
|
|
import { ColourField, Dropdown, Field, FieldRow, Segmented, Slider, Switch } from '@xenia/ui'
|
|
|
|
|
import { MediaPick } from './SignageFields'
|
|
|
|
|
import { moreChanged, WIDGET_COLOURS } from './signageLogic'
|
|
|
|
|
|
|
|
|
|
const TEXTS = ['name', 'date', 'clock', 'message', 'text', 'countdown', 'hours', 'wifi', 'contact', 'ticker', 'reviews', 'weather']
|
|
|
|
|
const TYPED = ['name', 'message', 'text']
|
|
|
|
|
const ANIMATIONS = ['none', 'fade', 'rise', 'drop', 'slide-left', 'slide-right', 'zoom', 'pop', 'pulse', 'float']
|
|
|
|
|
const DELAYS = [0, 5, 10, 15, 20, 30, 50]
|
|
|
|
|
const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900]
|
|
|
|
|
const DATE_FORMATS = ['long', 'weekday_day_month', 'day_month', 'weekday', 'numeric', 'numeric_short', 'iso']
|
|
|
|
|
|
|
|
|
|
export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
|
|
|
|
const { t } = useTranslation('manager')
|
|
|
|
|
const [open, setOpen] = useState(false)
|
|
|
|
|
const k = 'signage.more'
|
|
|
|
|
const text = TEXTS.includes(w.kind)
|
|
|
|
|
const numeric = ['numeric', 'numeric_short', 'iso'].includes(w.date_format)
|
|
|
|
|
return (
|
|
|
|
|
<div className="grid gap-2" data-testid="signage-widget-more">
|
|
|
|
|
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-more-toggle"
|
|
|
|
|
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
|
|
|
|
|
<SlidersHorizontal size={15} aria-hidden="true" />{t(`${k}.title`)}
|
|
|
|
|
{moreChanged(w) && <span className="w-1.5 h-1.5 rounded-full bg-accent" aria-hidden="true" />}
|
|
|
|
|
<ChevronDown size={15} className={`transition-transform duration-fast ${open ? 'rotate-180' : ''}`} aria-hidden="true" />
|
|
|
|
|
</button>
|
|
|
|
|
{open && (
|
|
|
|
|
<FieldRow className="-mx-3" min="11rem">
|
|
|
|
|
<Slider label={t(`${k}.opacity`)} value={w.opacity ?? 100} min={10} max={100} step={5} suffix="%" onChange={opacity => set({ opacity })} testId="signage-more-opacity" />
|
|
|
|
|
<Field label={t(`${k}.rotation`)}>
|
|
|
|
|
<Segmented fill value={[0, 90, 180, -90].includes(w.rotation || 0) ? (w.rotation || 0) : null} onChange={rotation => set({ rotation })}
|
|
|
|
|
options={[0, 90, 180, -90].map(r => ({ value: r, label: `${r}°` }))} data-testid="signage-more-rotation-steps" />
|
|
|
|
|
</Field>
|
|
|
|
|
<Slider label={t(`${k}.angle`)} value={w.rotation || 0} min={-180} max={180} step={1} suffix="°" onChange={rotation => set({ rotation })} testId="signage-more-rotation" />
|
|
|
|
|
<Field label={t(`${k}.shadow`)}>
|
|
|
|
|
<Dropdown value={w.shadow || 'none'} onChange={shadow => set({ shadow })} data-testid="signage-more-shadow"
|
|
|
|
|
options={['none', 'soft', 'strong', 'glow'].map(x => ({ value: x, label: t(`${k}.shadows.${x}`) }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
{w.shadow && w.shadow !== 'none' && (
|
|
|
|
|
<ColourField label={t(`${k}.shadowColour`)} value={w.shadow_colour || WIDGET_COLOURS.plate} onChange={shadow_colour => set({ shadow_colour })}
|
|
|
|
|
auto={{ label: t(`${k}.usual`), on: !w.shadow_colour, pick: () => set({ shadow_colour: null }) }} />
|
|
|
|
|
)}
|
|
|
|
|
<Slider label={t(`${k}.border`)} value={w.border_width || 0} min={0} max={20} onChange={border_width => set({ border_width })} testId="signage-more-border" />
|
|
|
|
|
{w.border_width > 0 && (
|
|
|
|
|
<ColourField label={t(`${k}.borderColour`)} value={w.border_colour || WIDGET_COLOURS.text} onChange={border_colour => set({ border_colour })} />
|
|
|
|
|
)}
|
|
|
|
|
<Slider label={t(`${k}.radius`)} value={w.border_radius || 0} min={0} max={100} step={5} onChange={border_radius => set({ border_radius })} />
|
|
|
|
|
<Field label={t(`${k}.animation`)}>
|
|
|
|
|
<Dropdown value={w.animation || 'none'} onChange={animation => set({ animation })} data-testid="signage-more-animation"
|
|
|
|
|
options={ANIMATIONS.map(x => ({ value: x, label: t(`${k}.animations.${x}`) }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
{w.animation && w.animation !== 'none' && !['pulse', 'float'].includes(w.animation) && (
|
|
|
|
|
<Field label={t(`${k}.delay`)}>
|
|
|
|
|
<Dropdown value={w.animation_delay || 0} onChange={v => set({ animation_delay: Number(v) })}
|
|
|
|
|
options={DELAYS.map(d => ({ value: d, label: t(`${k}.seconds`, { n: d / 10 }) }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
)}
|
|
|
|
|
{w.kind === 'logo' && (
|
|
|
|
|
<Field label={t('signage.fit')}>
|
|
|
|
|
<Dropdown value={w.fit || 'contain'} onChange={fit => set({ fit })}
|
|
|
|
|
options={['contain', 'cover', 'fill'].map(x => ({ value: x, label: t(`${k}.fits.${x}`) }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
)}
|
|
|
|
|
{text && (
|
|
|
|
|
<Field label={t(`${k}.weight`)}>
|
|
|
|
|
<Dropdown value={w.weight || ''} onChange={v => set({ weight: v === '' ? null : Number(v) })} data-testid="signage-more-weight"
|
|
|
|
|
options={[{ value: '', label: t(`${k}.usual`) }, ...WEIGHTS.map(n => ({ value: n, label: t(`${k}.weights.${n}`) }))]} />
|
|
|
|
|
</Field>
|
|
|
|
|
)}
|
|
|
|
|
{text && (
|
|
|
|
|
<ColourField label={t(`${k}.highlight`)} value={w.highlight || WIDGET_COLOURS.plate} onChange={highlight => set({ highlight })} testId="signage-more-highlight"
|
|
|
|
|
auto={{ label: t(`${k}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} />
|
|
|
|
|
)}
|
|
|
|
|
{TYPED.includes(w.kind) && (
|
|
|
|
|
<Field label={t(`${k}.typing`)}>
|
|
|
|
|
<Switch boxed className="h-control" checked={w.text_effect === 'typewriter'} onChange={on => set({ text_effect: on ? 'typewriter' : 'none' })}
|
|
|
|
|
label={t(`${k}.typewriter`)} data-testid="signage-more-typewriter" />
|
|
|
|
|
</Field>
|
|
|
|
|
)}
|
|
|
|
|
{w.kind === 'date' && (
|
|
|
|
|
<Field label={t(`${k}.dateFormat`)}>
|
|
|
|
|
<Dropdown value={w.date_format || (w.date_style === 'short' ? 'numeric' : 'long')} onChange={date_format => set({ date_format })} data-testid="signage-more-date-format"
|
|
|
|
|
options={DATE_FORMATS.map(x => ({ value: x, label: t(`${k}.dateFormats.${x}`) }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
)}
|
|
|
|
|
{w.kind === 'date' && numeric && (
|
|
|
|
|
<Field label={t(`${k}.separator`)}>
|
|
|
|
|
<Segmented fill value={w.date_separator || (w.date_format === 'iso' ? '-' : '/')} onChange={date_separator => set({ date_separator })}
|
|
|
|
|
options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${k}.space`) : x }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
)}
|
|
|
|
|
{w.kind === 'clock' && <>
|
|
|
|
|
<Field label={t(`${k}.clockFormat`)}>
|
|
|
|
|
<Segmented fill value={w.clock_format || '24'} onChange={clock_format => set({ clock_format })} data-testid="signage-more-clock-format"
|
|
|
|
|
options={['24', '12'].map(x => ({ value: x, label: t(`${k}.clockFormats.${x}`) }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
<Field label={t(`${k}.separator`)}>
|
|
|
|
|
<Segmented fill value={w.clock_separator || ':'} onChange={clock_separator => set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} />
|
|
|
|
|
</Field>
|
|
|
|
|
<Field label={t(`${k}.blink`)}>
|
|
|
|
|
<Switch boxed className="h-control" checked={!!w.clock_blink} onChange={clock_blink => set({ clock_blink })} label={t(`${k}.blinkLabel`)} />
|
|
|
|
|
</Field>
|
|
|
|
|
</>}
|
|
|
|
|
{w.kind === 'qr' && (
|
|
|
|
|
<div className="col-span-full">
|
|
|
|
|
<MediaPick kind="image" label={t(`${k}.qrLogo`)} value={w.media_id} entry={media[String(w.media_id)]} testid="signage-more-qr-logo"
|
|
|
|
|
onChange={item => { onMedia?.(item); set({ media_id: item.id }) }} onRemove={() => set({ media_id: null })} />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</FieldRow>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|