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:
+1
-1
@@ -51,7 +51,7 @@ Every page is on `<Page>` 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 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 `<input type="color">` |
|
| 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 `<input type="color">` |
|
||||||
| 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 |
|
| 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 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 `<input type="range">` |
|
| 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 `<input type="range">` |
|
||||||
| 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 |
|
| 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 |
|
||||||
|
|||||||
@@ -33,11 +33,12 @@ MODULE = Module(
|
|||||||
ConfigField('orientation', 'enum', default='landscape', choices=('landscape', 'portrait')),
|
ConfigField('orientation', 'enum', default='landscape', choices=('landscape', 'portrait')),
|
||||||
ConfigField('rotation', 'int', default=0, choices=(0, 90, 180, 270)),
|
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;
|
# 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('fit', 'enum', default='keep', choices=('keep', 'stretch'), group='picture'),
|
||||||
ConfigField('area_left', '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=0, max=4000, group='picture'),
|
ConfigField('area_top', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||||
ConfigField('area_right', 'int', default=0, min=0, max=4000, group='picture'),
|
ConfigField('area_right', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||||
ConfigField('area_bottom', 'int', default=0, min=0, max=4000, group='picture'),
|
ConfigField('area_bottom', 'int', default=0, min=-2000, max=4000, group='picture'),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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 = "signage.max_widgets" # widgets a slide may hold (owner review 6: Performance; 10 recommended)
|
||||||
MAX_WIDGETS_CAP = 50 # never more, whatever the setting
|
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_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")
|
AREA_KEYS = ("area_left", "area_top", "area_right", "area_bottom")
|
||||||
CALIBRATE_S = 15 * 60 # a calibration nobody ends stops by itself
|
CALIBRATE_S = 15 * 60 # a calibration nobody ends stops by itself
|
||||||
_viewports: dict = {} # device id → {width, height, ratio} (what the TV reported; memory only)
|
_viewports: dict = {} # device id → {width, height, ratio} (what the TV reported; memory only)
|
||||||
@@ -199,19 +200,24 @@ class MenuList(_Strict):
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
BOX_MAX = 400 # % of the slide a widget's box may reach (owner 2026-11-23)
|
||||||
|
|
||||||
|
|
||||||
class Box(_Strict):
|
class Box(_Strict):
|
||||||
"""Where a widget moved by hand sits (2026-11-21): % of the slide's (or its stack place's) width /
|
"""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
|
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)."""
|
grab it back; a text, clock, QR… is as big as its content (its height sets the size). Owner
|
||||||
x: float = Field(ge=-100, le=100)
|
2026-11-23: up to four times the slide (a picture made larger than the slide is cut off at its
|
||||||
y: float = Field(ge=-100, le=100)
|
edges, zoomed in)."""
|
||||||
w: float = Field(ge=1, le=100)
|
x: float = Field(ge=-BOX_MAX, le=100)
|
||||||
h: float = Field(ge=1, 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")
|
@model_validator(mode="after")
|
||||||
def _inside(self):
|
def _inside(self):
|
||||||
self.w = round(min(self.w, 100), 2)
|
self.w = round(self.w, 2)
|
||||||
self.h = round(min(self.h, 100), 2)
|
self.h = round(self.h, 2)
|
||||||
self.x = round(min(max(self.x, 5 - self.w), 95), 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)
|
self.y = round(min(max(self.y, 5 - self.h), 95), 2)
|
||||||
return self
|
return self
|
||||||
@@ -328,6 +334,7 @@ class Widget(_Strict):
|
|||||||
gallery_seconds: int = Field(default=5, ge=3, le=120)
|
gallery_seconds: int = Field(default=5, ge=3, le=120)
|
||||||
gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade"
|
gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade"
|
||||||
gallery_fit: Literal["cover", "contain"] = "cover"
|
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
|
# more settings (6R.17), every widget: on the element that places it
|
||||||
opacity: int = Field(default=100, ge=10, le=100)
|
opacity: int = Field(default=100, ge=10, le=100)
|
||||||
rotation: int = Field(default=0, ge=-180, le=180)
|
rotation: int = Field(default=0, ge=-180, le=180)
|
||||||
@@ -578,10 +585,10 @@ class ScreenBody(BaseModel):
|
|||||||
orientation: Optional[Orientation] = None
|
orientation: Optional[Orientation] = None
|
||||||
rotation: Optional[Literal[0, 90, 180, 270]] = 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
|
# 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_left: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||||
area_top: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
area_top: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||||
area_right: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
area_right: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||||
area_bottom: Optional[int] = Field(default=None, ge=0, le=AREA_MAX)
|
area_bottom: Optional[int] = Field(default=None, ge=-AREA_OUT, le=AREA_MAX)
|
||||||
fit: Optional[Literal["keep", "stretch"]] = None
|
fit: Optional[Literal["keep", "stretch"]] = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 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 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
|
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"}]}})
|
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
|
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"}})
|
r = client.put(f"/api/signage/slides/{s['id']}", headers=owner_h, json={"content": {"title": "x"}})
|
||||||
|
|||||||
@@ -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
|
assert ("signage.calibrate", [tv["id"]]) not in sent
|
||||||
# limits; not a screen
|
# limits; not a screen
|
||||||
assert client.put(f"/api/signage/screens/{tv['id']}", headers=owner_h, json={"area_left": 5000}).status_code == 422
|
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"
|
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
|
# 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)
|
assert client.post(f"/api/signage/screens/{other['id']}/calibrate", headers=tv["h"], json={"on": True}).status_code in (401, 403)
|
||||||
|
|||||||
@@ -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
|
// 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
|
// 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).
|
// 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 { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import { errorMessage } from '@xenia/api'
|
import { errorMessage } from '@xenia/api'
|
||||||
@@ -15,6 +19,7 @@ import { ShapeMark } from './ShapeField'
|
|||||||
const EDGES = ['top', 'right', 'bottom', 'left']
|
const EDGES = ['top', 'right', 'bottom', 'left']
|
||||||
const PRESETS = ['full', '16:9', '16:10', '21:9', '32:9', '4:3', '9:16']
|
const PRESETS = ['full', '16:9', '16:10', '21:9', '32:9', '4:3', '9:16']
|
||||||
const SAVE_MS = 200
|
const SAVE_MS = 200
|
||||||
|
const OUT = 2000 // px an edge may reach past the recognised window
|
||||||
|
|
||||||
export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
@@ -30,7 +35,8 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const mine = ++alive.current
|
const mine = ++alive.current
|
||||||
api.calibrateScreen(screen.id, true).catch(err => toast.error(errorMessage(err, t)))
|
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
|
}, [screen.id]) // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
// the TV's window size (it reports it when it starts and when it changes)
|
// the TV's window size (it reports it when it starts and when it changes)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -54,15 +60,20 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
|||||||
useEffect(() => () => clearTimeout(timer.current), [])
|
useEffect(() => () => clearTimeout(timer.current), [])
|
||||||
const win = viewport ? { w: viewport.width, h: viewport.height } : null
|
const win = viewport ? { w: viewport.width, h: viewport.height } : null
|
||||||
const pic = win ? pictureArea(win, area) : 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 W = 320
|
||||||
const H = win ? Math.round(W * win.h / win.w) : 180
|
const H = bounds ? Math.round(W * (bounds.b - bounds.y) / (bounds.r - bounds.x)) : 180
|
||||||
const k = win ? W / win.w : 0
|
const k = bounds ? W / (bounds.r - bounds.x) : 0
|
||||||
const edge = e => (
|
const edge = e => (
|
||||||
<Field label={t(`signage.calibrate.edges.${e}`)} className="w-36">
|
<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>
|
</Field>
|
||||||
)
|
)
|
||||||
return (
|
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 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>
|
<Button onClick={onClose} data-testid="signage-calibrate-done">{t('signage.calibrate.done')}</Button>
|
||||||
</>}>
|
</>}>
|
||||||
<div className="grid gap-5" data-testid="signage-calibrate-dialog">
|
<div className="grid gap-5 justify-items-center text-center" data-testid="signage-calibrate-dialog">
|
||||||
<p className="text-label text-ink-2" data-testid="signage-calibrate-window">
|
<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')}
|
{win ? t('signage.calibrate.window', { w: win.w, h: win.h, shape: shapeName(win.w, win.h) }) : t('signage.calibrate.waiting')}
|
||||||
</p>
|
</p>
|
||||||
<div className="grid gap-2">
|
{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>
|
<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 => (
|
{PRESETS.map(p => (
|
||||||
<Button key={p} size="sm" variant="secondary" disabled={!win} onClick={() => change(presetInsets(win, p))} data-preset={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} />}>
|
icon={p === 'full' ? undefined : <ShapeMark shape={p} size={16} />}>
|
||||||
@@ -86,7 +101,7 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</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>
|
<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" />
|
<Segmented value={step} onChange={setStep} options={[1, 10, 50].map(n => ({ value: n, label: `${n} px` }))} data-testid="signage-calibrate-step" />
|
||||||
</div>
|
</div>
|
||||||
@@ -94,13 +109,15 @@ export default function CalibrateDialog({ screen, onClose, onSaved }) {
|
|||||||
{edge('top')}
|
{edge('top')}
|
||||||
<div className="flex items-center gap-3 flex-wrap justify-center">
|
<div className="flex items-center gap-3 flex-wrap justify-center">
|
||||||
{edge('left')}
|
{edge('left')}
|
||||||
<div className="relative rounded-control border border-line-strong bg-surface-2" style={{ width: W, height: H }} aria-hidden="true">
|
<div className="relative rounded-control bg-surface-2" style={{ width: W, height: H }} aria-hidden="true" data-testid="signage-calibrate-diagram">
|
||||||
{pic && (
|
{pic && bounds && <>
|
||||||
<div className="absolute border-2 border-accent bg-accent-soft grid place-items-center text-caption text-accent-ink tabular-nums"
|
<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)}
|
{Math.round(pic.width)} × {Math.round(pic.height)}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
{edge('right')}
|
{edge('right')}
|
||||||
</div>
|
</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">
|
<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) }) : ''}
|
{pic ? t('signage.calibrate.picture', { w: Math.round(pic.width), h: Math.round(pic.height), shape: shapeName(pic.width, pic.height) }) : ''}
|
||||||
</p>
|
</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-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>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<div className="grid gap-2" data-testid="signage-widget-look">
|
||||||
|
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-look-toggle"
|
||||||
|
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
|
||||||
|
<Palette size={15} aria-hidden="true" />{t('signage.widgets.look')}
|
||||||
|
{changed && <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="10rem">
|
||||||
|
{text && <ColourField label={t('signage.widgets.colour')} value={w.colour || WIDGET_COLOURS.text} onChange={colour => set({ colour })} testId="signage-widget-colour"
|
||||||
|
auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />}
|
||||||
|
<ColourField label={t('signage.widgets.plate')} value={w.background_colour || WIDGET_COLOURS.plate} onChange={background_colour => set({ background_colour })} testId="signage-widget-plate"
|
||||||
|
auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} />
|
||||||
|
{text && <>
|
||||||
|
<Field label={t('signage.font')}>
|
||||||
|
<Dropdown value={w.font || ''} onChange={v => 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}`) }))]} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t('signage.look.f.widget.style')}>
|
||||||
|
<Segmented multiple fill value={styles} data-testid="signage-widget-style"
|
||||||
|
onChange={list => 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: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.look.${v}`), testId: `signage-widget-${v}` }))} />
|
||||||
|
</Field>
|
||||||
|
<Slider label={t('signage.widgets.textSize')} value={w.text_size || 100} min={50} max={200} step={10} suffix="%" onChange={text_size => set({ text_size })} testId="signage-widget-text-size" />
|
||||||
|
<Field label={t(`${m}.weight`)}>
|
||||||
|
<Dropdown value={w.weight || ''} onChange={v => 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}`) }))]} />
|
||||||
|
</Field>
|
||||||
|
<ColourField label={t(`${m}.highlight`)} value={w.highlight || WIDGET_COLOURS.plate} onChange={highlight => set({ highlight })} testId="signage-more-highlight"
|
||||||
|
auto={{ label: t(`${m}.noHighlight`), on: !w.highlight, pick: () => set({ highlight: null }) }} />
|
||||||
|
</>}
|
||||||
|
<ShadowFields w={w} set={set} />
|
||||||
|
{(w.kind === 'qr' || w.kind === 'wifi') && <>
|
||||||
|
<ColourField label={t('signage.widgets.qrColour')} value={w.qr_colour || WIDGET_COLOURS.qr} onChange={qr_colour => set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} />
|
||||||
|
<ColourField label={t('signage.widgets.qrBackground')} value={w.qr_background || WIDGET_COLOURS.qrBackground} onChange={qr_background => set({ qr_background })} testId="signage-widget-qr-background" />
|
||||||
|
</>}
|
||||||
|
{framed && <BorderFields w={w} set={set} />}
|
||||||
|
</FieldRow>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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 (<>
|
||||||
|
<Field label={t(`${m}.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(`${m}.shadows.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
{w.shadow && w.shadow !== 'none' && (
|
||||||
|
<ColourField label={t(`${m}.shadowColour`)} value={w.shadow_colour || WIDGET_COLOURS.plate} onChange={shadow_colour => 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 (<>
|
||||||
|
<Slider label={t(`${m}.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(`${m}.borderColour`)} value={w.border_colour || WIDGET_COLOURS.text} onChange={border_colour => set({ border_colour })} />
|
||||||
|
)}
|
||||||
|
<Slider label={t(`${m}.radius`)} value={w.border_radius || 0} min={0} max={100} step={5} onChange={border_radius => set({ border_radius })} />
|
||||||
|
</>)
|
||||||
|
}
|
||||||
@@ -2,27 +2,26 @@
|
|||||||
// for every widget its opacity, rotation (steps or any angle), shadow, border and an entrance
|
// 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;
|
// 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`,
|
// 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 { useState } from 'react'
|
||||||
import { ChevronDown, SlidersHorizontal } from 'lucide-react'
|
import { ChevronDown, SlidersHorizontal } from 'lucide-react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
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 { 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 TYPED = ['name', 'message', 'text']
|
||||||
const ANIMATIONS = ['none', 'fade', 'rise', 'drop', 'slide-left', 'slide-right', 'zoom', 'pop', 'pulse', 'float']
|
const ANIMATIONS = ['none', 'fade', 'rise', 'drop', 'slide-left', 'slide-right', 'zoom', 'pop', 'pulse', 'float']
|
||||||
const DELAYS = [0, 5, 10, 15, 20, 30, 50]
|
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 }) {
|
export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const k = 'signage.more'
|
const k = 'signage.more'
|
||||||
const text = TEXTS.includes(w.kind)
|
const look = lookKind(w.kind)
|
||||||
const numeric = ['numeric', 'numeric_short', 'iso'].includes(w.date_format)
|
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-2" data-testid="signage-widget-more">
|
<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"
|
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-more-toggle"
|
||||||
@@ -39,19 +38,8 @@ export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
|||||||
options={[0, 90, 180, -90].map(r => ({ value: r, label: `${r}°` }))} data-testid="signage-more-rotation-steps" />
|
options={[0, 90, 180, -90].map(r => ({ value: r, label: `${r}°` }))} data-testid="signage-more-rotation-steps" />
|
||||||
</Field>
|
</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" />
|
<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`)}>
|
{!look && <ShadowFields w={w} set={set} />}
|
||||||
<Dropdown value={w.shadow || 'none'} onChange={shadow => set({ shadow })} data-testid="signage-more-shadow"
|
{!FRAMED.includes(w.kind) && <BorderFields w={w} set={set} />}
|
||||||
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`)}>
|
<Field label={t(`${k}.animation`)}>
|
||||||
<Dropdown value={w.animation || 'none'} onChange={animation => set({ animation })} data-testid="signage-more-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}`) }))} />
|
options={ANIMATIONS.map(x => ({ value: x, label: t(`${k}.animations.${x}`) }))} />
|
||||||
@@ -68,46 +56,17 @@ export default function MoreSettings({ w, set, media = {}, onMedia }) {
|
|||||||
options={['contain', 'cover', 'fill'].map(x => ({ value: x, label: t(`${k}.fits.${x}`) }))} />
|
options={['contain', 'cover', 'fill'].map(x => ({ value: x, label: t(`${k}.fits.${x}`) }))} />
|
||||||
</Field>
|
</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) && (
|
{TYPED.includes(w.kind) && (
|
||||||
<Field label={t(`${k}.typing`)}>
|
<Field label={t(`${k}.typing`)}>
|
||||||
<Switch boxed className="h-control" checked={w.text_effect === 'typewriter'} onChange={on => set({ text_effect: on ? 'typewriter' : 'none' })}
|
<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" />
|
label={t(`${k}.typewriter`)} data-testid="signage-more-typewriter" />
|
||||||
</Field>
|
</Field>
|
||||||
)}
|
)}
|
||||||
{w.kind === 'date' && (
|
{w.kind === 'clock' && (
|
||||||
<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`)}>
|
<Field label={t(`${k}.blink`)}>
|
||||||
<Switch boxed className="h-control" checked={!!w.clock_blink} onChange={clock_blink => set({ clock_blink })} label={t(`${k}.blinkLabel`)} />
|
<Switch boxed className="h-control" checked={!!w.clock_blink} onChange={clock_blink => set({ clock_blink })} label={t(`${k}.blinkLabel`)} />
|
||||||
</Field>
|
</Field>
|
||||||
</>}
|
)}
|
||||||
{w.kind === 'qr' && (
|
{w.kind === 'qr' && (
|
||||||
<div className="col-span-full">
|
<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"
|
<MediaPick kind="image" label={t(`${k}.qrLogo`)} value={w.media_id} entry={media[String(w.media_id)]} testid="signage-more-qr-logo"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react'
|
|||||||
import { ArrowLeft, ArrowRight, Film, Plus, X } from 'lucide-react'
|
import { ArrowLeft, ArrowRight, Film, Plus, X } from 'lucide-react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { Button, ColourField, Dropdown, Field, IconButton, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
|
import { Button, ColourField, Dropdown, Field, IconButton, InfoTip, Input, Notice, NumberInput, Segmented, Slider, Switch } from '@xenia/ui'
|
||||||
import { listFolders } from '../media/mediaApi'
|
import { listFolders } from '../media/mediaApi'
|
||||||
import MediaPicker from '../media/MediaPicker'
|
import MediaPicker from '../media/MediaPicker'
|
||||||
import { useHours, useIdentity } from '../../shell/useIdentity'
|
import { useHours, useIdentity } from '../../shell/useIdentity'
|
||||||
@@ -84,7 +84,7 @@ export function MoreInlineFields({ w, set }) {
|
|||||||
}
|
}
|
||||||
if (w.kind === 'gallery') {
|
if (w.kind === 'gallery') {
|
||||||
return (<>
|
return (<>
|
||||||
<Field label={t(`${k}.gallery.source`)}>
|
<Field label={t(`${k}.gallery.source`)} className="col-span-2">
|
||||||
<Segmented fill value={w.gallery_source || 'pictures'} onChange={gallery_source => set({ gallery_source })} data-testid="signage-widget-gallery-source"
|
<Segmented fill value={w.gallery_source || 'pictures'} onChange={gallery_source => set({ gallery_source })} data-testid="signage-widget-gallery-source"
|
||||||
options={['pictures', 'folder'].map(v => ({ value: v, label: t(`${k}.gallery.sources.${v}`) }))} />
|
options={['pictures', 'folder'].map(v => ({ value: v, label: t(`${k}.gallery.sources.${v}`) }))} />
|
||||||
</Field>
|
</Field>
|
||||||
@@ -99,11 +99,19 @@ export function MoreInlineFields({ w, set }) {
|
|||||||
<Dropdown value={w.gallery_fit || 'cover'} onChange={gallery_fit => set({ gallery_fit })}
|
<Dropdown value={w.gallery_fit || 'cover'} onChange={gallery_fit => set({ gallery_fit })}
|
||||||
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
|
options={[{ value: 'cover', label: t('signage.fits.cover') }, { value: 'contain', label: t('signage.fits.contain') }]} />
|
||||||
</Field>
|
</Field>
|
||||||
|
{/* its title, above or below the pictures (owner 2026-11-23) */}
|
||||||
|
<Field label={t(`${k}.gallery.title`)}>
|
||||||
|
<Input value={w.text || ''} maxLength={120} placeholder={t(`${k}.gallery.titlePlaceholder`)} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-gallery-title" />
|
||||||
|
</Field>
|
||||||
|
<Field label={t(`${k}.gallery.titleAt`)}>
|
||||||
|
<Segmented fill value={w.title_position || 'above'} onChange={title_position => set({ title_position })} data-testid="signage-widget-gallery-title-at"
|
||||||
|
options={['above', 'below'].map(v => ({ value: v, label: t(`${k}.gallery.titleAts.${v}`) }))} />
|
||||||
|
</Field>
|
||||||
</>)
|
</>)
|
||||||
}
|
}
|
||||||
if (w.kind === 'reviews') {
|
if (w.kind === 'reviews') {
|
||||||
return (<>
|
return (<>
|
||||||
<Field label={t(`${k}.reviews.min`)}>
|
<Field label={t(`${k}.reviews.min`)} className="col-span-2">
|
||||||
<Segmented fill value={w.reviews_min || 4} onChange={reviews_min => set({ reviews_min })} data-testid="signage-widget-reviews-min"
|
<Segmented fill value={w.reviews_min || 4} onChange={reviews_min => set({ reviews_min })} data-testid="signage-widget-reviews-min"
|
||||||
options={[1, 2, 3, 4, 5].map(n => ({ value: n, label: `${n}+` }))} />
|
options={[1, 2, 3, 4, 5].map(n => ({ value: n, label: `${n}+` }))} />
|
||||||
</Field>
|
</Field>
|
||||||
@@ -176,7 +184,7 @@ export function MoreBelowFields({ w, set, media = {}, onMedia }) {
|
|||||||
options={['full', 'hide'].map(v => ({ value: v, label: t(`${k}.countdown.waitingModes.${v}`) }))} />
|
options={['full', 'hide'].map(v => ({ value: v, label: t(`${k}.countdown.waitingModes.${v}`) }))} />
|
||||||
</Field>
|
</Field>
|
||||||
)}
|
)}
|
||||||
<Field label={t(`${k}.countdown.done`)} hint={t(`${k}.countdown.doneHint`)}>
|
<Field label={t(`${k}.countdown.done`)} info={<InfoTip>{t(`${k}.countdown.doneHint`)}</InfoTip>}>
|
||||||
<Input value={w.countdown_done || ''} maxLength={80} placeholder={t(`${k}.countdown.donePlaceholder`)} onChange={e => set({ countdown_done: e.target.value || null, countdown_done_hide: !e.target.value })} />
|
<Input value={w.countdown_done || ''} maxLength={80} placeholder={t(`${k}.countdown.donePlaceholder`)} onChange={e => set({ countdown_done: e.target.value || null, countdown_done_hide: !e.target.value })} />
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -24,24 +24,32 @@
|
|||||||
// in layers: the card at the top is the widget drawn over the others, so a new widget goes on top
|
// in layers: the card at the top is the widget drawn over the others, so a new widget goes on top
|
||||||
// (last in the slide's list, first here); the arrows bring a widget forward / send it backward.
|
// (last in the slide's list, first here); the arrows bring a widget forward / send it backward.
|
||||||
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
|
// Up to the venue's limit (10 recommended; Signage → Message & settings → Performance).
|
||||||
|
// Owner 2026-11-23: a card is its main settings (the row and what needs more room under it: a
|
||||||
|
// picture, a gallery's pictures, the weather's details, a countdown's start and end…), then "Text
|
||||||
|
// and colours" (LookFields: every text, colour, shadow and highlight setting), then More settings.
|
||||||
|
// Alignment only where it lines something up: texts of several lines (Enter makes a new line in a
|
||||||
|
// text or the message), the hours, contact details, Wi-Fi (its code left / right / above), the
|
||||||
|
// weather laid out in rows, reviews, a countdown's title, a QR's caption, a gallery's title; inside
|
||||||
|
// a stack's part it also places the widget in its part.
|
||||||
import { Fragment, useEffect, useRef, useState } from 'react'
|
import { Fragment, useEffect, useRef, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, Bold, Italic, Palette, RotateCcw, Underline, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
AlignCenter, AlignLeft, AlignRight, AlignVerticalJustifyCenter, AlignVerticalJustifyEnd, AlignVerticalJustifyStart, ArrowDown, ArrowUp, RotateCcw, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
||||||
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
|
ImageIcon, LayoutList, MessageSquare, Plus, QrCode, Rows3, Store, Trash2, Type, UtensilsCrossed,
|
||||||
CalendarClock, Contact, GalleryHorizontal, MessageSquareQuote, MoveHorizontal, Shapes, Timer, Wifi,
|
CalendarClock, Contact, GalleryHorizontal, MessageSquareQuote, MoveHorizontal, Shapes, Timer, Wifi,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
|
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { Button, ColourField, Dialog, Dropdown, Field, FieldRow, IconButton, Input, Popover, Segmented, Slider, Switch } from '@xenia/ui'
|
import { Button, Dialog, Dropdown, Field, IconButton, Input, Popover, Segmented, Switch, Textarea } from '@xenia/ui'
|
||||||
import MessageOfTheDay from './MessageOfTheDay'
|
import MessageOfTheDay from './MessageOfTheDay'
|
||||||
import { usePerformance } from './usePerformance'
|
import { usePerformance } from './usePerformance'
|
||||||
import * as api from './signageApi'
|
import * as api from './signageApi'
|
||||||
|
import LookFields from './LookFields'
|
||||||
import MenuEditor from './MenuEditor'
|
import MenuEditor from './MenuEditor'
|
||||||
import MoreSettings from './MoreSettings'
|
import MoreSettings from './MoreSettings'
|
||||||
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
|
import { MoreBelowFields as MoreBelow, MoreInlineFields as MoreInline } from './MoreWidgetFields'
|
||||||
import { MediaPick, Section } from './SignageFields'
|
import { MediaPick, Section } from './SignageFields'
|
||||||
import {
|
import {
|
||||||
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, FONT_KEYS, WIDGET_COLOURS, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
|
CELL_KINDS, cellWidget, WEATHER_DETAILS, WEATHER_LAYOUTS, fillPlace, moved, newWidget, pickedAfterMove, presetWidget, WEATHER_CHOICES, weatherChoice, WIDGET_KINDS, WIDGET_POSITIONS,
|
||||||
} from './signageLogic'
|
} from './signageLogic'
|
||||||
|
|
||||||
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
|
const ICON = { logo: ImageIcon, name: Store, date: CalendarDays, clock: Clock, message: MessageSquare, text: Type, qr: QrCode, weather: CloudSun, menu: UtensilsCrossed, hstack: Columns3, vstack: Rows3,
|
||||||
@@ -50,6 +58,23 @@ const MORE_KINDS = ['shape', 'ticker', 'countdown', 'hours', 'wifi', 'contact',
|
|||||||
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
|
const iconOf = w => (w.kind === 'stack' ? (w.direction === 'column' ? Rows3 : Columns3) : ICON[w.kind] || LayoutList)
|
||||||
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
|
const kindLabel = (t, w) => t(`signage.widgets.kinds.${w.kind === 'stack' ? (w.direction === 'column' ? 'vstack' : 'hstack') : w.kind}`)
|
||||||
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
|
const ROW = 'grid gap-4 items-end grid-cols-[repeat(auto-fill,minmax(11rem,1fr))]'
|
||||||
|
const DATE_FORMATS = ['long', 'weekday_day_month', 'day_month', 'weekday', 'numeric', 'numeric_short', 'iso']
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the alignment lines something up (owner 2026-11-23): a widget of several lines or parts;
|
||||||
|
* one line (a name, date, clock), a picture, a scrolling text, a shape, a menu or a stack: no (each
|
||||||
|
* is exactly as big as what it shows, or fills its place). In a stack's part it also places the
|
||||||
|
* widget in its part, so there every widget but a stack, a menu, a scrolling text and a shape has it.
|
||||||
|
*/
|
||||||
|
function alignable(w, inPart = false) {
|
||||||
|
if (['stack', 'menu', 'ticker', 'shape'].includes(w.kind)) return false
|
||||||
|
if (inPart) return true
|
||||||
|
if (['logo', 'name', 'date', 'clock'].includes(w.kind)) return false
|
||||||
|
if (w.kind === 'weather') return (w.weather_layout || 'row') !== 'row'
|
||||||
|
if (w.kind === 'gallery' || w.kind === 'countdown') return !!w.text
|
||||||
|
if (w.kind === 'qr') return !!w.qr_caption
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
let library = null // the Slides library (for stacks' parts), read once
|
let library = null // the Slides library (for stacks' parts), read once
|
||||||
|
|
||||||
@@ -135,13 +160,13 @@ export default function WidgetsEditor({ widgets = [], onChange, media, onMedia,
|
|||||||
options={[...['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) })),
|
options={[...['small', 'medium', 'large'].map(s => ({ value: s, label: t(`signage.widgets.sizes.${s}`) })),
|
||||||
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
|
...(custom ? [{ value: 'custom', label: t('signage.widgets.custom') }] : [])]} />
|
||||||
</Field>
|
</Field>
|
||||||
{w.kind !== 'stack' && <AlignField w={w} set={patch => set(i, patch)} />}
|
{alignable(w) && <AlignField w={w} set={patch => set(i, patch)} />}
|
||||||
<InlineFields w={w} set={patch => set(i, patch)} />
|
<InlineFields w={w} set={patch => set(i, patch)} />
|
||||||
</div>
|
</div>
|
||||||
<LookFields w={w} set={patch => set(i, patch)} />
|
|
||||||
<MoreSettings w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
|
|
||||||
<BelowFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0}
|
<BelowFields w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} extras={extras} path={String(i)} depth={0}
|
||||||
selected={selected} onSelect={onSelect} />
|
selected={selected} onSelect={onSelect} />
|
||||||
|
<LookFields w={w} set={patch => set(i, patch)} />
|
||||||
|
<MoreSettings w={w} set={patch => set(i, patch)} media={media} onMedia={onMedia} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -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 (
|
|
||||||
<div className="grid gap-2" data-testid="signage-widget-look">
|
|
||||||
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-widget-look-toggle"
|
|
||||||
className="justify-self-start flex items-center gap-1.5 text-label font-medium text-ink-2 hover:text-ink">
|
|
||||||
<Palette size={15} aria-hidden="true" />{t(text ? 'signage.widgets.look' : 'signage.widgets.plateOnly')}
|
|
||||||
{changed && <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="10rem">
|
|
||||||
{text && <ColourField label={t('signage.widgets.colour')} value={w.colour || WIDGET_COLOURS.text} onChange={colour => set({ colour })} testId="signage-widget-colour"
|
|
||||||
auto={{ label: t('signage.widgets.asSlide'), on: !w.colour, pick: () => set({ colour: null }) }} />}
|
|
||||||
<ColourField label={t('signage.widgets.plate')} value={w.background_colour || WIDGET_COLOURS.plate} onChange={background_colour => set({ background_colour })} testId="signage-widget-plate"
|
|
||||||
auto={{ label: t('signage.widgets.noPlate'), on: !w.background_colour, pick: () => set({ background_colour: null }) }} />
|
|
||||||
{text && <>
|
|
||||||
<Field label={t('signage.font')}>
|
|
||||||
<Dropdown value={w.font || ''} onChange={v => 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}`) }))]} />
|
|
||||||
</Field>
|
|
||||||
<Field label={t('signage.look.f.widget.style')}>
|
|
||||||
<Segmented multiple fill value={styles} data-testid="signage-widget-style"
|
|
||||||
onChange={list => 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: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.look.${v}`), testId: `signage-widget-${v}` }))} />
|
|
||||||
</Field>
|
|
||||||
<Slider label={t('signage.widgets.textSize')} value={w.text_size || 100} min={50} max={200} step={10} suffix="%" onChange={text_size => set({ text_size })} testId="signage-widget-text-size" />
|
|
||||||
</>}
|
|
||||||
{(w.kind === 'qr' || w.kind === 'wifi') && <>
|
|
||||||
<ColourField label={t('signage.widgets.qrColour')} value={w.qr_colour || WIDGET_COLOURS.qr} onChange={qr_colour => set({ qr_colour })} testId="signage-widget-qr-colour" opacity={false} />
|
|
||||||
<ColourField label={t('signage.widgets.qrBackground')} value={w.qr_background || WIDGET_COLOURS.qrBackground} onChange={qr_background => set({ qr_background })} testId="signage-widget-qr-background" />
|
|
||||||
</>}
|
|
||||||
</FieldRow>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The message of the day's hint, and the message itself changed right here (owner review 5). */
|
/** The message of the day's hint, and the message itself changed right here (owner review 5). */
|
||||||
function MessageHint() {
|
function MessageHint() {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap items-center gap-2 -mt-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<p className="text-caption text-ink-3 flex-1 min-w-[12rem]">{t('signage.widgets.ownTextHint')}</p>
|
<p className="text-caption text-ink-3 flex-1 min-w-[12rem]">{t('signage.widgets.ownTextHint')}</p>
|
||||||
<Button size="sm" variant="secondary" onClick={() => setOpen(true)} data-testid="signage-widget-message-open">{t('signage.widgets.changeMessage')}</Button>
|
<Button size="sm" variant="secondary" onClick={() => setOpen(true)} data-testid="signage-widget-message-open">{t('signage.widgets.changeMessage')}</Button>
|
||||||
{open && (
|
{open && (
|
||||||
@@ -252,35 +225,36 @@ function MessageHint() {
|
|||||||
/** The options only some widgets have, on the same row as where / size / alignment. */
|
/** The options only some widgets have, on the same row as where / size / alignment. */
|
||||||
function InlineFields({ w, set }) {
|
function InlineFields({ w, set }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
|
const m = 'signage.more'
|
||||||
if (MORE_KINDS.includes(w.kind)) return <MoreInline w={w} set={set} />
|
if (MORE_KINDS.includes(w.kind)) return <MoreInline w={w} set={set} />
|
||||||
if (w.kind === 'message') {
|
|
||||||
return (
|
|
||||||
<Field label={t('signage.widgets.ownText')} className="col-span-2">
|
|
||||||
<Input value={w.text || ''} maxLength={200} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (w.kind === 'text') {
|
|
||||||
return (
|
|
||||||
<Field label={t('signage.widgets.theText')} className="col-span-2">
|
|
||||||
<Input value={w.text || ''} maxLength={200} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
|
|
||||||
</Field>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (w.kind === 'date') {
|
if (w.kind === 'date') {
|
||||||
return (
|
const format = w.date_format || (w.date_style === 'short' ? 'numeric' : 'long')
|
||||||
<Field label={t('signage.widgets.dateStyle')}>
|
return (<>
|
||||||
<Dropdown value={w.date_style || 'long'} onChange={date_style => set({ date_style })}
|
<Field label={t(`${m}.dateFormat`)} className="col-span-2">
|
||||||
options={[{ value: 'long', label: t('signage.widgets.dateLong') }, { value: 'short', label: t('signage.widgets.dateShort') }]} />
|
<Dropdown value={format} onChange={date_format => set({ date_format })} data-testid="signage-more-date-format"
|
||||||
|
options={DATE_FORMATS.map(x => ({ value: x, label: t(`${m}.dateFormats.${x}`) }))} />
|
||||||
</Field>
|
</Field>
|
||||||
)
|
{['numeric', 'numeric_short', 'iso'].includes(format) && (
|
||||||
|
<Field label={t(`${m}.separator`)}>
|
||||||
|
<Segmented fill value={w.date_separator || (format === 'iso' ? '-' : '/')} onChange={date_separator => set({ date_separator })}
|
||||||
|
options={['/', '.', '-', ' '].map(x => ({ value: x, label: x === ' ' ? t(`${m}.space`) : x }))} />
|
||||||
|
</Field>
|
||||||
|
)}
|
||||||
|
</>)
|
||||||
}
|
}
|
||||||
if (w.kind === 'clock') {
|
if (w.kind === 'clock') {
|
||||||
return (
|
return (<>
|
||||||
|
<Field label={t(`${m}.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(`${m}.clockFormats.${x}`) }))} />
|
||||||
|
</Field>
|
||||||
|
<Field label={t(`${m}.separator`)}>
|
||||||
|
<Segmented fill value={w.clock_separator || ':'} onChange={clock_separator => set({ clock_separator })} options={[':', '.'].map(x => ({ value: x, label: x }))} />
|
||||||
|
</Field>
|
||||||
<Field label={t('signage.widgets.clockShows')}>
|
<Field label={t('signage.widgets.clockShows')}>
|
||||||
<Switch boxed className="h-control" checked={!!w.clock_seconds} onChange={on => set({ clock_seconds: on })} label={t('signage.widgets.seconds')} data-testid="signage-widget-seconds" />
|
<Switch boxed className="h-control" checked={!!w.clock_seconds} onChange={on => set({ clock_seconds: on })} label={t('signage.widgets.seconds')} data-testid="signage-widget-seconds" />
|
||||||
</Field>
|
</Field>
|
||||||
)
|
</>)
|
||||||
}
|
}
|
||||||
if (w.kind === 'qr') {
|
if (w.kind === 'qr') {
|
||||||
return (
|
return (
|
||||||
@@ -323,7 +297,23 @@ function BelowFields({ w, set, media, onMedia, extras, path, depth, selected, on
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (w.kind === 'message') return <MessageHint />
|
if (w.kind === 'message') {
|
||||||
|
return (
|
||||||
|
<div className="grid gap-3">
|
||||||
|
<Field label={t('signage.widgets.ownText')} hint={t('signage.widgets.enterHint')}>
|
||||||
|
<Textarea rows={2} value={w.text || ''} maxLength={500} placeholder={t('signage.widgets.ownTextPlaceholder')} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-text" />
|
||||||
|
</Field>
|
||||||
|
<MessageHint />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (w.kind === 'text') {
|
||||||
|
return (
|
||||||
|
<Field label={t('signage.widgets.theText')} hint={t('signage.widgets.enterHint')}>
|
||||||
|
<Textarea rows={2} value={w.text || ''} maxLength={500} onChange={e => set({ text: e.target.value || null })} data-testid="signage-widget-own-text" />
|
||||||
|
</Field>
|
||||||
|
)
|
||||||
|
}
|
||||||
if (w.kind === 'weather') {
|
if (w.kind === 'weather') {
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-3">
|
<div className="grid gap-3">
|
||||||
@@ -488,14 +478,14 @@ function StackFields({ w, set, media, onMedia, extras, path, depth, selected, on
|
|||||||
? <Button variant="secondary" icon={<RotateCcw size={14} />} onClick={() => setW(fillPlace(x))} data-testid="signage-cell-fill">{t('signage.widgets.backInPlace')}</Button>
|
? <Button variant="secondary" icon={<RotateCcw size={14} />} onClick={() => setW(fillPlace(x))} data-testid="signage-cell-fill">{t('signage.widgets.backInPlace')}</Button>
|
||||||
: <span className="h-control flex items-center text-label text-ink-2" data-testid="signage-cell-place">{t('signage.widgets.fillsPlace')}</span>}
|
: <span className="h-control flex items-center text-label text-ink-2" data-testid="signage-cell-place">{t('signage.widgets.fillsPlace')}</span>}
|
||||||
</Field>
|
</Field>
|
||||||
<AlignField w={x} set={setW} testid="signage-cell-align" />
|
{alignable(x, true) && <AlignField w={x} set={setW} testid="signage-cell-align" />}
|
||||||
<VerticalField w={x} set={setW} />
|
<VerticalField w={x} set={setW} />
|
||||||
<InlineFields w={x} set={setW} />
|
<InlineFields w={x} set={setW} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
|
||||||
<LookFields w={x} set={setW} />
|
<LookFields w={x} set={setW} />
|
||||||
<MoreSettings w={x} set={setW} media={media} onMedia={onMedia} />
|
<MoreSettings w={x} set={setW} media={media} onMedia={onMedia} />
|
||||||
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={wp} depth={depth + 1} selected={selected} onSelect={onSelect} />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -417,8 +417,16 @@ export const LETTER_SPACINGS = [-0.05, -0.02, 0.02, 0.05, 0.1, 0.15, 0.2, 0.3]
|
|||||||
// a widget's "More settings" (6R.17)
|
// a widget's "More settings" (6R.17)
|
||||||
/** Has any of these been changed from the usual? (the dot on the toggle) */
|
/** Has any of these been changed from the usual? (the dot on the toggle) */
|
||||||
export function moreChanged(w) {
|
export function moreChanged(w) {
|
||||||
return !!((w.opacity ?? 100) < 100 || w.rotation || (w.shadow && w.shadow !== 'none') || w.border_width || w.border_radius
|
// owner 2026-11-23: text, colours, shadow and highlight are under "Text and colours" (a picture's
|
||||||
|| (w.animation && w.animation !== 'none') || w.weight || w.highlight || (w.text_effect && w.text_effect !== 'none')
|
// border too), the date's and clock's formats among their main settings
|
||||||
|| w.date_format || w.date_separator || w.clock_format === '12' || (w.clock_separator && w.clock_separator !== ':') || w.clock_blink
|
const look = lookKind(w.kind)
|
||||||
|
return !!((w.opacity ?? 100) < 100 || w.rotation || (!look && w.shadow && w.shadow !== 'none')
|
||||||
|
|| (!FRAMED.includes(w.kind) && (w.border_width || w.border_radius))
|
||||||
|
|| (w.animation && w.animation !== 'none') || (w.text_effect && w.text_effect !== 'none') || w.clock_blink
|
||||||
|| (w.kind === 'qr' && w.media_id) || (w.fit && w.fit !== 'contain'))
|
|| (w.kind === 'qr' && w.media_id) || (w.fit && w.fit !== 'contain'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The widgets with "Text and colours" (all but a menu, a stack and a shape: those have their own look). */
|
||||||
|
export const lookKind = kind => !['menu', 'stack', 'shape'].includes(kind)
|
||||||
|
/** The pictures whose border is under "Text and colours" (owner 2026-11-23). */
|
||||||
|
export const FRAMED = ['logo', 'gallery']
|
||||||
|
|||||||
@@ -123,7 +123,11 @@ test('owner review 6: a box off the slide (a strip stays), a tight box scaled ke
|
|||||||
test("a widget's More settings: changed or as usual (6R.17)", () => {
|
test("a widget's More settings: changed or as usual (6R.17)", () => {
|
||||||
assert.equal(moreChanged({ kind: 'clock' }), false)
|
assert.equal(moreChanged({ kind: 'clock' }), false)
|
||||||
assert.equal(moreChanged({ kind: 'clock', opacity: 100, shadow: 'none', animation: 'none', clock_separator: ':' }), false)
|
assert.equal(moreChanged({ kind: 'clock', opacity: 100, shadow: 'none', animation: 'none', clock_separator: ':' }), false)
|
||||||
assert.equal(moreChanged({ kind: 'clock', clock_format: '12' }), true)
|
assert.equal(moreChanged({ kind: 'clock', clock_format: '12' }), false) // a main setting since 2026-11-23
|
||||||
|
assert.equal(moreChanged({ kind: 'clock', shadow: 'soft', weight: 300, highlight: '#ff0000' }), false) // under Text and colours
|
||||||
|
assert.equal(moreChanged({ kind: 'shape', shadow: 'soft' }), true) // a shape has no Text and colours
|
||||||
|
assert.equal(moreChanged({ kind: 'gallery', border_width: 4 }), false) // a picture's border: Text and colours
|
||||||
|
assert.equal(moreChanged({ kind: 'clock', border_width: 4 }), true)
|
||||||
assert.equal(moreChanged({ kind: 'date', rotation: -15 }), true)
|
assert.equal(moreChanged({ kind: 'date', rotation: -15 }), true)
|
||||||
assert.equal(moreChanged({ kind: 'qr', media_id: 4 }), true)
|
assert.equal(moreChanged({ kind: 'qr', media_id: 4 }), true)
|
||||||
assert.equal(moreChanged({ kind: 'logo', media_id: 4 }), false)
|
assert.equal(moreChanged({ kind: 'logo', media_id: 4 }), false)
|
||||||
|
|||||||
@@ -1541,7 +1541,7 @@
|
|||||||
"dragHint": "Η λίστα είναι σε επίπεδα: το widget στην κορυφή σχεδιάζεται πάνω από τα από κάτω, και ένα νέο widget μπαίνει στην κορυφή. Διαλέξτε ένα widget στην προεπισκόπηση ή εδώ, σύρετέ το (ή με τα βέλη) για να το μετακινήσετε και από τις λαβές για να αλλάξετε το μέγεθος· η θέση και το μέγεθος γράφουν τότε «Προσαρμοσμένο».",
|
"dragHint": "Η λίστα είναι σε επίπεδα: το widget στην κορυφή σχεδιάζεται πάνω από τα από κάτω, και ένα νέο widget μπαίνει στην κορυφή. Διαλέξτε ένα widget στην προεπισκόπηση ή εδώ, σύρετέ το (ή με τα βέλη) για να το μετακινήσετε και από τις λαβές για να αλλάξετε το μέγεθος· η θέση και το μέγεθος γράφουν τότε «Προσαρμοσμένο».",
|
||||||
"custom": "Προσαρμοσμένο",
|
"custom": "Προσαρμοσμένο",
|
||||||
"align": "Στοίχιση",
|
"align": "Στοίχιση",
|
||||||
"alignAuto": "Αυτόματη",
|
"alignAuto": "Auto",
|
||||||
"dateStyle": "Μορφή",
|
"dateStyle": "Μορφή",
|
||||||
"canvas": "Τα widgets της διαφάνειας: σύρετε ένα για μετακίνηση, τις λαβές για μέγεθος, τα βέλη για μικρές κινήσεις",
|
"canvas": "Τα widgets της διαφάνειας: σύρετε ένα για μετακίνηση, τις λαβές για μέγεθος, τα βέλη για μικρές κινήσεις",
|
||||||
"earlier": "Πάνω (σχεδιάζεται κάτω από τα επόμενα)",
|
"earlier": "Πάνω (σχεδιάζεται κάτω από τα επόμενα)",
|
||||||
@@ -1594,8 +1594,7 @@
|
|||||||
"backInPlace": "Πίσω σε στοίχιση",
|
"backInPlace": "Πίσω σε στοίχιση",
|
||||||
"vertical": "Κάθετη στοίχιση",
|
"vertical": "Κάθετη στοίχιση",
|
||||||
"look": "Κείμενο και χρώματα",
|
"look": "Κείμενο και χρώματα",
|
||||||
"plateOnly": "Φόντο πίσω του",
|
"colour": "Χρώμα κειμένου",
|
||||||
"colour": "Χρώμα",
|
|
||||||
"asSlide": "Όπως η διαφάνεια",
|
"asSlide": "Όπως η διαφάνεια",
|
||||||
"plate": "Φόντο πίσω του",
|
"plate": "Φόντο πίσω του",
|
||||||
"noPlate": "Κανένα",
|
"noPlate": "Κανένα",
|
||||||
@@ -1633,8 +1632,8 @@
|
|||||||
"text": "Το κείμενο",
|
"text": "Το κείμενο",
|
||||||
"direction": "Κινείται",
|
"direction": "Κινείται",
|
||||||
"directions": {
|
"directions": {
|
||||||
"left": "Προς τα αριστερά",
|
"left": "Αριστερά",
|
||||||
"right": "Προς τα δεξιά"
|
"right": "Δεξιά"
|
||||||
},
|
},
|
||||||
"speed": "Ταχύτητα"
|
"speed": "Ταχύτητα"
|
||||||
},
|
},
|
||||||
@@ -1717,7 +1716,14 @@
|
|||||||
"noFolders": "Δεν υπάρχουν φάκελοι πολυμέσων ακόμη.",
|
"noFolders": "Δεν υπάρχουν φάκελοι πολυμέσων ακόμη.",
|
||||||
"toMedia": "Φτιάξτε έναν στη σελίδα Πολυμέσα",
|
"toMedia": "Φτιάξτε έναν στη σελίδα Πολυμέσα",
|
||||||
"add": "Προσθήκη εικόνων ή βίντεο",
|
"add": "Προσθήκη εικόνων ή βίντεο",
|
||||||
"empty": "Η συλλογή είναι άδεια ακόμη: μένει κρυφή."
|
"empty": "Η συλλογή είναι άδεια ακόμη: μένει κρυφή.",
|
||||||
|
"title": "Τίτλος",
|
||||||
|
"titlePlaceholder": "Κανένας",
|
||||||
|
"titleAt": "Ο τίτλος μπαίνει",
|
||||||
|
"titleAts": {
|
||||||
|
"above": "Από πάνω",
|
||||||
|
"below": "Από κάτω"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"weatherLayout": "Διάταξη",
|
"weatherLayout": "Διάταξη",
|
||||||
"weatherLayouts": {
|
"weatherLayouts": {
|
||||||
@@ -1741,7 +1747,8 @@
|
|||||||
"weatherHours": "Ώρες",
|
"weatherHours": "Ώρες",
|
||||||
"weatherPlace": "Η τοποθεσία",
|
"weatherPlace": "Η τοποθεσία",
|
||||||
"weatherPlaceLabel": "Δείχνει το όνομά της",
|
"weatherPlaceLabel": "Δείχνει το όνομά της",
|
||||||
"logoFromIdentity": "Χωρίς εικόνα: εμφανίζεται το λογότυπο του καταστήματος (Ρυθμίσεις → Ταυτότητα)."
|
"logoFromIdentity": "Χωρίς εικόνα: εμφανίζεται το λογότυπο του καταστήματος (Ρυθμίσεις → Ταυτότητα).",
|
||||||
|
"enterHint": "Με Enter αλλάζει γραμμή."
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"playlists": "Λίστες",
|
"playlists": "Λίστες",
|
||||||
@@ -1986,21 +1993,25 @@
|
|||||||
"open": "Βαθμονόμηση εικόνας",
|
"open": "Βαθμονόμηση εικόνας",
|
||||||
"title": "Βαθμονόμηση εικόνας: {{name}}",
|
"title": "Βαθμονόμηση εικόνας: {{name}}",
|
||||||
"intro": "Η τηλεόραση δείχνει τώρα τις άκρες της εικόνας με τέσσερα βέλη προς τα έξω. Μετακινήστε κάθε άκρη μέχρι το βέλος της να ακουμπά την άκρη της οθόνης ή διαλέξτε σχήμα. Οι αλλαγές φαίνονται αμέσως στην τηλεόραση.",
|
"intro": "Η τηλεόραση δείχνει τώρα τις άκρες της εικόνας με τέσσερα βέλη προς τα έξω. Μετακινήστε κάθε άκρη μέχρι το βέλος της να ακουμπά την άκρη της οθόνης ή διαλέξτε σχήμα. Οι αλλαγές φαίνονται αμέσως στην τηλεόραση.",
|
||||||
"window": "Το παράθυρο της τηλεόρασης: {{w}} × {{h}} px ({{shape}}).",
|
"window": "{{w}} × {{h}} px ({{shape}})",
|
||||||
"waiting": "Αναμονή για το μέγεθος της τηλεόρασης… Είναι ανοιχτή και δείχνει ψηφιακή σήμανση;",
|
"waiting": "Αναμονή για το μέγεθος της τηλεόρασης… Είναι ανοιχτή και δείχνει ψηφιακή σήμανση;",
|
||||||
"presets": "Σχήματα",
|
"presets": "Σχήματα",
|
||||||
"full": "Όλη η οθόνη",
|
"full": "Όλη η οθόνη",
|
||||||
"step": "Κάθε κλικ μετακινεί",
|
"step": "Κάθε κλικ μετακινεί",
|
||||||
"edges": {
|
"edges": {
|
||||||
"top": "Πάνω άκρη μέσα",
|
"top": "Πάνω άκρη",
|
||||||
"right": "Δεξιά άκρη μέσα",
|
"right": "Δεξιά άκρη",
|
||||||
"bottom": "Κάτω άκρη μέσα",
|
"bottom": "Κάτω άκρη",
|
||||||
"left": "Αριστερή άκρη μέσα"
|
"left": "Αριστερή άκρη"
|
||||||
},
|
},
|
||||||
"picture": "Η εικόνα: {{w}} × {{h}} px ({{shape}})",
|
"picture": "Η εικόνα: {{w}} × {{h}} px ({{shape}})",
|
||||||
"outside": "Έξω από την εικόνα η τηλεόραση μένει μαύρη.",
|
"outside": "Έξω από την εικόνα η τηλεόραση μένει μαύρη.",
|
||||||
"reset": "Ξανά όλη η οθόνη",
|
"reset": "Ξανά όλη η οθόνη",
|
||||||
"done": "Τέλος"
|
"done": "Τέλος",
|
||||||
|
"recognised": "Ανάλυση που αναγνωρίστηκε",
|
||||||
|
"recognisedHint": "Το μέγεθος που ανέφερε η ίδια η τηλεόραση. Αν η πραγματική της εικόνα είναι μεγαλύτερη ή μικρότερη, αλλάξτε την εδώ με τις άκρες από κάτω.",
|
||||||
|
"edgesHint": "Θετικός αριθμός φέρνει την άκρη μέσα· αρνητικός τη σπρώχνει έξω, πέρα από την ανάλυση που αναγνωρίστηκε.",
|
||||||
|
"past": "Μέρος της εικόνας περνά πλέον πέρα από την ανάλυση που αναγνωρίστηκε: αν η τηλεόραση δεν έχει πραγματικά εικόνα εκεί, αυτό το κομμάτι κόβεται."
|
||||||
},
|
},
|
||||||
"reviews": {
|
"reviews": {
|
||||||
"title": "Κριτικές",
|
"title": "Κριτικές",
|
||||||
|
|||||||
@@ -1594,8 +1594,7 @@
|
|||||||
"backInPlace": "Back to aligned",
|
"backInPlace": "Back to aligned",
|
||||||
"vertical": "Vertical alignment",
|
"vertical": "Vertical alignment",
|
||||||
"look": "Text and colours",
|
"look": "Text and colours",
|
||||||
"plateOnly": "Background plate",
|
"colour": "Text colour",
|
||||||
"colour": "Colour",
|
|
||||||
"asSlide": "As the slide",
|
"asSlide": "As the slide",
|
||||||
"plate": "Background plate",
|
"plate": "Background plate",
|
||||||
"noPlate": "None",
|
"noPlate": "None",
|
||||||
@@ -1633,8 +1632,8 @@
|
|||||||
"text": "The text",
|
"text": "The text",
|
||||||
"direction": "Moves",
|
"direction": "Moves",
|
||||||
"directions": {
|
"directions": {
|
||||||
"left": "To the left",
|
"left": "Left",
|
||||||
"right": "To the right"
|
"right": "Right"
|
||||||
},
|
},
|
||||||
"speed": "Speed"
|
"speed": "Speed"
|
||||||
},
|
},
|
||||||
@@ -1717,7 +1716,14 @@
|
|||||||
"noFolders": "No media folders yet.",
|
"noFolders": "No media folders yet.",
|
||||||
"toMedia": "Make one on the Media page",
|
"toMedia": "Make one on the Media page",
|
||||||
"add": "Add pictures or videos",
|
"add": "Add pictures or videos",
|
||||||
"empty": "Nothing in the gallery yet: it stays hidden."
|
"empty": "Nothing in the gallery yet: it stays hidden.",
|
||||||
|
"title": "Title",
|
||||||
|
"titlePlaceholder": "None",
|
||||||
|
"titleAt": "Title goes",
|
||||||
|
"titleAts": {
|
||||||
|
"above": "Above",
|
||||||
|
"below": "Below"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"weatherLayout": "Layout",
|
"weatherLayout": "Layout",
|
||||||
"weatherLayouts": {
|
"weatherLayouts": {
|
||||||
@@ -1741,7 +1747,8 @@
|
|||||||
"weatherHours": "Hours",
|
"weatherHours": "Hours",
|
||||||
"weatherPlace": "The place",
|
"weatherPlace": "The place",
|
||||||
"weatherPlaceLabel": "Show its name",
|
"weatherPlaceLabel": "Show its name",
|
||||||
"logoFromIdentity": "No picture chosen: the venue's logo (Settings → Identity) shows."
|
"logoFromIdentity": "No picture chosen: the venue's logo (Settings → Identity) shows.",
|
||||||
|
"enterHint": "Enter starts a new line."
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
"playlists": "Playlists",
|
"playlists": "Playlists",
|
||||||
@@ -1986,21 +1993,25 @@
|
|||||||
"open": "Calibrate the picture",
|
"open": "Calibrate the picture",
|
||||||
"title": "Calibrate the picture: {{name}}",
|
"title": "Calibrate the picture: {{name}}",
|
||||||
"intro": "The TV now shows its picture's edges with four arrows pointing out. Move each edge until its arrow just touches the edge of the screen, or pick a shape. Changes show on the TV at once.",
|
"intro": "The TV now shows its picture's edges with four arrows pointing out. Move each edge until its arrow just touches the edge of the screen, or pick a shape. Changes show on the TV at once.",
|
||||||
"window": "The TV's window: {{w}} × {{h}} px ({{shape}}).",
|
"window": "{{w}} × {{h}} px ({{shape}})",
|
||||||
"waiting": "Waiting for the TV to tell its size… Is it on and showing signage?",
|
"waiting": "Waiting for the TV to tell its size… Is it on and showing signage?",
|
||||||
"presets": "Shapes",
|
"presets": "Shapes",
|
||||||
"full": "Whole screen",
|
"full": "Whole screen",
|
||||||
"step": "Each click moves",
|
"step": "Each click moves",
|
||||||
"edges": {
|
"edges": {
|
||||||
"top": "Top edge in",
|
"top": "Top edge",
|
||||||
"right": "Right edge in",
|
"right": "Right edge",
|
||||||
"bottom": "Bottom edge in",
|
"bottom": "Bottom edge",
|
||||||
"left": "Left edge in"
|
"left": "Left edge"
|
||||||
},
|
},
|
||||||
"picture": "The picture: {{w}} × {{h}} px ({{shape}})",
|
"picture": "The picture: {{w}} × {{h}} px ({{shape}})",
|
||||||
"outside": "Outside the picture the TV stays black.",
|
"outside": "Outside the picture the TV stays black.",
|
||||||
"reset": "Whole screen again",
|
"reset": "Whole screen again",
|
||||||
"done": "Done"
|
"done": "Done",
|
||||||
|
"recognised": "Recognised resolution",
|
||||||
|
"recognisedHint": "The size the TV reported for itself. If its real picture is larger or smaller, change it right here with the edges below.",
|
||||||
|
"edgesHint": "A positive number moves that edge in; a negative one pushes it out, past the recognised resolution.",
|
||||||
|
"past": "Part of the picture now reaches past the recognised resolution: if the TV really has no picture there, that part is cut off."
|
||||||
},
|
},
|
||||||
"reviews": {
|
"reviews": {
|
||||||
"title": "Reviews",
|
"title": "Reviews",
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ const CORNER = {
|
|||||||
'bottom-right': { bottom: cq(3), right: cq(3), alignItems: 'flex-end' },
|
'bottom-right': { bottom: cq(3), right: cq(3), alignItems: 'flex-end' },
|
||||||
}
|
}
|
||||||
const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' }
|
const SELF = { left: 'flex-start', center: 'center', right: 'flex-end' }
|
||||||
|
const GRID = { left: 'start', center: 'center', right: 'end' } // a grid's items, by the widget's alignment
|
||||||
const placedBy = w => (w.position === 'custom' && w.box ? (TIGHT.includes(w.kind) ? 'tight' : true) : false)
|
const placedBy = w => (w.position === 'custom' && w.box ? (TIGHT.includes(w.kind) ? 'tight' : true) : false)
|
||||||
const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: 'center' }
|
const VSELF = { top: 'flex-start', middle: 'center', bottom: 'flex-end', auto: 'center' }
|
||||||
/** A widget's own colour and the plate behind it (owner review 5); `pad`: a plate that hugs it. */
|
/** A widget's own colour and the plate behind it (owner review 5); `pad`: a plate that hugs it. */
|
||||||
@@ -265,7 +266,7 @@ export function Widgets({ widgets, media, venue, now, colour, extras, embed }) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : {}
|
const own = w.align && w.align !== 'auto' ? { alignItems: SELF[w.align], textAlign: w.align } : { textAlign: widgetAlign(w) }
|
||||||
return (
|
return (
|
||||||
<div key={i} data-widget={i} ref={animate(w)} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true), ...fx(w, CORNER[w.position].transform) }}>
|
<div key={i} data-widget={i} ref={animate(w)} className="absolute" style={{ ...CORNER[w.position], ...own, display: 'flex', flexDirection: 'column', color: colour || '#fff', ...plate(w, true), ...fx(w, CORNER[w.position].transform) }}>
|
||||||
{body}
|
{body}
|
||||||
@@ -283,9 +284,10 @@ const OBJECT_POSITION = { left: 'left center', center: 'center', right: 'right c
|
|||||||
* the slide at size medium); `fit`: the widget fills its place instead (fitUnit: a stack's part);
|
* the slide at size medium); `fit`: the widget fills its place instead (fitUnit: a stack's part);
|
||||||
* fit 'tight' (owner review 6): placed by hand, its box is exactly its content: the box's height
|
* fit 'tight' (owner review 6): placed by hand, its box is exactly its content: the box's height
|
||||||
* (× its text size) sets the size and its width follows. `path`: the widget's place in the slide
|
* (× its text size) sets the size and its width follows. `path`: the widget's place in the slide
|
||||||
* ("2", "2.1.0" inside a stack), for its extras.
|
* ("2", "2.1.0" inside a stack), for its extras. `align`: how its lines line up with each other (owner
|
||||||
|
* 2026-11-23: the lines of a text, the rows of the hours or contact details, the weather's parts…).
|
||||||
*/
|
*/
|
||||||
function widgetBody(w, ctx, fit, path) {
|
function widgetBody(w, ctx, fit, path, align = widgetAlign(w)) {
|
||||||
const { media, venue, now, fmt, extras } = ctx
|
const { media, venue, now, fmt, extras } = ctx
|
||||||
const { formatDate, formatTime } = fmt
|
const { formatDate, formatTime } = fmt
|
||||||
const x = extras[path] || {}
|
const x = extras[path] || {}
|
||||||
@@ -300,10 +302,12 @@ function widgetBody(w, ctx, fit, path) {
|
|||||||
}
|
}
|
||||||
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: w.weight || (w.bold === false ? 400 : w.bold ? Math.max(weight, 800) : weight), lineHeight: 1.15,
|
const text = (u, size, weight = 700) => ({ fontSize: u(size), fontWeight: w.weight || (w.bold === false ? 400 : w.bold ? Math.max(weight, 800) : weight), lineHeight: 1.15,
|
||||||
...(w.highlight ? { background: w.highlight, padding: '0.05em 0.25em', borderRadius: '0.15em', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone' } : {}),
|
...(w.highlight ? { background: w.highlight, padding: '0.05em 0.25em', borderRadius: '0.15em', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone' } : {}),
|
||||||
textShadow: w.background_colour ? undefined : `0 ${cq(0.2)} ${cq(0.8)} rgba(0,0,0,0.35)`, whiteSpace: fit ? 'nowrap' : undefined,
|
textShadow: w.background_colour ? undefined : `0 ${cq(0.2)} ${cq(0.8)} rgba(0,0,0,0.35)`, whiteSpace: fit ? 'pre' : 'pre-line',
|
||||||
...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}), ...(w.underline ? { textDecoration: 'underline' } : {}) })
|
...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}), ...(w.underline ? { textDecoration: 'underline' } : {}) })
|
||||||
|
// a text of several lines (Enter, owner 2026-11-23): sized by its longest line and how many there are
|
||||||
const line = (str, testid, weight) => {
|
const line = (str, testid, weight) => {
|
||||||
const u = unit(3.4 * 1.15, textWidth(str.length, 3.4))
|
const rows = str.split('\n')
|
||||||
|
const u = unit(3.4 * 1.15 * rows.length, textWidth(Math.max(...rows.map(r => r.length)), 3.4))
|
||||||
return <span style={text(u, 3.4, weight)} data-testid={testid}>{w.text_effect === 'typewriter' ? <TypeText text={str} /> : str}</span>
|
return <span style={text(u, 3.4, weight)} data-testid={testid}>{w.text_effect === 'typewriter' ? <TypeText text={str} /> : str}</span>
|
||||||
}
|
}
|
||||||
// a menu or a stack fills a box: its own, or (in a corner / bar) one of a usual size
|
// a menu or a stack fills a box: its own, or (in a corner / bar) one of a usual size
|
||||||
@@ -353,7 +357,7 @@ function widgetBody(w, ctx, fit, path) {
|
|||||||
const caption = w.qr_caption ? 2.4 * 1.15 + 0.8 : 0
|
const caption = w.qr_caption ? 2.4 * 1.15 + 0.8 : 0
|
||||||
const u = unit(16 + caption, Math.max(16, w.qr_caption ? textWidth(w.qr_caption.length, 2.4) : 0))
|
const u = unit(16 + caption, Math.max(16, w.qr_caption ? textWidth(w.qr_caption.length, 2.4) : 0))
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[align], textAlign: align, gap: u(0.8) }} data-testid="signage-w-qr" data-link={link}>
|
||||||
<div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
<div style={{ background: w.qr_background || '#fff', padding: u(1), borderRadius: u(1), lineHeight: 0 }}>
|
||||||
<QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }}
|
<QRCodeSVG value={link} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(14), height: u(14) }}
|
||||||
level={logo ? 'H' : 'M'} imageSettings={logo ? { src: logo.src, width: 64, height: 64, excavate: true } : undefined} />
|
level={logo ? 'H' : 'M'} imageSettings={logo ? { src: logo.src, width: 64, height: 64, excavate: true } : undefined} />
|
||||||
@@ -362,7 +366,7 @@ function widgetBody(w, ctx, fit, path) {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (w.kind === 'weather') return weatherBody(w, venue?.weather, unit, text, formatDate, ctx.t)
|
if (w.kind === 'weather') return weatherBody(w, venue?.weather, unit, text, formatDate, ctx.t, align)
|
||||||
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} badges={venue?.badges} />, 'menu')
|
if (w.kind === 'menu') return boxed(<MenuWidget board={w.board || {}} menu={x.menu} now={now} badges={venue?.badges} />, 'menu')
|
||||||
if (w.kind === 'stack') return boxed(<Stack w={w} path={path} ctx={ctx} />, 'stack')
|
if (w.kind === 'stack') return boxed(<Stack w={w} path={path} ctx={ctx} />, 'stack')
|
||||||
// 6R.15
|
// 6R.15
|
||||||
@@ -382,26 +386,26 @@ function widgetBody(w, ctx, fit, path) {
|
|||||||
const label = w.text || ''
|
const label = w.text || ''
|
||||||
const u = unit((label ? 2.4 * 1.15 + 0.4 : 0) + 6 * 1.1, Math.max(textWidth(digits.length, 6) * 0.9, label ? textWidth(label.length, 2.4) : 0))
|
const u = unit((label ? 2.4 * 1.15 + 0.4 : 0) + 6 * 1.1, Math.max(textWidth(digits.length, 6) * 0.9, label ? textWidth(label.length, 2.4) : 0))
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'inherit', gap: u(0.4) }} data-testid="signage-w-countdown" data-state={st.state} data-left={st.left}>
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: SELF[align], textAlign: align, gap: u(0.4) }} data-testid="signage-w-countdown" data-state={st.state} data-left={st.left}>
|
||||||
{label && <span style={text(u, 2.4, 600)}>{label}</span>}
|
{label && <span style={text(u, 2.4, 600)}>{label}</span>}
|
||||||
<span style={{ ...text(u, 6, 800), lineHeight: 1.1, fontVariantNumeric: 'tabular-nums' }}>{digits}</span>
|
<span style={{ ...text(u, 6, 800), lineHeight: 1.1, fontVariantNumeric: 'tabular-nums' }}>{digits}</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text)
|
if (w.kind === 'hours') return hoursBody(w, ctx, unit, text, align)
|
||||||
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text)
|
if (w.kind === 'wifi') return wifiBody(w, venue?.identity?.wifi, unit, text, align)
|
||||||
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text)
|
if (w.kind === 'contact') return contactBody(w, venue?.identity?.contact, unit, text, align)
|
||||||
if (w.kind === 'gallery') {
|
if (w.kind === 'gallery') {
|
||||||
const ids = w.gallery_source === 'folder' ? (x.gallery || []) : (w.media_ids || [])
|
const ids = w.gallery_source === 'folder' ? (x.gallery || []) : (w.media_ids || [])
|
||||||
const items = ids.map(id => media(id)).filter(Boolean)
|
const items = ids.map(id => media(id)).filter(Boolean)
|
||||||
if (!items.length) return null
|
if (!items.length) return null
|
||||||
return boxed(<Gallery w={w} items={items} now={now} />, 'gallery')
|
return boxed(<Gallery w={w} items={items} now={now} title={w.text ? text(n => cq(+(n * ts).toFixed(3), 'h'), 9, 700) : null} align={align} />, 'gallery')
|
||||||
}
|
}
|
||||||
if (w.kind === 'reviews') {
|
if (w.kind === 'reviews') {
|
||||||
const list = (venue?.reviews || []).filter(r => r.stars >= (w.reviews_min || 4))
|
const list = (venue?.reviews || []).filter(r => r.stars >= (w.reviews_min || 4))
|
||||||
if (!list.length) return null
|
if (!list.length) return null
|
||||||
const r = list[pageAt(list.length, w.reviews_seconds || 8, now.getTime())]
|
const r = list[pageAt(list.length, w.reviews_seconds || 8, now.getTime())]
|
||||||
return boxed(<ReviewBody w={w} r={r} fmt={fmt} n={list.length} />, 'reviews')
|
return boxed(<ReviewBody w={w} r={r} fmt={fmt} n={list.length} align={align} />, 'reviews')
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -440,8 +444,11 @@ const GALLERY_IN = {
|
|||||||
zoom: [{ opacity: 0, transform: 'scale(1.12)' }, { opacity: 1, transform: 'scale(1)' }],
|
zoom: [{ opacity: 0, transform: 'scale(1.12)' }, { opacity: 1, transform: 'scale(1)' }],
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A gallery (6R.16): its pictures and videos one after another, each for its seconds, coming in with its transition. */
|
/**
|
||||||
function Gallery({ w, items, now }) {
|
* A gallery (6R.16): its pictures and videos one after another, each for its seconds, coming in with
|
||||||
|
* its transition; its title above or below them (owner 2026-11-23), `title` = the title's text style.
|
||||||
|
*/
|
||||||
|
function Gallery({ w, items, now, title, align }) {
|
||||||
const i = pageAt(items.length, w.gallery_seconds || 5, now.getTime())
|
const i = pageAt(items.length, w.gallery_seconds || 5, now.getTime())
|
||||||
const m = items[i]
|
const m = items[i]
|
||||||
const el = useRef(null)
|
const el = useRef(null)
|
||||||
@@ -453,13 +460,17 @@ function Gallery({ w, items, now }) {
|
|||||||
}, [i, frames])
|
}, [i, frames])
|
||||||
const fit = { width: '100%', height: '100%', objectFit: w.gallery_fit || 'cover', display: 'block' }
|
const fit = { width: '100%', height: '100%', objectFit: w.gallery_fit || 'cover', display: 'block' }
|
||||||
return (
|
return (
|
||||||
<div style={{ width: '100%', height: '100%', overflow: 'hidden', position: 'relative' }} data-testid="signage-w-gallery" data-index={i} data-count={items.length}>
|
<div style={{ width: '100%', height: '100%', display: 'flex', flexDirection: w.title_position === 'below' ? 'column-reverse' : 'column', gap: title ? '2%' : 0 }}
|
||||||
|
data-testid="signage-w-gallery" data-index={i} data-count={items.length}>
|
||||||
|
{title && <div style={{ ...title, flexShrink: 0, textAlign: align, overflow: 'hidden', textOverflow: 'ellipsis' }} data-testid="signage-w-gallery-title">{w.text}</div>}
|
||||||
|
<div style={{ flex: '1 1 0%', minHeight: 0, overflow: 'hidden', position: 'relative' }}>
|
||||||
<div key={`${i}-${m.src}`} ref={el} style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}>
|
<div key={`${i}-${m.src}`} ref={el} style={{ position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 }}>
|
||||||
{m.kind === 'video'
|
{m.kind === 'video'
|
||||||
? <video src={m.src} poster={m.poster} muted autoPlay loop playsInline style={fit} />
|
? <video src={m.src} poster={m.poster} muted autoPlay loop playsInline style={fit} />
|
||||||
: <img src={m.src} alt="" style={fit} />}
|
: <img src={m.src} alt="" style={fit} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,7 +478,7 @@ function Gallery({ w, items, now }) {
|
|||||||
* One of the venue's reviews (6R.19), the next one every few seconds: its stars, what they wrote,
|
* One of the venue's reviews (6R.19), the next one every few seconds: its stars, what they wrote,
|
||||||
* who and where. It fills its place: the text is sized from the place's size and the review's length.
|
* who and where. It fills its place: the text is sized from the place's size and the review's length.
|
||||||
*/
|
*/
|
||||||
function ReviewBody({ w, r, fmt, n }) {
|
function ReviewBody({ w, r, fmt, n, align }) {
|
||||||
const box = useRef(null)
|
const box = useRef(null)
|
||||||
const [size, setSize] = useState(null)
|
const [size, setSize] = useState(null)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -483,15 +494,17 @@ function ReviewBody({ w, r, fmt, n }) {
|
|||||||
const who = [w.reviews_name !== false && r.name, r.source, r.date && fmt.formatDate(`${r.date}T12:00:00Z`, 'date')].filter(Boolean).join(' · ')
|
const who = [w.reviews_name !== false && r.name, r.source, r.date && fmt.formatDate(`${r.date}T12:00:00Z`, 'date')].filter(Boolean).join(' · ')
|
||||||
const font = { ...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}) }
|
const font = { ...(w.font ? { fontFamily: FONTS[w.font] } : {}), ...(w.italic ? { fontStyle: 'italic' } : {}) }
|
||||||
return (
|
return (
|
||||||
<div ref={box} style={{ width: '100%', height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: f * 0.35, ...font }}
|
<div ref={box} style={{ width: '100%', height: '100%', overflow: 'hidden', display: 'flex', flexDirection: 'column', justifyContent: 'center', textAlign: align, gap: f * 0.35, ...font }}
|
||||||
data-testid="signage-w-reviews" data-count={n} data-name={r.name}>
|
data-testid="signage-w-reviews" data-count={n} data-name={r.name}>
|
||||||
{size && <>
|
{size && <>
|
||||||
{w.reviews_stars !== false && (
|
{w.reviews_stars !== false && (
|
||||||
<div style={{ display: 'flex', gap: f * 0.15, justifyContent: 'inherit' }} aria-label={`${r.stars}/5`}>
|
<div style={{ display: 'flex', gap: f * 0.15, justifyContent: SELF[align] }} aria-label={`${r.stars}/5`}>
|
||||||
{[1, 2, 3, 4, 5].map(i => <Star key={i} style={{ width: f * 1.1, height: f * 1.1, color: STAR, fill: i <= r.stars ? STAR : 'none', opacity: i <= r.stars ? 1 : 0.4 }} aria-hidden="true" />)}
|
{[1, 2, 3, 4, 5].map(i => <Star key={i} style={{ width: f * 1.1, height: f * 1.1, color: STAR, fill: i <= r.stars ? STAR : 'none', opacity: i <= r.stars ? 1 : 0.4 }} aria-hidden="true" />)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div style={{ fontSize: f, lineHeight: 1.35, fontWeight: w.bold ? 700 : 500, ...(w.underline ? { textDecoration: 'underline' } : {}) }}>“{r.text}”</div>
|
<div style={{ fontSize: f, lineHeight: 1.35, fontWeight: w.weight || (w.bold ? 700 : 500), ...(w.underline ? { textDecoration: 'underline' } : {}) }}>
|
||||||
|
<span style={w.highlight ? { background: w.highlight, padding: '0.05em 0.25em', borderRadius: '0.15em', boxDecorationBreak: 'clone', WebkitBoxDecorationBreak: 'clone' } : undefined}>“{r.text}”</span>
|
||||||
|
</div>
|
||||||
{who && <div style={{ fontSize: f * 0.72, fontWeight: 700, opacity: 0.85 }}>— {who}</div>}
|
{who && <div style={{ fontSize: f * 0.72, fontWeight: 700, opacity: 0.85 }}>— {who}</div>}
|
||||||
</>}
|
</>}
|
||||||
</div>
|
</div>
|
||||||
@@ -563,7 +576,7 @@ const MONDAY = '2026-11-16' // a Monday: day names from the venue'
|
|||||||
const dayShort = (fmt, i) => fmt.formatDate(`2026-11-${16 + i}T12:00:00Z`, 'weekday').slice(0, 3)
|
const dayShort = (fmt, i) => fmt.formatDate(`2026-11-${16 + i}T12:00:00Z`, 'weekday').slice(0, 3)
|
||||||
|
|
||||||
/** The opening hours (6R.15): the week (days with the same hours on one line) or today; today stands out. */
|
/** The opening hours (6R.15): the week (days with the same hours on one line) or today; today stands out. */
|
||||||
function hoursBody(w, ctx, unit, text) {
|
function hoursBody(w, ctx, unit, text, align = 'left') {
|
||||||
const { venue, now, fmt, t } = ctx
|
const { venue, now, fmt, t } = ctx
|
||||||
const hours = venue?.hours
|
const hours = venue?.hours
|
||||||
if (!hours?.set) return null
|
if (!hours?.set) return null
|
||||||
@@ -573,14 +586,15 @@ function hoursBody(w, ctx, unit, text) {
|
|||||||
const spansText = r => (r.spans.length ? r.spans.map(x => `${x.from}–${x.to}`).join(', ') : t('signage.closed'))
|
const spansText = r => (r.spans.length ? r.spans.map(x => `${x.from}–${x.to}`).join(', ') : t('signage.closed'))
|
||||||
const widest = Math.max(...rows.map(r => daysText(r).length + 2 + spansText(r).length), w.text ? w.text.length : 0)
|
const widest = Math.max(...rows.map(r => daysText(r).length + 2 + spansText(r).length), w.text ? w.text.length : 0)
|
||||||
const u = unit((rows.length + (w.text ? 1.3 : 0)) * 3 * 1.35, textWidth(widest, 3))
|
const u = unit((rows.length + (w.text ? 1.3 : 0)) * 3 * 1.35, textWidth(widest, 3))
|
||||||
|
// lined up (owner 2026-11-23): left / right: both columns to that side; centre: they meet in the middle
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'auto auto', columnGap: u(2), rowGap: u(0.4), alignItems: 'baseline', textAlign: 'left' }}
|
<div style={{ display: 'grid', gridTemplateColumns: 'auto auto', columnGap: u(2), rowGap: u(0.4), alignItems: 'baseline' }}
|
||||||
data-testid="signage-w-hours" data-rows={rows.length} data-start={MONDAY}>
|
data-testid="signage-w-hours" data-rows={rows.length} data-start={MONDAY} data-align={align}>
|
||||||
{w.text && <span style={{ ...text(u, 3.4, 800), gridColumn: '1 / -1' }}>{w.text}</span>}
|
{w.text && <span style={{ ...text(u, 3.4, 800), gridColumn: '1 / -1', textAlign: align }}>{w.text}</span>}
|
||||||
{rows.map(r => (
|
{rows.map(r => (
|
||||||
<span key={r.days.join()} style={{ display: 'contents' }} data-today={r.today ? 'true' : undefined}>
|
<span key={r.days.join()} style={{ display: 'contents' }} data-today={r.today ? 'true' : undefined}>
|
||||||
<span style={{ ...text(u, 3, r.today ? 800 : 600), opacity: r.today || w.hours_style === 'today' ? 1 : 0.85 }}>{daysText(r)}</span>
|
<span style={{ ...text(u, 3, r.today ? 800 : 600), opacity: r.today || w.hours_style === 'today' ? 1 : 0.85, textAlign: align === 'left' ? 'left' : 'right' }}>{daysText(r)}</span>
|
||||||
<span style={{ ...text(u, 3, r.today ? 800 : 500), fontVariantNumeric: 'tabular-nums' }}>{spansText(r)}</span>
|
<span style={{ ...text(u, 3, r.today ? 800 : 500), fontVariantNumeric: 'tabular-nums', textAlign: align === 'right' ? 'right' : 'left' }}>{spansText(r)}</span>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -588,24 +602,29 @@ function hoursBody(w, ctx, unit, text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The guests' Wi-Fi (6R.15, from the identity): its code to join, the network and the password. */
|
/** The guests' Wi-Fi (6R.15, from the identity): its code to join, the network and the password. */
|
||||||
function wifiBody(w, wifi, unit, text) {
|
function wifiBody(w, wifi, unit, text, align = 'left') {
|
||||||
if (!wifi?.ssid) return null
|
if (!wifi?.ssid) return null
|
||||||
const qr = w.wifi_qr !== false ? wifiQr(wifi) : ''
|
const qr = w.wifi_qr !== false ? wifiQr(wifi) : ''
|
||||||
const pw = w.wifi_password !== false && wifi.security !== 'nopass' && wifi.password ? wifi.password : ''
|
const pw = w.wifi_password !== false && wifi.security !== 'nopass' && wifi.password ? wifi.password : ''
|
||||||
const lines = [wifi.ssid, pw, wifi.note].filter(Boolean)
|
const lines = [wifi.ssid, pw, wifi.note].filter(Boolean)
|
||||||
const chars = Math.max(...lines.map(l => l.length)) + 2
|
const chars = Math.max(...lines.map(l => l.length)) + 2
|
||||||
const u = unit(Math.max(qr ? 13 : 0, lines.length * 3.4 * 1.35), (qr ? 14.5 : 0) + textWidth(chars, 3.4))
|
// the code on the left (left), on the right (right), above the text (centre: owner 2026-11-23)
|
||||||
|
const stacked = align === 'center' && qr
|
||||||
|
const u = stacked ? unit(13 + 1.5 + lines.length * 3.4 * 1.35, Math.max(13, textWidth(chars, 3.4)))
|
||||||
|
: unit(Math.max(qr ? 13 : 0, lines.length * 3.4 * 1.35), (qr ? 14.5 : 0) + textWidth(chars, 3.4))
|
||||||
const icon = { width: u(3), height: u(3), flexShrink: 0 }
|
const icon = { width: u(3), height: u(3), flexShrink: 0 }
|
||||||
|
const row = { display: 'flex', alignItems: 'center', gap: u(0.8), justifyContent: SELF[align] }
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: u(1.5), textAlign: 'left' }} data-testid="signage-w-wifi">
|
<div style={{ display: 'flex', flexDirection: stacked ? 'column' : align === 'right' ? 'row-reverse' : 'row', alignItems: 'center', gap: u(1.5), textAlign: align }}
|
||||||
|
data-testid="signage-w-wifi" data-align={align}>
|
||||||
{qr && (
|
{qr && (
|
||||||
<div style={{ background: w.qr_background || '#fff', padding: u(0.7), borderRadius: u(0.8), lineHeight: 0 }}>
|
<div style={{ background: w.qr_background || '#fff', padding: u(0.7), borderRadius: u(0.8), lineHeight: 0 }}>
|
||||||
<QRCodeSVG value={qr} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(11.5), height: u(11.5) }} />
|
<QRCodeSVG value={qr} size={256} fgColor={w.qr_colour || '#000000'} bgColor={w.qr_background || '#ffffff'} style={{ width: u(11.5), height: u(11.5) }} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div style={{ display: 'grid', gap: u(0.5) }}>
|
<div style={{ display: 'grid', gap: u(0.5), justifyItems: GRID[align] }}>
|
||||||
<span style={{ display: 'flex', alignItems: 'center', gap: u(0.8), ...text(u, 3.4, 800) }}><Wifi style={icon} aria-hidden="true" />{wifi.ssid}</span>
|
<span style={{ ...row, ...text(u, 3.4, 800) }}><Wifi style={icon} aria-hidden="true" />{wifi.ssid}</span>
|
||||||
{pw && <span style={{ display: 'flex', alignItems: 'center', gap: u(0.8), ...text(u, 3.4, 600) }}><Lock style={icon} aria-hidden="true" />{pw}</span>}
|
{pw && <span style={{ ...row, ...text(u, 3.4, 600) }}><Lock style={icon} aria-hidden="true" />{pw}</span>}
|
||||||
{wifi.note && <span style={{ ...text(u, 2.6, 500), opacity: 0.85 }}>{wifi.note}</span>}
|
{wifi.note && <span style={{ ...text(u, 2.6, 500), opacity: 0.85 }}>{wifi.note}</span>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -616,12 +635,12 @@ const CONTACT_ICONS = { phone: Phone, phone2: Phone, email: Mail, address: MapPi
|
|||||||
instagram: Camera, tiktok: Music, tripadvisor: Star, whatsapp: MessageCircle, viber: MessageCircle }
|
instagram: Camera, tiktok: Music, tripadvisor: Star, whatsapp: MessageCircle, viber: MessageCircle }
|
||||||
|
|
||||||
/** The venue's contact details (6R.15, from the identity): the chosen ones that are set, one a line with an icon. */
|
/** The venue's contact details (6R.15, from the identity): the chosen ones that are set, one a line with an icon. */
|
||||||
function contactBody(w, contact, unit, text) {
|
function contactBody(w, contact, unit, text, align = 'left') {
|
||||||
const rows = (w.contact_fields || ['phone', 'website', 'instagram']).filter(k => contact?.[k]).map(k => [k, contact[k]])
|
const rows = (w.contact_fields || ['phone', 'website', 'instagram']).filter(k => contact?.[k]).map(k => [k, contact[k]])
|
||||||
if (!rows.length) return null
|
if (!rows.length) return null
|
||||||
const u = unit(rows.length * 3.2 * 1.4, textWidth(Math.max(...rows.map(([, v]) => v.length)) + 2, 3.2))
|
const u = unit(rows.length * 3.2 * 1.4, textWidth(Math.max(...rows.map(([, v]) => v.length)) + 2, 3.2))
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'grid', gap: u(0.6), textAlign: 'left' }} data-testid="signage-w-contact" data-rows={rows.length}>
|
<div style={{ display: 'grid', gap: u(0.6), justifyItems: GRID[align], textAlign: align }} data-testid="signage-w-contact" data-rows={rows.length} data-align={align}>
|
||||||
{rows.map(([k, v]) => {
|
{rows.map(([k, v]) => {
|
||||||
const Icon = CONTACT_ICONS[k] || Globe
|
const Icon = CONTACT_ICONS[k] || Globe
|
||||||
return (
|
return (
|
||||||
@@ -640,7 +659,7 @@ function contactBody(w, contact, unit, text) {
|
|||||||
* next hours; with the details chosen (feels like, humidity, wind, rain chance, sunrise / sunset,
|
* next hours; with the details chosen (feels like, humidity, wind, rain chance, sunrise / sunset,
|
||||||
* UV, in words) and the place's name. Older forecasts without the details just leave them out.
|
* UV, in words) and the place's name. Older forecasts without the details just leave them out.
|
||||||
*/
|
*/
|
||||||
function weatherBody(w, wx, unit, text, formatDate, t) {
|
function weatherBody(w, wx, unit, text, formatDate, t, align = 'left') {
|
||||||
if (!wx || wx.temperature == null) return null // no internet / no place: hidden (5.4c)
|
if (!wx || wx.temperature == null) return null // no internet / no place: hidden (5.4c)
|
||||||
const from = w.weather_from || 0
|
const from = w.weather_from || 0
|
||||||
const style = w.weather_style || 'both'
|
const style = w.weather_style || 'both'
|
||||||
@@ -678,7 +697,7 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
|||||||
if (!hours.length) return null
|
if (!hours.length) return null
|
||||||
const u = unit((place ? 3.2 : 0) + 3 + 5 + 3.6, hours.length * 9)
|
const u = unit((place ? 3.2 : 0) + 3 + 5 + 3.6, hours.length * 9)
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'grid', gap: u(0.6) }} data-testid="signage-w-weather" data-layout="hourly">
|
<div style={{ display: 'grid', gap: u(0.6), justifyItems: GRID[align] }} data-testid="signage-w-weather" data-layout="hourly">
|
||||||
{place && <span style={text(u, 2.6, 700)}>{place}</span>}
|
{place && <span style={text(u, 2.6, 700)}>{place}</span>}
|
||||||
<div style={{ display: 'flex', gap: u(1.5) }}>
|
<div style={{ display: 'flex', gap: u(1.5) }}>
|
||||||
{hours.map(h => {
|
{hours.map(h => {
|
||||||
@@ -699,7 +718,7 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
|||||||
const list = days.slice(from, from + (w.weather_days || 3))
|
const list = days.slice(from, from + (w.weather_days || 3))
|
||||||
const u = unit((place ? 3.4 : 0) + list.length * 4.4, tw(4, 3) + 5 + tw(11, 3) + (want.has('rain') ? tw(5, 3) : 0) + 4)
|
const u = unit((place ? 3.4 : 0) + list.length * 4.4, tw(4, 3) + 5 + tw(11, 3) + (want.has('rain') ? tw(5, 3) : 0) + 4)
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'grid', gap: u(0.5) }} data-testid="signage-w-weather" data-layout="list">
|
<div style={{ display: 'grid', gap: u(0.5), justifyItems: GRID[align] }} data-testid="signage-w-weather" data-layout="list">
|
||||||
{place && <span style={text(u, 2.8, 700)}>{place}</span>}
|
{place && <span style={text(u, 2.8, 700)}>{place}</span>}
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: `auto auto auto${want.has('rain') ? ' auto' : ''}`, columnGap: u(1.6), rowGap: u(0.6), alignItems: 'center' }}>
|
<div style={{ display: 'grid', gridTemplateColumns: `auto auto auto${want.has('rain') ? ' auto' : ''}`, columnGap: u(1.6), rowGap: u(0.6), alignItems: 'center' }}>
|
||||||
{list.map((d, n) => {
|
{list.map((d, n) => {
|
||||||
@@ -737,7 +756,7 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
|||||||
const width = Math.max((pic ? 9 : 0) + (deg ? tw(main.label.length, 6) : 0), card ? detailW * 2 * 2.4 * 0.6 + 3 : tw(detailW, 2.6), tw(16, 2.4), place ? tw(place.length, 2.8) : 0)
|
const width = Math.max((pic ? 9 : 0) + (deg ? tw(main.label.length, 6) : 0), card ? detailW * 2 * 2.4 * 0.6 + 3 : tw(detailW, 2.6), tw(16, 2.4), place ? tw(place.length, 2.8) : 0)
|
||||||
const u = unit(lines * 4.2 + 3, width + 2)
|
const u = unit(lines * 4.2 + 3, width + 2)
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'grid', gap: u(0.8), justifyItems: 'inherit', ...(card ? { padding: u(1.5), borderRadius: u(1.5), background: w.background_colour ? undefined : 'rgba(0,0,0,0.28)' } : {}) }}
|
<div style={{ display: 'grid', gap: u(0.8), justifyItems: GRID[align], textAlign: align, ...(card ? { padding: u(1.5), borderRadius: u(1.5), background: w.background_colour ? undefined : 'rgba(0,0,0,0.28)' } : {}) }}
|
||||||
data-testid="signage-w-weather" data-layout={layout} data-style={style} data-from={from}>
|
data-testid="signage-w-weather" data-layout={layout} data-style={style} data-from={from}>
|
||||||
{place && <span style={{ ...text(u, 2.8, 700), opacity: 0.9 }}>{place}</span>}
|
{place && <span style={{ ...text(u, 2.8, 700), opacity: 0.9 }}>{place}</span>}
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: u(1.5) }}>
|
<div style={{ display: 'flex', alignItems: 'center', gap: u(1.5) }}>
|
||||||
@@ -746,11 +765,11 @@ function weatherBody(w, wx, unit, text, formatDate, t) {
|
|||||||
</div>
|
</div>
|
||||||
{words && <span style={{ ...text(u, 2.8, 600), opacity: 0.9 }} data-testid="signage-weather-words">{words}</span>}
|
{words && <span style={{ ...text(u, 2.8, 600), opacity: 0.9 }} data-testid="signage-weather-words">{words}</span>}
|
||||||
{details.length > 0 && (
|
{details.length > 0 && (
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: card ? 'auto auto' : 'auto', columnGap: u(2), rowGap: u(0.5) }}>
|
<div style={{ display: 'grid', gridTemplateColumns: card ? 'auto auto' : 'auto', columnGap: u(2), rowGap: u(0.5), justifyItems: GRID[align] }}>
|
||||||
{detailEls({ u, s: 2.6 }, u(0.6))}
|
{detailEls({ u, s: 2.6 }, u(0.6))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{rest.length > 0 && <div style={{ display: card ? 'flex' : 'grid', gap: u(card ? 1.6 : 0.4), flexWrap: 'wrap' }}>{restEls(u, 2.4)}</div>}
|
{rest.length > 0 && <div style={{ display: card ? 'flex' : 'grid', gap: u(card ? 1.6 : 0.4), flexWrap: 'wrap', justifyContent: SELF[align], justifyItems: GRID[align] }}>{restEls(u, 2.4)}</div>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -820,7 +839,7 @@ function Stack({ w, path, ctx }) {
|
|||||||
const wp = `${cp}.${k}`
|
const wp = `${cp}.${k}`
|
||||||
const own = cw.position === 'custom' && cw.box
|
const own = cw.position === 'custom' && cw.box
|
||||||
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
||||||
const body = widgetBody(cw, ctx, own && TIGHT.includes(cw.kind) ? 'tight' : true, wp)
|
const body = widgetBody(cw, ctx, own && TIGHT.includes(cw.kind) ? 'tight' : true, wp, align)
|
||||||
return (
|
return (
|
||||||
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size', position: 'relative',
|
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size', position: 'relative',
|
||||||
...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }}
|
...(own ? {} : { display: 'flex', alignItems: VSELF[cw.vertical] || 'center', justifyContent: SELF[align], textAlign: align }) }}
|
||||||
|
|||||||
@@ -481,10 +481,11 @@ export function fitBox(W, H, ratio) {
|
|||||||
|
|
||||||
/** A screen's picture area in its window: the window minus the calibrated insets (never smaller than 50 px). */
|
/** A screen's picture area in its window: the window minus the calibrated insets (never smaller than 50 px). */
|
||||||
export function pictureArea(win, area = {}) {
|
export function pictureArea(win, area = {}) {
|
||||||
const l = Math.max(0, area.left || 0)
|
// below 0 an edge reaches past the window the TV reported (owner 2026-11-23): that part is cut off
|
||||||
const t = Math.max(0, area.top || 0)
|
const l = area.left || 0
|
||||||
const width = Math.max(50, win.w - l - Math.max(0, area.right || 0))
|
const t = area.top || 0
|
||||||
const height = Math.max(50, win.h - t - Math.max(0, area.bottom || 0))
|
const width = Math.max(50, win.w - l - (area.right || 0))
|
||||||
|
const height = Math.max(50, win.h - t - (area.bottom || 0))
|
||||||
return { left: l, top: t, width, height }
|
return { left: l, top: t, width, height }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -264,6 +264,8 @@ test('slide shapes: custom ratios, the canvas, the box a slide keeps on any scre
|
|||||||
assert.deepEqual([c.left, c.top, c.width, c.height], [0, 60, 1920, 1080])
|
assert.deepEqual([c.left, c.top, c.width, c.height], [0, 60, 1920, 1080])
|
||||||
// calibration: the window minus the insets; the presets centre a shape
|
// calibration: the window minus the insets; the presets centre a shape
|
||||||
assert.deepEqual(pictureArea({ w: 1920, h: 1080 }, { left: 10, top: 0, right: 30, bottom: 20 }), { left: 10, top: 0, width: 1880, height: 1060 })
|
assert.deepEqual(pictureArea({ w: 1920, h: 1080 }, { left: 10, top: 0, right: 30, bottom: 20 }), { left: 10, top: 0, width: 1880, height: 1060 })
|
||||||
|
// below 0 an edge reaches past the window the TV reported (owner 2026-11-23)
|
||||||
|
assert.deepEqual(pictureArea({ w: 1920, h: 1080 }, { left: -40, top: -10, right: -40, bottom: 0 }), { left: -40, top: -10, width: 2000, height: 1090 })
|
||||||
assert.deepEqual(presetInsets({ w: 2560, h: 1080 }, '16:9'), { left: 320, top: 0, right: 320, bottom: 0 })
|
assert.deepEqual(presetInsets({ w: 2560, h: 1080 }, '16:9'), { left: 320, top: 0, right: 320, bottom: 0 })
|
||||||
assert.deepEqual(presetInsets({ w: 1920, h: 1080 }, 'full'), { left: 0, top: 0, right: 0, bottom: 0 })
|
assert.deepEqual(presetInsets({ w: 1920, h: 1080 }, 'full'), { left: 0, top: 0, right: 0, bottom: 0 })
|
||||||
assert.equal(shapeName(2560, 1080), '21:9')
|
assert.equal(shapeName(2560, 1080), '21:9')
|
||||||
|
|||||||
@@ -11,11 +11,14 @@ const Icon = ({ d }) => (
|
|||||||
* <NumberInput value={seconds} min={1} max={3600} onChange={setSeconds} suffix="s" />
|
* <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
|
* 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
|
* 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.
|
* when the field is left. Inside a <Field> it takes the field's id. With a `min` below 0 a minus
|
||||||
|
* may be typed in front (2026-11-23).
|
||||||
*/
|
*/
|
||||||
export function NumberInput({ value, onChange, min = 0, max = Infinity, step = 1, suffix, size = 'md', invalid = false, disabled = false, className, id, ...rest }) {
|
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 labels = useLabels()
|
||||||
const [focus, setFocus] = useState(false)
|
const [focus, setFocus] = useState(false)
|
||||||
|
const [draft, setDraft] = useState(null) // "-" typed, no digits yet
|
||||||
|
const signed = min < 0
|
||||||
const n = value === '' || value == null ? null : Number(value)
|
const n = value === '' || value == null ? null : Number(value)
|
||||||
const clamp = v => Math.min(max, Math.max(min, v))
|
const clamp = v => Math.min(max, Math.max(min, v))
|
||||||
const stepBy = d => onChange?.(clamp((n ?? min) + d))
|
const stepBy = d => onChange?.(clamp((n ?? min) + d))
|
||||||
@@ -24,14 +27,16 @@ export function NumberInput({ value, onChange, min = 0, max = Infinity, step = 1
|
|||||||
<button type="button" className="x-number__btn" onClick={() => stepBy(-step)} disabled={disabled || (n != null && n <= min)} aria-label={labels.decrease} tabIndex={-1}>
|
<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" />
|
<Icon d="M5 12h14" />
|
||||||
</button>
|
</button>
|
||||||
<input id={id} type="text" inputMode="numeric" className="x-number__input" value={n == null ? '' : String(n)} disabled={disabled}
|
<input id={id} type="text" inputMode={signed ? 'text' : 'numeric'} className="x-number__input" value={draft ?? (n == null ? '' : String(n))} disabled={disabled}
|
||||||
aria-invalid={invalid || undefined}
|
aria-invalid={invalid || undefined}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
|
const minus = signed && /^\s*-/.test(e.target.value)
|
||||||
const digits = e.target.value.replace(/\D/g, '')
|
const digits = e.target.value.replace(/\D/g, '')
|
||||||
onChange?.(digits === '' ? null : Math.min(max, Number(digits)))
|
setDraft(minus && digits === '' ? '-' : null)
|
||||||
|
onChange?.(digits === '' ? null : Math.min(max, (minus ? -1 : 1) * Number(digits)))
|
||||||
}}
|
}}
|
||||||
onFocus={() => setFocus(true)}
|
onFocus={() => setFocus(true)}
|
||||||
onBlur={() => { setFocus(false); if (n != null && n < min) onChange?.(min) }}
|
onBlur={() => { setFocus(false); setDraft(null); if (n != null && n < min) onChange?.(min) }}
|
||||||
onKeyDown={e => {
|
onKeyDown={e => {
|
||||||
if (e.key === 'ArrowUp') { e.preventDefault(); stepBy(step) }
|
if (e.key === 'ArrowUp') { e.preventDefault(); stepBy(step) }
|
||||||
if (e.key === 'ArrowDown') { e.preventDefault(); stepBy(-step) }
|
if (e.key === 'ArrowDown') { e.preventDefault(); stepBy(-step) }
|
||||||
|
|||||||
@@ -72,12 +72,14 @@ export default function SignageApp() {
|
|||||||
const { t } = useTranslation('terminal')
|
const { t } = useTranslation('terminal')
|
||||||
const { offline } = useDevice()
|
const { offline } = useDevice()
|
||||||
const [data, setData] = useState(readCache)
|
const [data, setData] = useState(readCache)
|
||||||
|
const [calib, setCalib] = useState(null) // the last signage.calibrate, until the next answer
|
||||||
const [now, setNow] = useState(() => new Date())
|
const [now, setNow] = useState(() => new Date())
|
||||||
|
|
||||||
const load = useCallback(async () => {
|
const load = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const { data: d } = await client.get('/api/signage/screen', quiet)
|
const { data: d } = await client.get('/api/signage/screen', quiet)
|
||||||
setData(prev => (prev?.version === d.version ? prev : d))
|
setData(prev => (prev?.version === d.version ? prev : d))
|
||||||
|
setCalib(null) // the answer is newer than any calibration event before it
|
||||||
writeCache(d)
|
writeCache(d)
|
||||||
} catch { /* keep playing what we have */ }
|
} catch { /* keep playing what we have */ }
|
||||||
}, [])
|
}, [])
|
||||||
@@ -100,8 +102,9 @@ export default function SignageApp() {
|
|||||||
}, [])
|
}, [])
|
||||||
useEffect(() => { report() }, [report, win.w, win.h])
|
useEffect(() => { report() }, [report, win.w, win.h])
|
||||||
useLiveEvent('ready', report)
|
useLiveEvent('ready', report)
|
||||||
const [calib, setCalib] = useState(null) // the last signage.calibrate: { on, area }
|
// the last signage.calibrate: { on, area }; the screen's answer is asked for too (owner 2026-11-23:
|
||||||
useLiveEvent('signage.calibrate', d => setCalib({ on: !!d?.on, area: d?.area || null }))
|
// the outline must show the first time, even when the event comes before the TV is listening)
|
||||||
|
useLiveEvent('signage.calibrate', d => { setCalib({ on: !!d?.on, area: d?.area || null }); load() })
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!calib?.on) return undefined
|
if (!calib?.on) return undefined
|
||||||
const id = setTimeout(() => setCalib({ on: false, area: null }), CALIBRATE_MS)
|
const id = setTimeout(() => setCalib({ on: false, area: null }), CALIBRATE_MS)
|
||||||
@@ -120,6 +123,12 @@ export default function SignageApp() {
|
|||||||
const tz = data?.schedule?.timezone
|
const tz = data?.schedule?.timezone
|
||||||
const screen = data?.screen
|
const screen = data?.screen
|
||||||
const calibrating = calib ? calib.on : !!screen?.calibrating
|
const calibrating = calib ? calib.on : !!screen?.calibrating
|
||||||
|
// while calibrating, the answer every few seconds (an edge moved while an event was missed)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!calibrating) return undefined
|
||||||
|
const id = setInterval(load, 4000)
|
||||||
|
return () => clearInterval(id)
|
||||||
|
}, [calibrating, load])
|
||||||
const pic = pictureArea(win, (calib?.on && calib.area) || screen?.area)
|
const pic = pictureArea(win, (calib?.on && calib.area) || screen?.area)
|
||||||
const frame = frameSize(screen?.rotation, pic)
|
const frame = frameSize(screen?.rotation, pic)
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ try {
|
|||||||
await mgr.getByTestId('signage-add-slide').click()
|
await mgr.getByTestId('signage-add-slide').click()
|
||||||
await mgr.getByTestId('signage-template-menuBoard').click()
|
await mgr.getByTestId('signage-template-menuBoard').click()
|
||||||
await mgr.getByTestId('signage-menu-editor').waitFor({ timeout: 10_000 })
|
await mgr.getByTestId('signage-menu-editor').waitFor({ timeout: 10_000 })
|
||||||
|
await mgr.locator('.x-overlay').waitFor({ state: 'detached', timeout: 5000 }).catch(() => {}) // the "Add a slide" dialog has gone
|
||||||
await mgr.getByTestId('signage-menu-select').click()
|
await mgr.getByTestId('signage-menu-select').click()
|
||||||
await mgr.getByRole('option', { name: 'Chosen categories and products' }).click()
|
await mgr.getByRole('option', { name: 'Chosen categories and products' }).click()
|
||||||
await mgr.locator(`[data-testid="signage-menu-category"][data-name="${catA.name}"]`).click()
|
await mgr.locator(`[data-testid="signage-menu-category"][data-name="${catA.name}"]`).click()
|
||||||
@@ -573,6 +574,13 @@ try {
|
|||||||
const plus = mgr.getByTestId('signage-calibrate-top').locator('xpath=..').locator('button').last()
|
const plus = mgr.getByTestId('signage-calibrate-top').locator('xpath=..').locator('button').last()
|
||||||
await plus.click(); await plus.click()
|
await plus.click(); await plus.click()
|
||||||
r.check('6R.13: …the top edge moved in 2 px with + (the TV follows)', await waitFor(async () => (await areaNow()) === '150,2,960,538', 8000, 200) === true, String(await areaNow()))
|
r.check('6R.13: …the top edge moved in 2 px with + (the TV follows)', await waitFor(async () => (await areaNow()) === '150,2,960,538', 8000, 200) === true, String(await areaNow()))
|
||||||
|
// 2026-11-23: an edge may go past the recognised window (a negative number)
|
||||||
|
const left = mgr.getByTestId('signage-calibrate-left')
|
||||||
|
await left.fill('-40'); await left.press('Tab')
|
||||||
|
r.check('2026-11-23: an edge pushed past the recognised window (-40 px): the picture on the TV reaches past it',
|
||||||
|
await waitFor(async () => (await areaNow()) === '-40,2,1150,538', 8000, 200) === true && await mgr.getByTestId('signage-calibrate-past').isVisible(), String(await areaNow()))
|
||||||
|
await left.fill('150'); await left.press('Tab')
|
||||||
|
await waitFor(async () => (await areaNow()) === '150,2,960,538', 8000, 200)
|
||||||
await mgr.screenshot({ path: path.join(OUT, 'signage-calibrate.png') })
|
await mgr.screenshot({ path: path.join(OUT, 'signage-calibrate.png') })
|
||||||
await tv.screenshot({ path: path.join(OUT, 'signage-calibrate-tv.png') })
|
await tv.screenshot({ path: path.join(OUT, 'signage-calibrate-tv.png') })
|
||||||
await mgr.getByTestId('signage-calibrate-done').click()
|
await mgr.getByTestId('signage-calibrate-done').click()
|
||||||
|
|||||||
Reference in New Issue
Block a user