From cd8218689cd3993ccf0d604b93bc34df0ecaeb19 Mon Sep 17 00:00:00 2001 From: bonamin Date: Mon, 23 Nov 2026 05:40:04 +0200 Subject: [PATCH] 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 --- docs/DESIGN.md | 2 +- local_backend/modules/signage/manifest.py | 11 +- local_backend/routers/signage.py | 29 ++-- local_backend/tests/test_signage_library.py | 10 ++ local_backend/tests/test_signage_shapes.py | 4 + .../src/pages/signage/CalibrateDialog.jsx | 53 ++++-- .../src/pages/signage/LookFields.jsx | 98 +++++++++++ .../src/pages/signage/MoreSettings.jsx | 63 ++----- .../src/pages/signage/MoreWidgetFields.jsx | 16 +- .../src/pages/signage/WidgetsEditor.jsx | 156 ++++++++---------- .../src/pages/signage/signageLogic.js | 14 +- manager_dashboard/tests/signage.test.mjs | 6 +- packages/i18n/locales/el/manager.json | 37 +++-- packages/i18n/locales/en/manager.json | 35 ++-- packages/signage/src/Slides.jsx | 109 +++++++----- packages/signage/src/logic.js | 9 +- packages/signage/tests/logic.test.mjs | 2 + packages/ui/src/components/NumberInput.jsx | 13 +- terminal/src/apps/signage/SignageApp.jsx | 13 +- tests/e2e/signage.mjs | 8 + 20 files changed, 431 insertions(+), 257 deletions(-) create mode 100644 manager_dashboard/src/pages/signage/LookFields.jsx diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 2466cbd..ee9f90b 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -51,7 +51,7 @@ Every page is on `` except Inventory → Stock (a placeholder). Two-column | A small panel under a button | `Popover` (`open`, `anchor` = the button's ref, `onClose`) | a colour picker, an "Add…" menu. Drawn over everything (portal), flips above, stays inside the window: **never an `absolute` panel inside a section** (it is clipped and makes the section scroll) | | A colour (a venue's: data) | `ColourField` (`auto`, `opacity`, `presets`) | a field with its swatch and code; its panel (over the page) has 12 ready colours, the picker, the opacity (`#rrggbbaa`) and the code. `auto` = a first choice that leaves it to something else ("As the slide"). **Never** a bare `` | | An icon from a set | `IconPicker` (`icons` = { key: component }) | a field showing the icon; a grid of the set over the page, "No icon" first | -| A whole number (seconds, counts) | `NumberInput` (`min`, `max`, `suffix`) | − / + on its sides, as tall as an input; it may be emptied while typing (`onChange(null)`): the form shows the error and blocks saving. **Never** clamp on every key (the user can't clear the field) | +| A whole number (seconds, counts) | `NumberInput` (`min`, `max`, `suffix`) | − / + on its sides, as tall as an input; it may be emptied while typing (`onChange(null)`): the form shows the error and blocks saving. **Never** clamp on every key (the user can't clear the field). With a `min` below 0 a minus may be typed in front | | A note in a box (what works, a caution) | `Notice` (`tone`, `title`, `icon`, `items` = [{ tone, label, text }]) | a tinted box with a bar on its left; `items` are points with a tone dot and a bold label. **Never** a local `bg-info-soft` paragraph rebuilt per page | | A slider with its value | `Slider` (`suffix`) | framed and as tall as the fields beside it; the value sits as close to it as the frame's padding. **Never** a bare `` | | Fields that should wrap | `FieldRow` (`min`, `shade` on every other row) | each field keeps its least width; a row that wraps is framed (and tinted with `shade`), a row on one line looks like any row | diff --git a/local_backend/modules/signage/manifest.py b/local_backend/modules/signage/manifest.py index 748a31a..0b4429f 100644 --- a/local_backend/modules/signage/manifest.py +++ b/local_backend/modules/signage/manifest.py @@ -33,11 +33,12 @@ MODULE = Module( ConfigField('orientation', 'enum', default='landscape', choices=('landscape', 'portrait')), ConfigField('rotation', 'int', default=0, choices=(0, 90, 180, 270)), # its picture (6R.13): a slide of another shape keeps its shape (bands) or fills the picture; - # px cut off each edge of the TV's window (set by Signage > Screens > Calibrate) + # px cut off each edge of the TV's window (set by Signage > Screens > Calibrate); below 0 the + # picture reaches past that edge of the window the TV reported (owner 2026-11-23) ConfigField('fit', 'enum', default='keep', choices=('keep', 'stretch'), group='picture'), - ConfigField('area_left', 'int', default=0, min=0, max=4000, group='picture'), - ConfigField('area_top', 'int', default=0, min=0, max=4000, group='picture'), - ConfigField('area_right', 'int', default=0, min=0, max=4000, group='picture'), - ConfigField('area_bottom', 'int', default=0, min=0, max=4000, group='picture'), + ConfigField('area_left', 'int', default=0, min=-2000, max=4000, group='picture'), + ConfigField('area_top', 'int', default=0, min=-2000, max=4000, group='picture'), + ConfigField('area_right', 'int', default=0, min=-2000, max=4000, group='picture'), + ConfigField('area_bottom', 'int', default=0, min=-2000, max=4000, group='picture'), )), ) diff --git a/local_backend/routers/signage.py b/local_backend/routers/signage.py index 951d9bb..dbcf54b 100644 --- a/local_backend/routers/signage.py +++ b/local_backend/routers/signage.py @@ -57,6 +57,7 @@ REVIEWS = "signage.reviews" # the venue's reviews, typed in by hand MAX_WIDGETS = "signage.max_widgets" # widgets a slide may hold (owner review 6: Performance; 10 recommended) MAX_WIDGETS_CAP = 50 # never more, whatever the setting AREA_MAX = 4000 # px a screen's picture area may cut off one edge (6R.13) +AREA_OUT = 2000 # px it may reach past an edge of the window the TV reported (owner 2026-11-23) AREA_KEYS = ("area_left", "area_top", "area_right", "area_bottom") CALIBRATE_S = 15 * 60 # a calibration nobody ends stops by itself _viewports: dict = {} # device id → {width, height, ratio} (what the TV reported; memory only) @@ -199,19 +200,24 @@ class MenuList(_Strict): return out +BOX_MAX = 400 # % of the slide a widget's box may reach (owner 2026-11-23) + + class Box(_Strict): """Where a widget moved by hand sits (2026-11-21): % of the slide's (or its stack place's) width / height. Owner review 6: it may run off the slide, as long as a strip of it (5 %) stays on it to - grab it back; a text, clock, QR… is as big as its content (its height sets the size).""" - x: float = Field(ge=-100, le=100) - y: float = Field(ge=-100, le=100) - w: float = Field(ge=1, le=100) - h: float = Field(ge=1, le=100) + grab it back; a text, clock, QR… is as big as its content (its height sets the size). Owner + 2026-11-23: up to four times the slide (a picture made larger than the slide is cut off at its + edges, zoomed in).""" + x: float = Field(ge=-BOX_MAX, le=100) + y: float = Field(ge=-BOX_MAX, le=100) + w: float = Field(ge=1, le=BOX_MAX) + h: float = Field(ge=1, le=BOX_MAX) @model_validator(mode="after") def _inside(self): - self.w = round(min(self.w, 100), 2) - self.h = round(min(self.h, 100), 2) + self.w = round(self.w, 2) + self.h = round(self.h, 2) self.x = round(min(max(self.x, 5 - self.w), 95), 2) self.y = round(min(max(self.y, 5 - self.h), 95), 2) return self @@ -328,6 +334,7 @@ class Widget(_Strict): gallery_seconds: int = Field(default=5, ge=3, le=120) gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade" gallery_fit: Literal["cover", "contain"] = "cover" + title_position: Literal["above", "below"] = "above" # its title (`text`) above or below the pictures (owner 2026-11-23) # more settings (6R.17), every widget: on the element that places it opacity: int = Field(default=100, ge=10, le=100) rotation: int = Field(default=0, ge=-180, le=180) @@ -578,10 +585,10 @@ class ScreenBody(BaseModel): orientation: Optional[Orientation] = None rotation: Optional[Literal[0, 90, 180, 270]] = None # its picture area (6R.13): px cut off each edge of the TV's window; how a slide of another shape fits - area_left: Optional[int] = Field(default=None, ge=0, le=AREA_MAX) - area_top: Optional[int] = Field(default=None, ge=0, le=AREA_MAX) - area_right: Optional[int] = Field(default=None, ge=0, le=AREA_MAX) - area_bottom: Optional[int] = Field(default=None, ge=0, le=AREA_MAX) + area_left: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX) + area_top: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX) + area_right: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX) + area_bottom: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX) fit: Optional[Literal["keep", "stretch"]] = None diff --git a/local_backend/tests/test_signage_library.py b/local_backend/tests/test_signage_library.py index 47f38ff..563311f 100644 --- a/local_backend/tests/test_signage_library.py +++ b/local_backend/tests/test_signage_library.py @@ -84,6 +84,16 @@ def test_blank_slides_and_widgets_placed_by_hand(client, owner_h): assert clock["size"] == "custom" and clock["box"] == {"x": 90, "y": 5, "w": 20, "h": 10} and clock["align"] == "right" assert big["box"] == {"x": 95, "y": -15, "w": 30, "h": 20} assert date["size"] == "medium" and date["box"] is None # a corner: no box, a real size + # owner 2026-11-23: a picture made larger than the slide (cut off at its edges); a gallery's title below + r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [ + {"kind": "logo", "position": "custom", "box": {"x": -60, "y": -40, "w": 220, "h": 180}}, + {"kind": "gallery", "text": "Our dishes", "title_position": "below", "position": "top-left"}]}}) + logo, gallery = r.json()["content"]["widgets"] + assert logo["box"] == {"x": -60, "y": -40, "w": 220, "h": 180} + assert gallery["text"] == "Our dishes" and gallery["title_position"] == "below" + r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [ + {"kind": "logo", "position": "custom", "box": {"x": 0, "y": 0, "w": 401, "h": 10}}]}}) + assert err(r) == "signage.content_invalid" # at most four times the slide r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"widgets": [{"kind": "clock", "position": "custom"}]}}) assert err(r) == "signage.content_invalid" # placed by hand needs its box r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"title": "x"}}) diff --git a/local_backend/tests/test_signage_shapes.py b/local_backend/tests/test_signage_shapes.py index 1bd9948..697033a 100644 --- a/local_backend/tests/test_signage_shapes.py +++ b/local_backend/tests/test_signage_shapes.py @@ -55,6 +55,10 @@ def test_a_screens_picture_area_and_calibration(client, owner_h, screens, sent): assert ("signage.calibrate", [tv["id"]]) not in sent # limits; not a screen assert client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": 5000}).status_code == 422 + # owner 2026-11-23: an edge may reach past the window the TV reported (its real picture is larger) + r = client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": -60, "area_top": 0}) + assert r.status_code == 200 and r.json()["area"]["left"] == -60 + assert client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": -2001}).status_code == 422 assert err(client.post("/api/signage/screens/99999/calibrate", headers=owner_h, json={"on": True})) == "signage.not_a_screen" # a screen can't calibrate itself or report for another assert client.post(f"/api/signage/screens/{other['id']}/calibrate", headers=tv["h"], json={"on": True}).status_code in (401, 403) diff --git a/manager_dashboard/src/pages/signage/CalibrateDialog.jsx b/manager_dashboard/src/pages/signage/CalibrateDialog.jsx index daeb5aa..6b2caf1 100644 --- a/manager_dashboard/src/pages/signage/CalibrateDialog.jsx +++ b/manager_dashboard/src/pages/signage/CalibrateDialog.jsx @@ -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 => ( - setEdge(e, v)} data-testid={`signage-calibrate-${e}`} /> + setEdge(e, v)} data-testid={`signage-calibrate-${e}`} /> ) return ( @@ -71,13 +82,17 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) { }> -
-

- {win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')} -

-
+
+
+ {t('signage.calibrate.recognised')} +

+ {win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')} +

+ {win &&

{t('signage.calibrate.recognisedHint')}

} +
+
{t('signage.calibrate.presets')} -
+
{PRESETS.map(p => (
-
+
{t('signage.calibrate.step')} ({ value: n, label: `${n} px` }))} data-testid="signage-calibrate-step" />
@@ -94,13 +109,15 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) { {edge('top')}
{edge('left')} - ) diff --git a/manager_dashboard/src/pages/signage/LookFields.jsx b/manager_dashboard/src/pages/signage/LookFields.jsx new file mode 100644 index 0000000..0bef500 --- /dev/null +++ b/manager_dashboard/src/pages/signage/LookFields.jsx @@ -0,0 +1,98 @@ +// A widget's "Text and colours" (owner review 5, 2026-11-21; owner 2026-11-23: everything about its +// text and colours in one place): its text colour (text and pictures; empty = the slide's), a plate +// behind it, its font, bold / italic / underline, text size and weight, a highlight behind the text, +// its shadow (and the shadow's colour); a QR code's dots and background; a picture's (logo, gallery) +// border. A menu, a stack and a shape have none (their own look / their main settings). +import { useState } from 'react' +import { Bold, ChevronDown, Italic, Palette, Underline } from 'lucide-react' +import { useTranslation } from '@xenia/i18n' +import { ColourField, Dropdown, Field, FieldRow, Segmented, Slider } from '@xenia/ui' +import { FONT_KEYS, FRAMED, lookKind, WIDGET_COLOURS } from './signageLogic' + +// which widgets have text (their colour, font, style, size, weight, highlight) +const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews', 'gallery'] +const WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900] + +export default function LookFields({ w, set }) { + const { t } = useTranslation('manager') + const [open, setOpen] = useState(false) + if (!lookKind(w.kind)) return null + const text = TEXT_KINDS.includes(w.kind) + const framed = FRAMED.includes(w.kind) + const m = 'signage.more' + const changed = !!(w.colour || w.background_colour || w.font || w.bold != null || w.italic || w.underline || (w.text_size && w.text_size !== 100) || w.qr_colour || w.qr_background + || w.weight || w.highlight || (w.shadow && w.shadow !== 'none') || (framed && (w.border_width || w.border_radius))) + const styles = [w.bold !== false && 'bold', w.italic && 'italic', w.underline && 'underline'].filter(Boolean) + return ( +
+ + {open && ( + + {text && set({ colour })} testId="signage-widget-colour" + auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />} + set({ background_colour })} testId="signage-widget-plate" + auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} /> + {text && <> + + set({ font: v || null })} data-testid="signage-widget-font" + options={[{ value: '', label: t('signage.widgets.asSlide') }, ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]} /> + + + set({ bold: list.includes('bold') ? null : false, italic: list.includes('italic'), underline: list.includes('underline') })} + options={[['bold', Bold], ['italic', Italic], ['underline', Underline]].map(([v, Icon]) => ( + { value: v, icon: + set({ text_size })} testId="signage-widget-text-size" /> + + set({ weight: v === '' ? null : Number(v) })} data-testid="signage-more-weight" + options={[{ value: '', label: t(`${m}.usual`) }, ...WEIGHTS.map(n => ({ value: n, label: t(`${m}.weights.${n}`) }))]} /> + + set({ highlight })} testId="signage-more-highlight" + auto={{ label: t(`${m}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} /> + } + + {(w.kind === 'qr' || w.kind === 'wifi') && <> + set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} /> + set({ qr_background })} testId="signage-widget-qr-background" /> + } + {framed && } + + )} +
+ ) +} + +/** A widget's shadow and its colour (here, or under More settings for a widget without Text and colours). */ +export function ShadowFields({ w, set }) { + const { t } = useTranslation('manager') + const m = 'signage.more' + return (<> + + set({ shadow })} data-testid="signage-more-shadow" + options={['none', 'soft', 'strong', 'glow'].map(x => ({ value: x, label: t(`${m}.shadows.${x}`) }))} /> + + {w.shadow && w.shadow !== 'none' && ( + set({ shadow_colour })} + auto={{ label: t(`${m}.usual`), on: !w.shadow_colour, pick: () => set({ shadow_colour: null }) }} /> + )} + ) +} + +/** A widget's border: its width, colour and rounded corners. */ +export function BorderFields({ w, set }) { + const { t } = useTranslation('manager') + const m = 'signage.more' + return (<> + set({ border_width })} testId="signage-more-border" /> + {w.border_width > 0 && ( + set({ border_colour })} /> + )} + set({ border_radius })} /> + ) +} diff --git a/manager_dashboard/src/pages/signage/MoreSettings.jsx b/manager_dashboard/src/pages/signage/MoreSettings.jsx index a98b102..39dbc02 100644 --- a/manager_dashboard/src/pages/signage/MoreSettings.jsx +++ b/manager_dashboard/src/pages/signage/MoreSettings.jsx @@ -2,27 +2,26 @@ // 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`). +// `animate`, `dateText`). Owner 2026-11-23: the weight, highlight and shadow moved to "Text and +// colours" (LookFields; the shadow stays here for a menu, a stack, a shape), a logo's / gallery's +// border too, the date's and clock's formats to their main settings. 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 { Dropdown, Field, FieldRow, Segmented, Slider, Switch } from '@xenia/ui' +import { BorderFields, ShadowFields } from './LookFields' import { MediaPick } from './SignageFields' -import { moreChanged, WIDGET_COLOURS } from './signageLogic' +import { FRAMED, lookKind, moreChanged } 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) + const look = lookKind(w.kind) return (
- set(i, patch)} /> - set(i, patch)} media={media} onMedia={onMedia} /> set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0} selected={selected} onSelect={onSelect} /> + set(i, patch)} /> + set(i, patch)} media={media} onMedia={onMedia} />
) @@ -179,64 +204,12 @@ function VerticalField({ w, set }) { ) } -// which widgets have text (their colour, font, style and size), a QR code's own colours, a plate -const TEXT_KINDS = ['name', 'date', 'clock', 'message', 'text', 'qr', 'weather', 'ticker', 'countdown', 'hours', 'wifi', 'contact', 'reviews'] - -/** - * A widget's own look (owner review 5), folded under "Text and colours": its colour (text and - * pictures; empty = the slide's), a plate behind it, its font, bold / italic / underline and text - * size; a QR code's dots and background. A logo has only the plate; a menu has its own look. - */ -function LookFields({ w, set }) { - const { t } = useTranslation('manager') - const [open, setOpen] = useState(false) - if (w.kind === 'menu' || w.kind === 'stack' || w.kind === 'shape') return null - const text = TEXT_KINDS.includes(w.kind) - const changed = !!(w.colour || w.background_colour || w.font || w.bold != null || w.italic || w.underline || (w.text_size && w.text_size !== 100) || w.qr_colour || w.qr_background) - const styles = [w.bold !== false && 'bold', w.italic && 'italic', w.underline && 'underline'].filter(Boolean) - return ( -
- - {open && ( - - {text && set({ colour })} testId="signage-widget-colour" - auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />} - set({ background_colour })} testId="signage-widget-plate" - auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} /> - {text && <> - - set({ font: v || null })} data-testid="signage-widget-font" - options={[{ value: '', label: t('signage.widgets.asSlide') }, ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]} /> - - - set({ bold: list.includes('bold') ? null : false, italic: list.includes('italic'), underline: list.includes('underline') })} - options={[['bold', Bold], ['italic', Italic], ['underline', Underline]].map(([v, Icon]) => ( - { value: v, icon: - set({ text_size })} testId="signage-widget-text-size" /> - } - {(w.kind === 'qr' || w.kind === 'wifi') && <> - set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} /> - set({ qr_background })} testId="signage-widget-qr-background" /> - } - - )} -
- ) -} - /** The message of the day's hint, and the message itself changed right here (owner review 5). */ function MessageHint() { const { t } = useTranslation('manager') const [open, setOpen] = useState(false) return ( -
+

{t('signage.widgets.ownTextHint')}

{open && ( @@ -252,35 +225,36 @@ function MessageHint() { /** The options only some widgets have, on the same row as where / size / alignment. */ function InlineFields({ w, set }) { const { t } = useTranslation('manager') + const m = 'signage.more' if (MORE_KINDS.includes(w.kind)) return - if (w.kind === 'message') { - return ( - - set({ text: e.target.value || null })} data-testid="signage-widget-text" /> - - ) - } - if (w.kind === 'text') { - return ( - - set({ text: e.target.value || null })} data-testid="signage-widget-own-text" /> - - ) - } if (w.kind === 'date') { - return ( - - set({ date_style })} - options={[{ value: 'long', label: t('signage.widgets.dateLong') }, { value: 'short', label: t('signage.widgets.dateShort') }]} /> + const format = w.date_format || (w.date_style === 'short' ? 'numeric' : 'long') + return (<> + + set({ date_format })} data-testid="signage-more-date-format" + options={DATE_FORMATS.map(x => ({ value: x, label: t(`${m}.dateFormats.${x}`) }))} /> - ) + {['numeric', 'numeric_short', 'iso'].includes(format) && ( + + set({ date_separator })} + options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${m}.space`) : x }))} /> + + )} + ) } if (w.kind === 'clock') { - return ( + return (<> + + set({ clock_format })} data-testid="signage-more-clock-format" + options={['24', '12'].map(x => ({ value: x, label: t(`${m}.clockFormats.${x}`) }))} /> + + + set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} /> + set({ clock_seconds: on })} label={t('signage.widgets.seconds')} data-testid="signage-widget-seconds" /> - ) + ) } if (w.kind === 'qr') { return ( @@ -323,7 +297,23 @@ function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, on
) } - if (w.kind === 'message') return + if (w.kind === 'message') { + return ( +
+ +