feat(signage): look rows that wrap, one colour field with opacity, badges' text, several widgets per stack part, pages up to 2200 px (owner review 4)
- Menu text look: each field names its part ("Headings size"), rows wrap in aligned columns on
alternating bands; names align left / right; line and letter spacing as lists (Auto default);
each field changes only itself (followers frozen before the other changes); badge colour +
badge text colour (auto: readableOn); "Reset the look" with a question.
- ColourField everywhere in signage: a Popover panel (new @xenia/ui Popover, portal, kept in the
window) with 12 presets, picker, opacity (#rrggbbaa) and typed code; HEX accepts 8 digits.
- Stacks: Cell.widgets (a stored `widget` still reads), several widgets per part laid across the
stack's direction; extras by path stack.part.place; Add a widget adds, each removable / ordered.
- Page rule: --x-page-max is 2200px (no longer follows the window height).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -16,7 +16,7 @@
|
|||||||
Every page's root is `<Page>` from `@xenia/ui`. It provides:
|
Every page's root is `<Page>` from `@xenia/ui`. It provides:
|
||||||
|
|
||||||
- **its own scrolling** (the shell's `<main>` never scrolls),
|
- **its own scrolling** (the shell's `<main>` never scrolls),
|
||||||
- **the width:** it fills the content area up to the width of a 16:9 screen (`--x-page-max` = `max(1280px, 100vh × 16/9)`). On a 1080p monitor the page fills the screen; on an ultrawide it stays 16:9 wide and is **centred**,
|
- **the width:** it fills the content area up to 2200 px (`--x-page-max`). On a 1080p monitor the page fills the screen; on an ultrawide it stays 2200 px wide and is **centred**. The width never depends on the window's height (owner 2026-11-21: a short window used to narrow the page),
|
||||||
- **the padding and gaps** (`--x-page-pad`, `--x-page-gap`), the same on every page.
|
- **the padding and gaps** (`--x-page-pad`, `--x-page-gap`), the same on every page.
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
@@ -48,6 +48,7 @@ Every page is on `<Page>` except Inventory → Stock (a placeholder). Two-column
|
|||||||
| Filters / actions over a list | `Toolbar`, `ToolbarSpacer` | every control in it the same height; the search box grows |
|
| Filters / actions over a list | `Toolbar`, `ToolbarSpacer` | every control in it the same height; the search box grows |
|
||||||
| Search | `SearchInput` | icon, clear button; `onChange(text)` |
|
| Search | `SearchInput` | icon, clear button; `onChange(text)` |
|
||||||
| Choose one / several | `Dropdown` (`multiple`) | **never a native `<select>` in a toolbar.** Multi: value is an array, `[]` = all (`allLabel`). Options can carry a `dot` (a zone's colour) and a `hint`. Search box from 9 options. Same heights as `Input`. Native `Select` stays only inside forms where the phone's own picker is better |
|
| Choose one / several | `Dropdown` (`multiple`) | **never a native `<select>` in a toolbar.** Multi: value is an array, `[]` = all (`allLabel`). Options can carry a `dot` (a zone's colour) and a `hint`. Search box from 9 options. Same heights as `Input`. Native `Select` stays only inside forms where the phone's own picker is better |
|
||||||
|
| 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 toggle filter (a state) | `FilterChip` (`tone`, `count`) | |
|
| A toggle filter (a state) | `FilterChip` (`tone`, `count`) | |
|
||||||
| Two or three views (List / Map / QR) | `Segmented` | the view in the address (`?view=`) |
|
| Two or three views (List / Map / QR) | `Segmented` | the view in the address (`?view=`) |
|
||||||
| Sections of a page or a dialog | `Tabs` (`size="lg"` on pages) | scrolls sideways only, never up/down. `inset`: the strip is a card's header (card padding at the sides, the same room above and below a button in `end`, the labels level with it, no line under it). `fill`: the tabs share the width equally (a narrow column) |
|
| Sections of a page or a dialog | `Tabs` (`size="lg"` on pages) | scrolls sideways only, never up/down. `inset`: the strip is a card's header (card padding at the sides, the same room above and below a button in `end`, the labels level with it, no line under it). `fill`: the tabs share the width equally (a narrow column) |
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ from services.ws_bus import broadcast_sync
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
KEY = "signage.manage"
|
KEY = "signage.manage"
|
||||||
MESSAGE = "signage.message"
|
MESSAGE = "signage.message"
|
||||||
HEX = r"^#[0-9a-fA-F]{6}$"
|
HEX = r"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$" # #rrggbb, or #rrggbbaa (see-through, 2026-11-21)
|
||||||
TIME = r"^([01]\d|2[0-3]):[0-5]\d$"
|
TIME = r"^([01]\d|2[0-3]):[0-5]\d$"
|
||||||
DATE = r"^\d{4}-\d{2}-\d{2}$"
|
DATE = r"^\d{4}-\d{2}-\d{2}$"
|
||||||
Orientation = Literal["landscape", "portrait"]
|
Orientation = Literal["landscape", "portrait"]
|
||||||
@@ -133,7 +133,8 @@ class MenuList(_Strict):
|
|||||||
page_seconds: int = Field(default=10, ge=3, le=120)
|
page_seconds: int = Field(default=10, ge=3, le=120)
|
||||||
font: Font = "sans"
|
font: Font = "sans"
|
||||||
text_colour: str = Field(default="#ffffff", pattern=HEX)
|
text_colour: str = Field(default="#ffffff", pattern=HEX)
|
||||||
accent_colour: str = Field(default="#f59e0b", pattern=HEX) # prices, headings, badges
|
accent_colour: str = Field(default="#f59e0b", pattern=HEX) # badges, page dots (headings and prices unless their own)
|
||||||
|
badge_text_colour: Optional[str] = Field(default=None, pattern=HEX) # None: white or black, to read on the badge
|
||||||
text_size: int = Field(default=100, ge=50, le=250)
|
text_size: int = Field(default=100, ge=50, le=250)
|
||||||
# the look of each part (owner review 3, 2026-11-21)
|
# the look of each part (owner review 3, 2026-11-21)
|
||||||
heading_style: TextStyle = Field(default_factory=TextStyle)
|
heading_style: TextStyle = Field(default_factory=TextStyle)
|
||||||
@@ -188,16 +189,28 @@ class Box(_Strict):
|
|||||||
|
|
||||||
class Cell(_Strict):
|
class Cell(_Strict):
|
||||||
"""A part of a stack (2026-11-21): its share of the stack (the parts' shares are weights; the
|
"""A part of a stack (2026-11-21): its share of the stack (the parts' shares are weights; the
|
||||||
editor keeps them adding up to 100) and what it shows: a widget (another stack too, one level
|
editor keeps them adding up to 100) and what it shows: widgets (another stack too, one level
|
||||||
deep) or a slide of the Slides library, drawn whole inside the part; or nothing."""
|
deep; several share the part, one over the other in a side-by-side stack, side by side in the
|
||||||
|
other), or a slide of the Slides library, drawn whole inside the part; or nothing."""
|
||||||
share: float = Field(default=50, ge=1, le=100)
|
share: float = Field(default=50, ge=1, le=100)
|
||||||
widget: Optional["Widget"] = None
|
widgets: List["Widget"] = Field(default_factory=list, max_length=6)
|
||||||
slide_id: Optional[int] = None
|
slide_id: Optional[int] = None
|
||||||
|
|
||||||
|
@model_validator(mode="before")
|
||||||
|
@classmethod
|
||||||
|
def _one_widget(cls, v):
|
||||||
|
# a part held one widget (`widget`) until owner review 4 (2026-11-21)
|
||||||
|
if isinstance(v, dict) and "widget" in v:
|
||||||
|
v = dict(v)
|
||||||
|
w = v.pop("widget")
|
||||||
|
if w is not None:
|
||||||
|
v["widgets"] = [w, *(v.get("widgets") or [])]
|
||||||
|
return v
|
||||||
|
|
||||||
@model_validator(mode="after")
|
@model_validator(mode="after")
|
||||||
def _one(self):
|
def _one(self):
|
||||||
if self.widget is not None and self.slide_id is not None:
|
if self.widgets and self.slide_id is not None:
|
||||||
raise ValueError("a part shows a widget or a slide, not both")
|
raise ValueError("a part shows widgets or a slide, not both")
|
||||||
self.share = round(self.share, 2)
|
self.share = round(self.share, 2)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@@ -461,20 +474,26 @@ def media_ids(value) -> list[int]:
|
|||||||
|
|
||||||
|
|
||||||
def walk_widgets(widgets, prefix: str = ""):
|
def walk_widgets(widgets, prefix: str = ""):
|
||||||
"""Every widget of a slide, inside stacks too, with its path ("2", "2.0", "2.1.1": the widget's
|
"""Every widget of a slide, inside stacks too, with its path ("2"; "2.1.0": the widget's index,
|
||||||
index, then its part's): → (path, widget, None), and (path, None, slide id) for a part that
|
then its part's, then its place in the part): → (path, widget, None), and ("2.1", None, slide
|
||||||
shows a library slide. The editor and the player find a widget's extras by its path."""
|
id) for a part that shows a library slide. The editor and the player find a widget's extras by its path."""
|
||||||
for i, w in enumerate(widgets or []):
|
for i, w in enumerate(widgets or []):
|
||||||
yield from _walk_one(w, f"{prefix}{i}")
|
yield from _walk_one(w, f"{prefix}{i}")
|
||||||
|
|
||||||
|
|
||||||
|
def cell_widgets(c: dict) -> list:
|
||||||
|
"""A part's widgets (stored before owner review 4 as one `widget`)."""
|
||||||
|
return c.get("widgets") or ([c["widget"]] if c.get("widget") else [])
|
||||||
|
|
||||||
|
|
||||||
def _walk_one(w: dict, path: str):
|
def _walk_one(w: dict, path: str):
|
||||||
yield path, w, None
|
yield path, w, None
|
||||||
for j, c in enumerate(w.get("cells") or []):
|
for j, c in enumerate(w.get("cells") or []):
|
||||||
cp = f"{path}.{j}"
|
cp = f"{path}.{j}"
|
||||||
if c.get("widget"):
|
ws = cell_widgets(c)
|
||||||
yield from _walk_one(c["widget"], cp)
|
for k, cw in enumerate(ws):
|
||||||
elif c.get("slide_id"):
|
yield from _walk_one(cw, f"{cp}.{k}")
|
||||||
|
if not ws and c.get("slide_id"):
|
||||||
yield cp, None, c["slide_id"]
|
yield cp, None, c["slide_id"]
|
||||||
|
|
||||||
|
|
||||||
@@ -542,7 +561,7 @@ def _content(db, kind: str, raw: dict | None) -> dict:
|
|||||||
raise XeniaError("media.not_a_picture")
|
raise XeniaError("media.not_a_picture")
|
||||||
for path, w, sid in found:
|
for path, w, sid in found:
|
||||||
# a stack inside a stack, not deeper (2026-11-21)
|
# a stack inside a stack, not deeper (2026-11-21)
|
||||||
if w and w.get("kind") == "stack" and path.count(".") > 1:
|
if w and w.get("kind") == "stack" and path.count(".") > 2:
|
||||||
raise XeniaError("signage.content_invalid", field=f"widgets.{path}", reason="a stack goes at most one stack deep")
|
raise XeniaError("signage.content_invalid", field=f"widgets.{path}", reason="a stack goes at most one stack deep")
|
||||||
if sid and db.get(SignageSavedSlide, sid) is None:
|
if sid and db.get(SignageSavedSlide, sid) is None:
|
||||||
raise XeniaError("signage.slide_unknown", slide_id=sid)
|
raise XeniaError("signage.slide_unknown", slide_id=sid)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def test_text_weather_and_stack_widgets_are_checked(client, owner_h):
|
|||||||
ws = s["content"]["widgets"]
|
ws = s["content"]["widgets"]
|
||||||
assert ws[0]["text"] == "Happy hour 18-20"
|
assert ws[0]["text"] == "Happy hour 18-20"
|
||||||
assert ws[1]["weather_from"] == 1 and ws[1]["weather_days"] == 2 and ws[1]["weather_style"] == "icon" # the forecast has 3 days
|
assert ws[1]["weather_from"] == 1 and ws[1]["weather_days"] == 2 and ws[1]["weather_style"] == "icon" # the forecast has 3 days
|
||||||
assert [c["share"] for c in ws[2]["cells"]] == [30, 70] and ws[2]["cells"][1]["widget"]["direction"] == "column"
|
assert [c["share"] for c in ws[2]["cells"]] == [30, 70] and ws[2]["cells"][1]["widgets"][0]["direction"] == "column"
|
||||||
assert ws[0]["cells"] == [] and ws[0]["board"] is None
|
assert ws[0]["cells"] == [] and ws[0]["board"] is None
|
||||||
url = f"/api/signage/playlists/{p['id']}/slides"
|
url = f"/api/signage/playlists/{p['id']}/slides"
|
||||||
bad = [
|
bad = [
|
||||||
@@ -57,12 +57,12 @@ def test_a_stack_shows_a_library_slide_and_a_menu_widget(client, owner_h, screen
|
|||||||
got = client.get("/api/signage/screen", headers=tv["h"]).json()["playlist"]["slides"][0]
|
got = client.get("/api/signage/screen", headers=tv["h"]).json()["playlist"]["slides"][0]
|
||||||
ex = got["extras"]
|
ex = got["extras"]
|
||||||
assert ex["0"]["link"] and got["content"]["widgets"][0]["link"] == ex["0"]["link"]
|
assert ex["0"]["link"] and got["content"]["widgets"][0]["link"] == ex["0"]["link"]
|
||||||
assert names(ex["1.0"]["menu"]) == [] and ex["1.0"]["menu"]["count"] == 0 # Beer hidden; Wine: delivery only
|
assert names(ex["1.0.0"]["menu"]) == [] and ex["1.0.0"]["menu"]["count"] == 0 # Beer hidden; Wine: delivery only
|
||||||
inner = ex["1.1"]["slide"]
|
inner = ex["1.1"]["slide"]
|
||||||
assert inner["id"] == promo["id"] and inner["kind"] == "text" and inner["content"]["title"] == "Fresh fish"
|
assert inner["id"] == promo["id"] and inner["kind"] == "text" and inner["content"]["title"] == "Fresh fish"
|
||||||
assert inner["extras"]["0"]["link"] # its own widgets' extras
|
assert inner["extras"]["0"]["link"] # its own widgets' extras
|
||||||
# the editor: the hidden product stays in the list, marked
|
# the editor: the hidden product stays in the list, marked
|
||||||
ed = client.get(f"/api/signage/playlists/{p['id']}", headers=owner_h).json()["slides"][0]["extras"]["1.0"]["menu"]
|
ed = client.get(f"/api/signage/playlists/{p['id']}", headers=owner_h).json()["slides"][0]["extras"]["1.0.0"]["menu"]
|
||||||
assert [(i["name"], i.get("hidden", False)) for g in ed["groups"] for i in g["items"]] == [("Beer", True)] and ed["count"] == 0
|
assert [(i["name"], i.get("hidden", False)) for g in ed["groups"] for i in g["items"]] == [("Beer", True)] and ed["count"] == 0
|
||||||
# a change to the library slide reaches the screens that show it inside a stack
|
# a change to the library slide reaches the screens that show it inside a stack
|
||||||
sent.clear()
|
sent.clear()
|
||||||
@@ -89,7 +89,7 @@ def test_the_editor_previews_any_slide(client, owner_h, menu):
|
|||||||
{"share": 50, "slide_id": promo["id"]})]}})
|
{"share": 50, "slide_id": promo["id"]})]}})
|
||||||
assert r.status_code == 200, r.text
|
assert r.status_code == 200, r.text
|
||||||
got = r.json()
|
got = r.json()
|
||||||
assert [i.get("hidden") for g in got["extras"]["0.0"]["menu"]["groups"] for i in g["items"]] == [True]
|
assert [i.get("hidden") for g in got["extras"]["0.0.0"]["menu"]["groups"] for i in g["items"]] == [True]
|
||||||
assert got["extras"]["0.1"]["slide"]["content"]["title"] == "Inside" and got["menu"] is None and got["media"] == {}
|
assert got["extras"]["0.1"]["slide"]["content"]["title"] == "Inside" and got["menu"] is None and got["media"] == {}
|
||||||
r = client.post("/api/signage/preview/slide", headers=owner_h, json={"kind": "menu", "content": {"select": "all", "exclude_ids": [menu["beer"].id]}})
|
r = client.post("/api/signage/preview/slide", headers=owner_h, json={"kind": "menu", "content": {"select": "all", "exclude_ids": [menu["beer"].id]}})
|
||||||
m = r.json()["menu"]
|
m = r.json()["menu"]
|
||||||
@@ -117,3 +117,27 @@ def test_a_board_has_its_own_names_and_the_look_of_each_part(client, owner_h, me
|
|||||||
url = f"/api/signage/playlists/{p['id']}/slides"
|
url = f"/api/signage/playlists/{p['id']}/slides"
|
||||||
for bad in ({"names": {"x": "a"}}, {"heading_style": {"size": 20}}, {"dot_style": {"style": "wavy"}}, {"line_height": 9}, {"photo_shape": "star"}):
|
for bad in ({"names": {"x": "a"}}, {"heading_style": {"size": 20}}, {"dot_style": {"style": "wavy"}}, {"line_height": 9}, {"photo_shape": "star"}):
|
||||||
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": bad})) == "signage.content_invalid", bad
|
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": bad})) == "signage.content_invalid", bad
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_part_holds_several_widgets_and_colours_can_be_see_through(client, owner_h, menu):
|
||||||
|
"""Owner review 4 (2026-11-21): a stack's part holds several widgets (each with its own extras,
|
||||||
|
by path "stack.part.place"); a part stored with one `widget` still reads; colours #rrggbbaa; a
|
||||||
|
board's badges have their own text colour."""
|
||||||
|
p = playlist(client, owner_h)
|
||||||
|
s = slide(client, owner_h, p["id"], "blank", content={"background": {"colour": "#11182780"}, "widgets": [
|
||||||
|
stack({"share": 40, "widgets": [{"kind": "clock"}, {"kind": "qr"}, {"kind": "menu", "board": {"product_ids": [menu["steak"].id]}}]},
|
||||||
|
{"share": 60, "widget": {"kind": "date"}}),
|
||||||
|
]})
|
||||||
|
cells = s["content"]["widgets"][0]["cells"]
|
||||||
|
assert [w["kind"] for w in cells[0]["widgets"]] == ["clock", "qr", "menu"] and [w["kind"] for w in cells[1]["widgets"]] == ["date"]
|
||||||
|
assert "widget" not in cells[1] and s["content"]["background"]["colour"] == "#11182780"
|
||||||
|
ex = client.get(f"/api/signage/playlists/{p['id']}", headers=owner_h).json()["slides"][0]["extras"]
|
||||||
|
assert ex["0.0.1"]["link"] and names(ex["0.0.2"]["menu"]) == [["Grill", ["Steak"]]]
|
||||||
|
url = f"/api/signage/playlists/{p['id']}/slides"
|
||||||
|
for bad in (stack({"share": 50, "widgets": [{"kind": "clock"}], "slide_id": 1}),
|
||||||
|
stack({"share": 50, "widgets": [{"kind": "clock"}] * 7})):
|
||||||
|
assert err(client.post(url, headers=owner_h, json={"kind": "blank", "content": {"widgets": [bad]}})) == "signage.content_invalid", bad
|
||||||
|
m = slide(client, owner_h, p["id"], "menu", content={"accent_colour": "#1e3a8a", "badge_text_colour": "#fde68aCC"})["content"]
|
||||||
|
assert m["badge_text_colour"] == "#fde68aCC" and m["accent_colour"] == "#1e3a8a"
|
||||||
|
for bad in ({"badge_text_colour": "#fff"}, {"text_colour": "#12345"}):
|
||||||
|
assert err(client.post(url, headers=owner_h, json={"kind": "menu", "content": bad})) == "signage.content_invalid", bad
|
||||||
|
|||||||
@@ -1,108 +1,154 @@
|
|||||||
// A menu's look, part by part (owner review 3, 2026-11-21), for menu slides and menu widgets alike:
|
// A menu's look, part by part (owner review 3, 2026-11-21), for menu slides and menu widgets alike:
|
||||||
// one row each for the headings, the product names and the prices (size, colour, font, bold /
|
// headings, product names and prices (size, colour, font, bold / italic / underline, alignment),
|
||||||
// italic / underline, alignment), the dots between name and price (size, colour, style), and the
|
// the dots between name and price with the badges' colours, the spacing (line and letter spacing:
|
||||||
// spacing (line and letter spacing: empty = auto) with the photos' size and shape and the accent
|
// Auto or a choice) with the photos' size and shape. The player draws it (menuLook).
|
||||||
// (badges, page dots). The names' row sets the board's own text size, colour and font; headings and
|
// Owner review 4 (2026-11-21): every field says what it sets ("Headings size"), so a row needs no
|
||||||
// prices follow them (the accent colour) until given their own. The player draws it (menuLook).
|
// title; fields keep their width and wrap to a second line, each row on its own band. Every field
|
||||||
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-react'
|
// changes only itself: a part that still follows another (headings and prices take the names' size
|
||||||
|
// and the accent colour, the dots the text colour) is given that value before the other changes.
|
||||||
|
// Names align left or right; "Reset the look" puts every part back.
|
||||||
|
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, RotateCcw, Underline } from 'lucide-react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { Dropdown, Field, Input, Segmented } from '@xenia/ui'
|
import { Button, Dropdown, Field, Segmented, useConfirm } from '@xenia/ui'
|
||||||
import { FONT_KEYS, MENU_COLOURS } from './signageLogic'
|
import { readableOn } from '@xenia/signage'
|
||||||
|
import { FONT_KEYS, joinAlpha, LETTER_SPACINGS, LINE_HEIGHTS, MENU_COLOURS, MENU_LOOK_DEFAULTS, splitAlpha } from './signageLogic'
|
||||||
import { ColourField, Range, Section } from './SignageFields'
|
import { ColourField, Range, Section } from './SignageFields'
|
||||||
|
|
||||||
const ROW = 'grid gap-3 items-end grid-cols-2 lg:grid-cols-[7rem_repeat(5,minmax(0,1fr))]'
|
const ALIGN_ICONS = { left: AlignLeft, center: AlignCenter, right: AlignRight }
|
||||||
|
|
||||||
export default function MenuLook({ c, setC }) {
|
export default function MenuLook({ c, setC }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
|
const [confirm, confirmDialog] = useConfirm()
|
||||||
const base = c.text_size || 100
|
const base = c.text_size || 100
|
||||||
const accent = c.accent_colour || MENU_COLOURS.accent
|
const accent = c.accent_colour || MENU_COLOURS.accent
|
||||||
|
const text = c.text_colour || MENU_COLOURS.text
|
||||||
const style = key => c[key] || {}
|
const style = key => c[key] || {}
|
||||||
const setStyle = (key, patch) => setC({ [key]: { ...style(key), ...patch } })
|
const setStyle = (key, patch) => setC({ [key]: { ...style(key), ...patch } })
|
||||||
|
const h = style('heading_style')
|
||||||
|
const p = style('price_style')
|
||||||
|
const d = style('dot_style')
|
||||||
|
const dotsAuto = joinAlpha(splitAlpha(text).rgb, 35) // the player's faint text colour
|
||||||
|
const L = (part, field) => t(`signage.look.f.${part}.${field}`)
|
||||||
const fontOptions = inherit => [...(inherit ? [{ value: '', label: t('signage.look.sameFont') }] : []), ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]
|
const fontOptions = inherit => [...(inherit ? [{ value: '', label: t('signage.look.sameFont') }] : []), ...FONT_KEYS.map(x => ({ value: x, label: t(`signage.fonts.${x}`) }))]
|
||||||
const num = (v, lo, hi) => {
|
|
||||||
const n = Number(String(v).replace(',', '.'))
|
// each changes only itself: what followed it keeps what it showed
|
||||||
return v === '' || Number.isNaN(n) ? null : Math.min(hi, Math.max(lo, n))
|
const setNamesSize = v => setC({ text_size: v, heading_style: { ...h, size: h.size || base }, price_style: { ...p, size: p.size || base } })
|
||||||
|
const setNamesColour = v => setC({ text_colour: v, dot_style: { ...d, colour: d.colour || dotsAuto } })
|
||||||
|
const setAccent = v => setC({ accent_colour: v, heading_style: { ...h, colour: h.colour || accent }, price_style: { ...p, colour: p.colour || accent } })
|
||||||
|
|
||||||
|
const reset = async () => {
|
||||||
|
if (await confirm({ title: t('signage.look.resetTitle'), body: t('signage.look.resetBody'), confirmLabel: t('signage.look.reset'), testId: 'signage-look-reset-confirm' })) {
|
||||||
|
setC(MENU_LOOK_DEFAULTS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A row for headings / names / prices: size, colour, font, style, alignment. */
|
const cell = (_w, node) => <div className="min-w-0">{node}</div>
|
||||||
const partRow = (key, label, { size, colour, font, onSize, onColour, onFont, inherit, align }) => {
|
|
||||||
|
/** Headings, names or prices: size, colour, font, style, alignment. */
|
||||||
|
const partRow = (part, key, { size, colour, font, onSize, onColour, onFont, inherit, align, aligns = ['left', 'center', 'right'] }) => {
|
||||||
const s = style(key)
|
const s = style(key)
|
||||||
return (
|
return (
|
||||||
<div className={ROW} data-testid={`signage-look-${key}`}>
|
<Band testid={`signage-look-${key}`}>
|
||||||
<RowLabel>{label}</RowLabel>
|
{cell('size', <Range label={L(part, 'size')} value={size} min={50} max={300} step={10} suffix="%" onChange={onSize} testid={`signage-look-${key}-size`} />)}
|
||||||
<Range label={t('signage.look.size')} value={size} min={50} max={300} step={10} suffix="%" onChange={onSize} testid={`signage-look-${key}-size`} />
|
{cell('colour', <ColourField label={L(part, 'colour')} value={colour} onChange={onColour} testid={`signage-look-${key}-colour`} />)}
|
||||||
<ColourField compact label={t('signage.look.colour')} value={colour} onChange={onColour} testid={`signage-look-${key}-colour`} />
|
{cell('font', (
|
||||||
<Field label={t('signage.look.font')}>
|
<Field label={L(part, 'font')}>
|
||||||
<Dropdown value={font} onChange={onFont} options={fontOptions(inherit)} data-testid={`signage-look-${key}-font`} />
|
<Dropdown value={font} onChange={onFont} options={fontOptions(inherit)} data-testid={`signage-look-${key}-font`} />
|
||||||
</Field>
|
</Field>
|
||||||
<Field label={t('signage.look.style')}>
|
))}
|
||||||
|
{cell('style', (
|
||||||
|
<Field label={L(part, 'style')}>
|
||||||
<TextToggles s={s} onChange={patch => setStyle(key, patch)} testid={`signage-look-${key}`} />
|
<TextToggles s={s} onChange={patch => setStyle(key, patch)} testid={`signage-look-${key}`} />
|
||||||
</Field>
|
</Field>
|
||||||
<Field label={t('signage.look.align')}>
|
))}
|
||||||
<Segmented value={s.align || align} onChange={v => setStyle(key, { align: v })} fill data-testid={`signage-look-${key}-align`}
|
{cell('align', (
|
||||||
options={[['left', AlignLeft], ['center', AlignCenter], ['right', AlignRight]].map(([v, Icon]) => (
|
<Field label={L(part, 'align')}>
|
||||||
{ value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.aligns.${v}`), testId: `signage-look-${key}-align-${v}` }))} />
|
<Segmented value={aligns.includes(s.align) ? s.align : align} onChange={v => setStyle(key, { align: v })} fill data-testid={`signage-look-${key}-align`}
|
||||||
|
options={aligns.map(v => {
|
||||||
|
const Icon = ALIGN_ICONS[v]
|
||||||
|
return { value: v, icon: <Icon size={16} aria-hidden="true" />, ariaLabel: t(`signage.aligns.${v}`), testId: `signage-look-${key}-align-${v}` }
|
||||||
|
})} />
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
))}
|
||||||
|
</Band>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const d = style('dot_style')
|
const choices = (list, current, label) => {
|
||||||
|
const values = current != null && !list.includes(current) ? [...list, current].sort((a, b) => a - b) : list
|
||||||
|
return [{ value: '', label: t('signage.look.auto') }, ...values.map(x => ({ value: String(x), label: label(x) }))]
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Section title={t('signage.textLook')} testid="signage-text-look">
|
<Section title={t('signage.textLook')} testid="signage-text-look"
|
||||||
<div className="grid gap-5">
|
aside={<Button size="sm" variant="ghost" icon={<RotateCcw size={14} />} onClick={reset} data-testid="signage-look-reset">{t('signage.look.reset')}</Button>}>
|
||||||
{partRow('heading_style', t('signage.look.headings'), {
|
<div className="grid gap-2">
|
||||||
size: style('heading_style').size || base, onSize: v => setStyle('heading_style', { size: v }),
|
{partRow('heading', 'heading_style', {
|
||||||
colour: style('heading_style').colour || accent, onColour: v => setStyle('heading_style', { colour: v }),
|
size: h.size || base, onSize: v => setStyle('heading_style', { size: v }),
|
||||||
font: style('heading_style').font || '', onFont: v => setStyle('heading_style', { font: v || null }), inherit: true,
|
colour: h.colour || accent, onColour: v => setStyle('heading_style', { colour: v }),
|
||||||
|
font: h.font || '', onFont: v => setStyle('heading_style', { font: v || null }), inherit: true,
|
||||||
align: c.board_align || 'left',
|
align: c.board_align || 'left',
|
||||||
})}
|
})}
|
||||||
{partRow('item_style', t('signage.look.names'), {
|
{partRow('item', 'item_style', {
|
||||||
size: base, onSize: v => setC({ text_size: v }),
|
size: base, onSize: setNamesSize,
|
||||||
colour: c.text_colour || MENU_COLOURS.text, onColour: v => setC({ text_colour: v }),
|
colour: text, onColour: setNamesColour,
|
||||||
font: c.font || 'sans', onFont: v => setC({ font: v }), inherit: false, align: 'left',
|
font: c.font || 'sans', onFont: v => setC({ font: v }), inherit: false, align: 'left', aligns: ['left', 'right'],
|
||||||
})}
|
})}
|
||||||
{partRow('price_style', t('signage.look.prices'), {
|
{partRow('price', 'price_style', {
|
||||||
size: style('price_style').size || base, onSize: v => setStyle('price_style', { size: v }),
|
size: p.size || base, onSize: v => setStyle('price_style', { size: v }),
|
||||||
colour: style('price_style').colour || accent, onColour: v => setStyle('price_style', { colour: v }),
|
colour: p.colour || accent, onColour: v => setStyle('price_style', { colour: v }),
|
||||||
font: style('price_style').font || '', onFont: v => setStyle('price_style', { font: v || null }), inherit: true, align: 'right',
|
font: p.font || '', onFont: v => setStyle('price_style', { font: v || null }), inherit: true, align: 'right',
|
||||||
})}
|
})}
|
||||||
<div className={ROW} data-testid="signage-look-dots">
|
<Band testid="signage-look-dots">
|
||||||
<RowLabel>{t('signage.look.dots')}</RowLabel>
|
{cell('size', <Range label={L('dots', 'size')} value={d.size || 100} min={50} max={300} step={10} suffix="%" onChange={v => setStyle('dot_style', { size: v })} testid="signage-look-dots-size" />)}
|
||||||
<Range label={t('signage.look.size')} value={d.size || 100} min={50} max={300} step={10} suffix="%" onChange={v => setStyle('dot_style', { size: v })} testid="signage-look-dots-size" />
|
{cell('colour', <ColourField label={L('dots', 'colour')} value={d.colour || dotsAuto} onChange={v => setStyle('dot_style', { colour: v })} testid="signage-look-dots-colour" />)}
|
||||||
<ColourField compact label={t('signage.look.colour')} value={d.colour || c.text_colour || MENU_COLOURS.text} onChange={v => setStyle('dot_style', { colour: v })} testid="signage-look-dots-colour" />
|
{cell('font', (
|
||||||
<Field label={t('signage.look.dotStyle')}>
|
<Field label={L('dots', 'line')}>
|
||||||
<Dropdown value={d.style || 'dotted'} onChange={v => setStyle('dot_style', { style: v })} data-testid="signage-look-dots-style"
|
<Dropdown value={d.style || 'dotted'} onChange={v => setStyle('dot_style', { style: v })} data-testid="signage-look-dots-style"
|
||||||
options={['dotted', 'dashed', 'solid', 'none'].map(x => ({ value: x, label: t(`signage.look.dotStyles.${x}`) }))} />
|
options={['dotted', 'dashed', 'solid', 'none'].map(x => ({ value: x, label: t(`signage.look.dotStyles.${x}`) }))} />
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
))}
|
||||||
<div className={ROW} data-testid="signage-look-spacing">
|
{cell('colour', <ColourField label={t('signage.look.badgeColour')} value={accent} onChange={setAccent} testid="signage-accent" />)}
|
||||||
<RowLabel>{t('signage.look.spacing')}</RowLabel>
|
{cell('colour', <ColourField label={t('signage.look.badgeText')} value={c.badge_text_colour || readableOn(accent)} onChange={v => setC({ badge_text_colour: v })}
|
||||||
|
testid="signage-badge-text" auto={{ label: t('signage.look.badgeTextAuto'), on: !c.badge_text_colour, pick: () => setC({ badge_text_colour: null }) }} />)}
|
||||||
|
</Band>
|
||||||
|
<Band testid="signage-look-spacing">
|
||||||
|
{cell('font', (
|
||||||
<Field label={t('signage.look.lineHeight')}>
|
<Field label={t('signage.look.lineHeight')}>
|
||||||
<Input inputMode="decimal" value={c.line_height ?? ''} placeholder={t('signage.look.auto')} data-testid="signage-look-line-height"
|
<Dropdown value={c.line_height != null ? String(c.line_height) : ''} onChange={v => setC({ line_height: v === '' ? null : Number(v) })} data-testid="signage-look-line-height"
|
||||||
onChange={e => setC({ line_height: num(e.target.value, 0.8, 3) })} />
|
options={choices(LINE_HEIGHTS, c.line_height, x => `${x}×`)} />
|
||||||
</Field>
|
</Field>
|
||||||
|
))}
|
||||||
|
{cell('font', (
|
||||||
<Field label={t('signage.look.letterSpacing')}>
|
<Field label={t('signage.look.letterSpacing')}>
|
||||||
<Input inputMode="decimal" value={c.letter_spacing ?? ''} placeholder={t('signage.look.auto')} data-testid="signage-look-letter-spacing"
|
<Dropdown value={c.letter_spacing != null ? String(c.letter_spacing) : ''} onChange={v => setC({ letter_spacing: v === '' ? null : Number(v) })} data-testid="signage-look-letter-spacing"
|
||||||
onChange={e => setC({ letter_spacing: num(e.target.value, -0.1, 0.5) })} />
|
options={choices(LETTER_SPACINGS, c.letter_spacing, x => `${x > 0 ? '+' : ''}${Math.round(x * 100)}%`)} />
|
||||||
</Field>
|
</Field>
|
||||||
{c.show_photos ? <>
|
))}
|
||||||
<Range label={t('signage.look.photoSize')} value={c.photo_size || 100} min={50} max={250} step={10} suffix="%" onChange={v => setC({ photo_size: v })} testid="signage-look-photo-size" />
|
{c.show_photos && <>
|
||||||
|
{cell('size', <Range label={t('signage.look.photoSize')} value={c.photo_size || 100} min={50} max={250} step={10} suffix="%" onChange={v => setC({ photo_size: v })} testid="signage-look-photo-size" />)}
|
||||||
|
{cell('font', (
|
||||||
<Field label={t('signage.look.photoShape')}>
|
<Field label={t('signage.look.photoShape')}>
|
||||||
<Dropdown value={c.photo_shape || 'rounded'} onChange={v => setC({ photo_shape: v })} data-testid="signage-look-photo-shape"
|
<Dropdown value={c.photo_shape || 'rounded'} onChange={v => setC({ photo_shape: v })} data-testid="signage-look-photo-shape"
|
||||||
options={['square', 'rounded', 'round'].map(x => ({ value: x, label: t(`signage.look.shapes.${x}`) }))} />
|
options={['square', 'rounded', 'round'].map(x => ({ value: x, label: t(`signage.look.shapes.${x}`) }))} />
|
||||||
</Field>
|
</Field>
|
||||||
</> : <><span className="hidden lg:block" /><span className="hidden lg:block" /></>}
|
))}
|
||||||
<ColourField compact label={t('signage.look.accent')} value={accent} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
</>}
|
||||||
</div>
|
</Band>
|
||||||
<p className="text-caption text-ink-3 -mt-2">{t('signage.look.hint')}</p>
|
<p className="text-caption text-ink-3 mt-1">{t('signage.look.hint')}</p>
|
||||||
</div>
|
</div>
|
||||||
|
{confirmDialog}
|
||||||
</Section>
|
</Section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function RowLabel({ children }) {
|
/** A row of the look: its fields keep their least width and wrap to a second line, in columns that
|
||||||
return <span className="col-span-2 lg:col-span-1 lg:h-control flex items-center text-label font-semibold text-ink">{children}</span>
|
* line up from row to row; rows alternate shades. */
|
||||||
|
function Band({ testid, children }) {
|
||||||
|
return (
|
||||||
|
<div className="grid gap-3 items-end grid-cols-[repeat(auto-fill,minmax(10.5rem,1fr))] rounded-control border border-line p-3 bg-surface even:bg-surface-2" data-testid={testid}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Bold, italic, underline: three toggles as tall as a field. */
|
/** Bold, italic, underline: three toggles as tall as a field. */
|
||||||
@@ -114,7 +160,7 @@ function TextToggles({ s, onChange, testid }) {
|
|||||||
{items.map(([k, Icon, on]) => (
|
{items.map(([k, Icon, on]) => (
|
||||||
<button key={k} type="button" aria-pressed={on} aria-label={t(`signage.look.${k}`)} title={t(`signage.look.${k}`)}
|
<button key={k} type="button" aria-pressed={on} aria-label={t(`signage.look.${k}`)} title={t(`signage.look.${k}`)}
|
||||||
onClick={() => onChange({ [k]: !on })} data-testid={`${testid}-${k}`}
|
onClick={() => onChange({ [k]: !on })} data-testid={`${testid}-${k}`}
|
||||||
className={`flex-1 grid place-items-center rounded-[calc(var(--x-radius-control)-2px)] transition-colors duration-fast
|
className={`flex-1 min-w-[2rem] grid place-items-center rounded-[calc(var(--x-radius-control)-2px)] transition-colors duration-fast
|
||||||
${on ? 'bg-accent-soft text-accent-ink' : 'text-ink-2 hover:bg-surface-2'}`}>
|
${on ? 'bg-accent-soft text-accent-ink' : 'text-ink-2 hover:bg-surface-2'}`}>
|
||||||
<Icon size={16} aria-hidden="true" />
|
<Icon size={16} aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -3,12 +3,13 @@
|
|||||||
// a background (colour or photo with darkening), a slider with its value.
|
// a background (colour or photo with darkening), a slider with its value.
|
||||||
// 2026-11-21 (owner review 2): the slider framed like the fields beside it; a colour as a field
|
// 2026-11-21 (owner review 2): the slider framed like the fields beside it; a colour as a field
|
||||||
// (its swatch and code) that opens the ready colours and the picker, so it fits a row of fields.
|
// (its swatch and code) that opens the ready colours and the picker, so it fits a row of fields.
|
||||||
import { useEffect, useRef, useState } from 'react'
|
// Owner review 4: that colour field everywhere, its panel over the page, see-through colours.
|
||||||
|
import { useCallback, useRef, useState } from 'react'
|
||||||
import { AlertTriangle, Film, ImageIcon, X } from 'lucide-react'
|
import { AlertTriangle, Film, ImageIcon, X } from 'lucide-react'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { Button, Dropdown, Field, IconButton } from '@xenia/ui'
|
import { Button, Dropdown, Field, IconButton, Input, Popover } from '@xenia/ui'
|
||||||
import MediaPicker from '../media/MediaPicker'
|
import MediaPicker from '../media/MediaPicker'
|
||||||
import { COLOUR_PRESETS } from './signageLogic'
|
import { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } from './signageLogic'
|
||||||
|
|
||||||
/** A part of the slide editor: its title over a thin line, then its fields (DESIGN.md §3). */
|
/** A part of the slide editor: its title over a thin line, then its fields (DESIGN.md §3). */
|
||||||
export function Section({ title, aside, children, testid, className = '' }) {
|
export function Section({ title, aside, children, testid, className = '' }) {
|
||||||
@@ -69,66 +70,71 @@ export function MediaPick({ kind = 'image', value, entry, onChange, onRemove, mi
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A colour the venue chooses for its TV (stored as #rrggbb: data, not a theme colour): a few
|
/**
|
||||||
* ready colours with one click, and the picker for any other (2026-11-21). `compact`: a field
|
* A colour the venue chooses for its TV (data, not a theme colour: #rrggbb, or #rrggbbaa when
|
||||||
* (swatch and code) that opens them, as tall and as wide as the fields beside it. */
|
* see-through): a field (its swatch and code) that opens a small panel over the page (owner review
|
||||||
export function ColourField({ label, value, onChange, testid, presets = COLOUR_PRESETS, compact = false }) {
|
* 4, 2026-11-21: every signage colour): twelve ready colours, then the picker, the opacity and the
|
||||||
|
* code typed by hand. Each field changes only its own colour. `auto` ({ label, on, pick }): a first
|
||||||
|
* choice that lets the TV choose (a badge's text: white or black, whichever reads).
|
||||||
|
*/
|
||||||
|
export function ColourField({ label, value, onChange, testid, presets = COLOUR_PRESETS, auto, className }) {
|
||||||
|
const { t } = useTranslation('manager')
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
const [typed, setTyped] = useState(null)
|
||||||
|
const btn = useRef(null)
|
||||||
const v = (value || '#000000').toLowerCase()
|
const v = (value || '#000000').toLowerCase()
|
||||||
if (compact) return <ColourPick label={label} value={v} onChange={onChange} testid={testid} presets={presets} />
|
const { rgb, alpha } = splitAlpha(v)
|
||||||
|
const close = useCallback(() => { setOpen(false); setTyped(null) }, [])
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-1.5" role="group" aria-label={label}>
|
<>
|
||||||
<span className="text-label font-medium text-ink">{label}</span>
|
<Field label={label} className={className}>
|
||||||
<span className="min-h-control flex flex-wrap items-center gap-1.5">
|
<button ref={btn} type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} aria-haspopup="dialog" data-testid={testid ? `${testid}-open` : undefined}
|
||||||
|
className="w-full min-w-0 h-control flex items-center gap-2.5 px-3 rounded-control border border-line bg-surface text-label text-ink hover:border-line-strong transition-colors duration-fast">
|
||||||
|
<Swatch colour={v} className="w-6 h-6" />
|
||||||
|
<span className={`truncate ${auto?.on ? 'text-ink-2' : 'font-mono text-ink-2'}`}>{auto?.on ? auto.label : v}</span>
|
||||||
|
</button>
|
||||||
|
</Field>
|
||||||
|
<Popover open={open} anchor={btn} onClose={close} aria-label={label} className="grid gap-3 p-3 w-[17.5rem]"
|
||||||
|
data-testid={testid ? `${testid}-panel` : 'signage-colour-panel'}>
|
||||||
|
{auto && (
|
||||||
|
<button type="button" onClick={() => { auto.pick(); close() }} aria-pressed={!!auto.on} data-testid={testid ? `${testid}-auto` : undefined}
|
||||||
|
className={`h-control px-3 rounded-control border text-label text-left transition-colors duration-fast ${auto.on ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line text-ink hover:bg-surface-2'}`}>
|
||||||
|
{auto.label}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<div className="grid grid-cols-6 gap-2 justify-items-center">
|
||||||
{presets.map(c => (
|
{presets.map(c => (
|
||||||
<button key={c} type="button" onClick={() => onChange(c)} aria-label={c} aria-pressed={v === c} title={c}
|
<button key={c} type="button" onClick={() => { onChange(joinAlpha(c, alpha)); close() }} aria-label={c} aria-pressed={!auto?.on && rgb === c} title={c}
|
||||||
className={`w-7 h-7 rounded-full border border-line-strong shrink-0 transition-transform duration-fast ${v === c ? 'ring-2 ring-accent ring-offset-2 ring-offset-surface' : 'hover:scale-110'}`}
|
className={`w-8 h-8 rounded-full transition-transform duration-fast ${!auto?.on && rgb === c ? 'ring-2 ring-accent ring-offset-2 ring-offset-surface' : 'hover:scale-110'}`}
|
||||||
style={{ background: c }} data-testid={testid ? `${testid}-preset` : undefined} />
|
data-testid={testid ? `${testid}-preset` : undefined}>
|
||||||
|
<Swatch colour={c} className="w-8 h-8" />
|
||||||
|
</button>
|
||||||
))}
|
))}
|
||||||
<input type="color" value={v} onChange={e => onChange(e.target.value)} data-testid={testid} aria-label={label}
|
|
||||||
className="w-9 h-9 rounded-control border border-line bg-surface cursor-pointer p-0.5 ml-1" />
|
|
||||||
<span className="text-caption text-ink-3 font-mono">{v}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div className="grid gap-2.5 border-t border-line pt-3">
|
||||||
|
<span className="text-overline font-semibold uppercase tracking-wide text-ink-3">{t('signage.colourPick.custom')}</span>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<input type="color" value={rgb} onChange={e => { setTyped(null); onChange(joinAlpha(e.target.value, alpha)) }} data-testid={testid} aria-label={label}
|
||||||
|
className="w-10 h-control shrink-0 rounded-control border border-line bg-surface cursor-pointer p-0.5" />
|
||||||
|
<Input value={typed ?? v} maxLength={9} spellCheck={false} aria-label={t('signage.colourPick.code')} className="font-mono min-w-0 flex-1" data-testid={testid ? `${testid}-code` : undefined}
|
||||||
|
onChange={e => { setTyped(e.target.value); const c = typedColour(e.target.value); if (c) onChange(c) }} onBlur={() => setTyped(null)} />
|
||||||
|
</div>
|
||||||
|
<label className="grid gap-1 text-caption text-ink-2">
|
||||||
|
<span className="flex justify-between"><span>{t('signage.colourPick.opacity')}</span><span className="tabular-nums">{alpha}%</span></span>
|
||||||
|
<input type="range" min={0} max={100} step={5} value={alpha} onChange={e => { setTyped(null); onChange(joinAlpha(rgb, Number(e.target.value))) }}
|
||||||
|
className="accent-accent" data-testid={testid ? `${testid}-opacity` : undefined} />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</Popover>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ColourPick({ label, value, onChange, testid, presets }) {
|
/** A colour's swatch, over a checkerboard so a see-through colour shows as one. */
|
||||||
const [open, setOpen] = useState(false)
|
function Swatch({ colour, className = '' }) {
|
||||||
const box = useRef(null)
|
|
||||||
useEffect(() => {
|
|
||||||
if (!open) return undefined
|
|
||||||
const away = e => { if (!box.current?.contains(e.target)) setOpen(false) }
|
|
||||||
const esc = e => { if (e.key === 'Escape') setOpen(false) }
|
|
||||||
window.addEventListener('pointerdown', away)
|
|
||||||
window.addEventListener('keydown', esc)
|
|
||||||
return () => { window.removeEventListener('pointerdown', away); window.removeEventListener('keydown', esc) }
|
|
||||||
}, [open])
|
|
||||||
return (
|
return (
|
||||||
<Field label={label}>
|
<span className={`block rounded-full border border-line-strong shrink-0 ${className}`} aria-hidden="true" data-venue-colour=""
|
||||||
<div ref={box} className="relative">
|
style={{ background: `linear-gradient(${colour}, ${colour}), repeating-conic-gradient(#d1d5db 0 25%, #ffffff 0 50%) 0 0 / 8px 8px` }} />
|
||||||
<button type="button" onClick={() => setOpen(o => !o)} aria-expanded={open} aria-label={label} data-testid={testid ? `${testid}-open` : undefined}
|
|
||||||
className="w-full h-control flex items-center gap-2.5 px-3 rounded-control border border-line bg-surface text-label text-ink hover:border-line-strong transition-colors duration-fast">
|
|
||||||
<span className="w-6 h-6 rounded-full border border-line-strong shrink-0" style={{ background: value }} aria-hidden="true" />
|
|
||||||
<span className="font-mono text-ink-2 truncate">{value}</span>
|
|
||||||
</button>
|
|
||||||
{open && (
|
|
||||||
<div className="absolute z-30 left-0 top-full mt-1.5 grid gap-3 p-3 rounded-card border border-line bg-surface shadow-lg w-max" role="dialog" aria-label={label}>
|
|
||||||
<div className="grid grid-cols-5 gap-2">
|
|
||||||
{presets.map(c => (
|
|
||||||
<button key={c} type="button" onClick={() => { onChange(c); setOpen(false) }} aria-label={c} aria-pressed={value === c} title={c}
|
|
||||||
className={`w-8 h-8 rounded-full border border-line-strong transition-transform duration-fast ${value === c ? 'ring-2 ring-accent ring-offset-2 ring-offset-surface' : 'hover:scale-110'}`}
|
|
||||||
style={{ background: c }} data-testid={testid ? `${testid}-preset` : undefined} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<label className="flex items-center gap-2 text-label text-ink-2">
|
|
||||||
<input type="color" value={value} onChange={e => onChange(e.target.value)} data-testid={testid} aria-label={label}
|
|
||||||
className="w-9 h-9 rounded-control border border-line bg-surface cursor-pointer p-0.5" />
|
|
||||||
<span className="font-mono">{value}</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Field>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +151,7 @@ export function BackgroundField({ value, onChange, media, onMedia, misfit, testi
|
|||||||
options={[{ value: 'colour', label: t('signage.bgColour') }, { value: 'media', label: t('signage.bgPhoto') }]} />
|
options={[{ value: 'colour', label: t('signage.bgColour') }, { value: 'media', label: t('signage.bgPhoto') }]} />
|
||||||
</Field>
|
</Field>
|
||||||
{bg.kind === 'colour'
|
{bg.kind === 'colour'
|
||||||
? <ColourField label={t('signage.colour')} value={bg.colour} onChange={colour => set({ colour })} testid={`${testid}-colour`} />
|
? <ColourField label={t('signage.colour')} value={bg.colour} onChange={colour => set({ colour })} testid={`${testid}-colour`} className="max-w-xs" />
|
||||||
: (
|
: (
|
||||||
<div className="grid gap-4 sm:grid-cols-[auto_minmax(0,1fr)_12rem] items-end">
|
<div className="grid gap-4 sm:grid-cols-[auto_minmax(0,1fr)_12rem] items-end">
|
||||||
<MediaPick kind="image" value={bg.media_id} entry={media?.[String(bg.media_id)]} misfit={misfit} testid={`${testid}-photo`}
|
<MediaPick kind="image" value={bg.media_id} entry={media?.[String(bg.media_id)]} misfit={misfit} testid={`${testid}-photo`}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export default function SlideEditor({ slide, onChange, media, onMedia, misfit =
|
|||||||
onChange={item => { onMedia(item); setC({ media_id: item.id }) }} testid="signage-picture" />
|
onChange={item => { onMedia(item); setC({ media_id: item.id }) }} testid="signage-picture" />
|
||||||
<div className="grid gap-4 md:grid-cols-[16rem_minmax(0,1fr)] items-start">
|
<div className="grid gap-4 md:grid-cols-[16rem_minmax(0,1fr)] items-start">
|
||||||
{fit}
|
{fit}
|
||||||
<ColourField label={t('signage.around')} value={c.background_colour || '#000000'} onChange={v => setC({ background_colour: v })} />
|
<ColourField label={t('signage.around')} value={c.background_colour || '#000000'} onChange={v => setC({ background_colour: v })} testid="signage-around" className="max-w-xs" />
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
)}
|
)}
|
||||||
@@ -162,7 +162,7 @@ export function TextLook({ c, setC, align = true, children }) {
|
|||||||
</Field>
|
</Field>
|
||||||
<Range label={t('signage.textSizeLabel')} value={c.text_size || 100} min={50} max={250} step={10} suffix="%"
|
<Range label={t('signage.textSizeLabel')} value={c.text_size || 100} min={50} max={250} step={10} suffix="%"
|
||||||
onChange={v => setC({ text_size: v })} testid="signage-text-size" />
|
onChange={v => setC({ text_size: v })} testid="signage-text-size" />
|
||||||
<ColourField compact label={t('signage.textColour')} value={c.text_colour || '#ffffff'} onChange={v => setC({ text_colour: v })} testid="signage-text-colour" />
|
<ColourField label={t('signage.textColour')} value={c.text_colour || '#ffffff'} onChange={v => setC({ text_colour: v })} testid="signage-text-colour" />
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</Section>
|
</Section>
|
||||||
|
|||||||
@@ -12,15 +12,16 @@
|
|||||||
// level deep) or a whole slide from the Slides library.
|
// level deep) or a whole slide from the Slides library.
|
||||||
// Owner review 3 (2026-11-21): a stack's parts sized by dragging the lines between them on its bar;
|
// Owner review 3 (2026-11-21): a stack's parts sized by dragging the lines between them on its bar;
|
||||||
// "Add a widget" beside what a part shows; Delete removes the picked widget (WidgetCanvas).
|
// "Add a widget" beside what a part shows; Delete removes the picked widget (WidgetCanvas).
|
||||||
|
// Owner review 4 (2026-11-21): a part holds several widgets, added with "Add a widget".
|
||||||
// Up to 10 (the server's limit).
|
// Up to 10 (the server's limit).
|
||||||
import { Fragment, useEffect, useRef, useState } from 'react'
|
import { Fragment, useEffect, useRef, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, BookImage, CalendarDays, ChevronDown, Clock, CloudSun, Columns3, GripVertical,
|
AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, 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,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { evenShares, setShare } from '@xenia/signage'
|
import { cellWidgets, evenShares, setShare } from '@xenia/signage'
|
||||||
import { useTranslation } from '@xenia/i18n'
|
import { useTranslation } from '@xenia/i18n'
|
||||||
import { Button, Dropdown, Field, IconButton, Input, Segmented, Switch } from '@xenia/ui'
|
import { Button, Dropdown, Field, IconButton, Input, Popover, Segmented, Switch } from '@xenia/ui'
|
||||||
import * as api from './signageApi'
|
import * as api from './signageApi'
|
||||||
import MenuEditor from './MenuEditor'
|
import MenuEditor from './MenuEditor'
|
||||||
import { MediaPick, Section } from './SignageFields'
|
import { MediaPick, Section } from './SignageFields'
|
||||||
@@ -255,8 +256,9 @@ function MenuBoardFields({ w, set, extras, path }) {
|
|||||||
/**
|
/**
|
||||||
* A stack's parts: side by side or one over the other, how many (2–6), their sizes (drag the lines
|
* A stack's parts: side by side or one over the other, how many (2–6), their sizes (drag the lines
|
||||||
* between them on the bar, or focus one and use the arrow keys; "Split evenly"), and what each
|
* between them on the bar, or focus one and use the arrow keys; "Split evenly"), and what each
|
||||||
* shows: a widget (picked from the list or with "Add a widget"), another stack (one level deep),
|
* shows: widgets added with "Add a widget" (several share the part, owner review 4: one over the
|
||||||
* a slide from the Slides library, or nothing.
|
* other in a side-by-side stack, side by side in the other; each with its settings, moved up or
|
||||||
|
* down, removed), another stack (one level deep), or a slide from the Slides library.
|
||||||
*/
|
*/
|
||||||
function StackFields({ w, set, media, onMedia, extras, path, depth }) {
|
function StackFields({ w, set, media, onMedia, extras, path, depth }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
@@ -264,22 +266,27 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) {
|
|||||||
const cells = w.cells || []
|
const cells = w.cells || []
|
||||||
const shares = cells.map(c => Math.round(c.share || 0))
|
const shares = cells.map(c => Math.round(c.share || 0))
|
||||||
const setCells = next => set({ cells: next })
|
const setCells = next => set({ cells: next })
|
||||||
const setCell = (j, patch) => setCells(cells.map((c, k) => (k === j ? { ...c, ...patch } : c)))
|
const setCell = (j, patch) => setCells(cells.map((c, k) => {
|
||||||
|
if (k !== j) return c
|
||||||
|
const { widget: _old, ...rest } = { ...c, ...patch } // a part stored with one `widget`: now `widgets`
|
||||||
|
return rest
|
||||||
|
}))
|
||||||
const setShares = next => setCells(cells.map((c, k) => ({ ...c, share: next[k] })))
|
const setShares = next => setCells(cells.map((c, k) => ({ ...c, share: next[k] })))
|
||||||
const count = n => {
|
const count = n => {
|
||||||
const even = evenShares(n)
|
const even = evenShares(n)
|
||||||
setCells(Array.from({ length: n }, (_, k) => ({ ...(cells[k] || {}), share: even[k] })))
|
setCells(Array.from({ length: n }, (_, k) => ({ ...(cells[k] || {}), share: even[k] })))
|
||||||
}
|
}
|
||||||
const shows = c => (c.slide_id ? 'slide' : c.widget ? (c.widget.kind === 'stack' ? (c.widget.direction === 'column' ? 'vstack' : 'hstack') : c.widget.kind) : '')
|
const setWidgets = (j, list) => setCell(j, { widgets: list, slide_id: null })
|
||||||
const pick = (j, v) => {
|
const add = (j, v) => {
|
||||||
if (!v) setCell(j, { widget: null, slide_id: null })
|
if (v === 'slide') setCell(j, { widgets: [], slide_id: slides[0]?.id ?? null })
|
||||||
else if (v === 'slide') setCell(j, { widget: null, slide_id: slides[0]?.id ?? null })
|
else setWidgets(j, [...cellWidgets(cells[j]), cellWidget(v)])
|
||||||
else setCell(j, { widget: cellWidget(v), slide_id: null })
|
|
||||||
}
|
}
|
||||||
const kinds = [...CELL_KINDS, ...(depth === 0 ? ['hstack', 'vstack'] : [])]
|
const kinds = [...CELL_KINDS, ...(depth === 0 ? ['hstack', 'vstack'] : [])]
|
||||||
const label = c => {
|
const label = c => {
|
||||||
const v = shows(c)
|
const ws = cellWidgets(c)
|
||||||
return !v ? t('signage.widgets.stack.nothing') : v === 'slide' ? (slides.find(x => x.id === c.slide_id)?.name || t('signage.widgets.stack.slide')) : t(`signage.widgets.kinds.${v}`)
|
if (ws.length) return ws.map(x => kindLabel(t, x)).join(' · ')
|
||||||
|
if (c.slide_id != null) return slides.find(x => x.id === c.slide_id)?.name || t('signage.widgets.stack.slide')
|
||||||
|
return t('signage.widgets.stack.nothing')
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="grid gap-3 rounded-control border border-line bg-surface p-3" data-testid="signage-stack-editor" data-depth={depth}>
|
<div className="grid gap-3 rounded-control border border-line bg-surface p-3" data-testid="signage-stack-editor" data-depth={depth}>
|
||||||
@@ -298,37 +305,59 @@ function StackFields({ w, set, media, onMedia, extras, path, depth }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ShareBar column={w.direction === 'column'} shares={shares} labels={cells.map(label)} onChange={setShares} />
|
<ShareBar column={w.direction === 'column'} shares={shares} labels={cells.map(label)} onChange={setShares} />
|
||||||
<p className="text-caption text-ink-3 -mt-1">{t('signage.widgets.stack.barHint')}</p>
|
<p className="text-caption text-ink-3 -mt-1">{t(w.direction === 'column' ? 'signage.widgets.stack.barHintColumn' : 'signage.widgets.stack.barHint')}</p>
|
||||||
{cells.map((c, j) => {
|
{cells.map((c, j) => {
|
||||||
const cp = `${path}.${j}`
|
const cp = `${path}.${j}`
|
||||||
const v = shows(c)
|
const ws = cellWidgets(c)
|
||||||
const setW = patch => setCell(j, { widget: { ...c.widget, ...patch } })
|
const slide = !ws.length && c.slide_id != null
|
||||||
|
const setOne = (k, patch) => setWidgets(j, ws.map((x, m) => (m === k ? { ...x, ...patch } : x)))
|
||||||
|
const moveOne = (k, to) => { if (to >= 0 && to < ws.length) setWidgets(j, moved(ws, k, to)) }
|
||||||
return (
|
return (
|
||||||
<div key={j} className="grid gap-3 rounded-control border border-line bg-surface-2 p-3" data-testid="signage-stack-cell-editor" data-index={j}>
|
<div key={j} className="grid gap-3 rounded-control border border-line bg-surface-2 p-3" data-testid="signage-stack-cell-editor" data-index={j}>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
<span className="text-label font-semibold text-ink">{t('signage.widgets.stack.partTitle', { n: j + 1 })}</span>
|
<span className="text-label font-semibold text-ink">{t('signage.widgets.stack.partTitle', { n: j + 1 })}</span>
|
||||||
<span className="text-caption text-ink-3 tabular-nums" data-testid="signage-stack-share">{shares[j]}%</span>
|
<span className="text-caption text-ink-3 tabular-nums" data-testid="signage-stack-share">{shares[j]}%</span>
|
||||||
|
{!ws.length && !slide && <span className="text-caption text-ink-3">· {t('signage.widgets.stack.nothing')}</span>}
|
||||||
|
<span className="flex-1" />
|
||||||
|
<AddToPart kinds={kinds} onPick={v => add(j, v)} />
|
||||||
</div>
|
</div>
|
||||||
<div className={ROW}>
|
{slide && (
|
||||||
<Field label={t('signage.widgets.stack.shows')}>
|
<div className="flex items-end gap-2">
|
||||||
<Dropdown value={v} onChange={x => pick(j, x)} data-testid="signage-stack-shows"
|
<Field label={t('signage.widgets.stack.slide')} className="flex-1 max-w-md">
|
||||||
options={[{ value: '', label: t('signage.widgets.stack.nothing') },
|
<Dropdown value={String(c.slide_id)} onChange={x => setCell(j, { slide_id: x ? Number(x) : null })} data-testid="signage-stack-slide"
|
||||||
...kinds.map(k => ({ value: k, label: t(`signage.widgets.kinds.${k}`) })),
|
|
||||||
{ value: 'slide', label: t('signage.widgets.stack.aSlide') }]} />
|
|
||||||
</Field>
|
|
||||||
<div className="flex items-end"><AddToPart kinds={kinds} onPick={x => pick(j, x)} filled={!!v} /></div>
|
|
||||||
{c.slide_id != null || v === 'slide' ? (
|
|
||||||
<Field label={t('signage.widgets.stack.slide')} className="col-span-2">
|
|
||||||
<Dropdown value={c.slide_id != null ? String(c.slide_id) : ''} onChange={x => setCell(j, { slide_id: x ? Number(x) : null })} data-testid="signage-stack-slide"
|
|
||||||
options={slides.length ? slides.map(s => ({ value: String(s.id), label: s.name }))
|
options={slides.length ? slides.map(s => ({ value: String(s.id), label: s.name }))
|
||||||
: [{ value: '', label: t('signage.widgets.stack.noSlides') }]} />
|
: [{ value: String(c.slide_id), label: t('signage.widgets.stack.noSlides') }]} />
|
||||||
</Field>
|
</Field>
|
||||||
) : c.widget && <>
|
<IconButton variant="ghost" label={t('signage.widgets.stack.removeSlide')} onClick={() => setCell(j, { slide_id: null })} data-testid="signage-stack-slide-remove">
|
||||||
{c.widget.kind !== 'stack' && <AlignField w={c.widget} set={setW} testid="signage-cell-align" />}
|
<Trash2 size={15} />
|
||||||
<InlineFields w={c.widget} set={setW} />
|
</IconButton>
|
||||||
</>}
|
|
||||||
</div>
|
</div>
|
||||||
{c.widget && <BelowFields w={c.widget} set={setW} media={media} onMedia={onMedia} extras={extras} path={cp} depth={depth + 1} />}
|
)}
|
||||||
|
{ws.map((x, k) => {
|
||||||
|
const Icon = iconOf(x)
|
||||||
|
const setW = patch => setOne(k, patch)
|
||||||
|
return (
|
||||||
|
<div key={k} className="grid gap-3 rounded-control border border-line bg-surface p-3" data-testid="signage-stack-part-widget" data-kind={x.kind}>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Icon size={15} className="text-ink-2 shrink-0" aria-hidden="true" />
|
||||||
|
<span className="text-label font-semibold text-ink flex-1 min-w-0 truncate">{kindLabel(t, x)}</span>
|
||||||
|
{ws.length > 1 && <>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.widgets.stack.before')} disabled={k === 0} onClick={() => moveOne(k, k - 1)}><ArrowUp size={14} /></IconButton>
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.widgets.stack.after')} disabled={k === ws.length - 1} onClick={() => moveOne(k, k + 1)}><ArrowDown size={14} /></IconButton>
|
||||||
|
</>}
|
||||||
|
<IconButton size="sm" variant="ghost" label={t('signage.widgets.stack.removeWidget')} onClick={() => setWidgets(j, ws.filter((_, m) => m !== k))}
|
||||||
|
data-testid="signage-stack-part-remove"><Trash2 size={14} /></IconButton>
|
||||||
|
</div>
|
||||||
|
{x.kind !== 'stack' && (
|
||||||
|
<div className={ROW}>
|
||||||
|
<AlignField w={x} set={setW} testid="signage-cell-align" />
|
||||||
|
<InlineFields w={x} set={setW} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<BelowFields w={x} set={setW} media={media} onMedia={onMedia} extras={extras} path={`${cp}.${k}`} depth={depth + 1} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@@ -390,39 +419,30 @@ function ShareBar({ column, shares, labels, onChange }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "Add a widget" to a part: every widget (and a slide from the Slides library) in a small panel. */
|
/** "Add a widget" to a part: every widget (and a slide from the Slides library) in a small panel
|
||||||
function AddToPart({ kinds, onPick, filled }) {
|
* over the page; widgets add up, a slide takes the part's place. */
|
||||||
|
function AddToPart({ kinds, onPick }) {
|
||||||
const { t } = useTranslation('manager')
|
const { t } = useTranslation('manager')
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const box = useRef(null)
|
const btn = useRef(null)
|
||||||
useEffect(() => {
|
|
||||||
if (!open) return undefined
|
|
||||||
const away = e => { if (!box.current?.contains(e.target)) setOpen(false) }
|
|
||||||
const esc = e => { if (e.key === 'Escape') setOpen(false) }
|
|
||||||
window.addEventListener('pointerdown', away)
|
|
||||||
window.addEventListener('keydown', esc)
|
|
||||||
return () => { window.removeEventListener('pointerdown', away); window.removeEventListener('keydown', esc) }
|
|
||||||
}, [open])
|
|
||||||
const choose = k => { onPick(k); setOpen(false) }
|
const choose = k => { onPick(k); setOpen(false) }
|
||||||
return (
|
return (
|
||||||
<div ref={box} className="relative">
|
<>
|
||||||
<Button variant="secondary" icon={<Plus size={14} />} onClick={() => setOpen(o => !o)} aria-expanded={open} data-testid="signage-stack-add">
|
<Button ref={btn} size="sm" variant="secondary" icon={<Plus size={14} />} onClick={() => setOpen(o => !o)} aria-expanded={open} aria-haspopup="menu" data-testid="signage-stack-add">
|
||||||
{t(filled ? 'signage.widgets.stack.replace' : 'signage.widgets.stack.add')}
|
{t('signage.widgets.stack.add')}
|
||||||
</Button>
|
</Button>
|
||||||
{open && (
|
<Popover open={open} anchor={btn} onClose={() => setOpen(false)} role="menu" className="w-[22rem] grid grid-cols-2 gap-1.5 p-2" data-testid="signage-stack-add-menu">
|
||||||
<div className="absolute z-30 left-0 top-full mt-1.5 w-[22rem] grid grid-cols-2 gap-1.5 p-2 rounded-card border border-line bg-surface shadow-lg" role="menu">
|
|
||||||
{[...kinds, 'slide'].map(k => {
|
{[...kinds, 'slide'].map(k => {
|
||||||
const Icon = k === 'slide' ? BookImage : ICON[k]
|
const Icon = k === 'slide' ? BookImage : ICON[k]
|
||||||
return (
|
return (
|
||||||
<button key={k} type="button" role="menuitem" onClick={() => choose(k)} data-testid={`signage-stack-add-${k}`}
|
<button key={k} type="button" role="menuitem" onClick={() => choose(k)} data-testid={`signage-stack-add-${k}`}
|
||||||
className="flex items-center gap-2 px-2.5 py-2 rounded-control text-left text-label text-ink hover:bg-surface-2">
|
className={`flex items-center gap-2 px-2.5 py-2 rounded-control text-left text-label text-ink hover:bg-surface-2 ${k === 'slide' ? 'col-span-2' : ''}`}>
|
||||||
<Icon size={15} className="text-ink-2 shrink-0" aria-hidden="true" />
|
<Icon size={15} className="text-ink-2 shrink-0" aria-hidden="true" />
|
||||||
{k === 'slide' ? t('signage.widgets.stack.aSlide') : t(`signage.widgets.kinds.${k}`)}
|
{k === 'slide' ? t('signage.widgets.stack.aSlideInstead') : t(`signage.widgets.kinds.${k}`)}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</Popover>
|
||||||
)}
|
</>
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,8 +206,33 @@ export function slideFromSaved(saved) {
|
|||||||
return { kind: saved.kind, ...slideBody(saved), content: JSON.parse(JSON.stringify(saved.content || {})) }
|
return { kind: saved.kind, ...slideBody(saved), content: JSON.parse(JSON.stringify(saved.content || {})) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Colours offered with one click beside the colour picker (the venue's TV: data, not the theme). */
|
/** Colours offered with one click in the colour picker (the venue's TV: data, not the theme):
|
||||||
export const COLOUR_PRESETS = ['#ffffff', '#111827', '#fde68a', '#f59e0b', '#ef4444', '#22c55e', '#38bdf8', '#a78bfa', '#f472b6']
|
* two rows of six (owner review 4, 2026-11-21). */
|
||||||
|
export const COLOUR_PRESETS = [
|
||||||
|
'#ffffff', '#d1d5db', '#6b7280', '#111827', '#000000', '#fde68a',
|
||||||
|
'#f59e0b', '#ef4444', '#f472b6', '#a78bfa', '#38bdf8', '#22c55e',
|
||||||
|
]
|
||||||
|
|
||||||
|
/** A colour as its #rrggbb and its opacity (0–100 %): #rrggbbaa is see-through (2026-11-21). */
|
||||||
|
export function splitAlpha(hex) {
|
||||||
|
const h = String(hex || '#000000').toLowerCase()
|
||||||
|
const rgb = /^#[0-9a-f]{6}/.test(h) ? h.slice(0, 7) : '#000000'
|
||||||
|
const a = /^#[0-9a-f]{8}$/.test(h) ? Math.round((parseInt(h.slice(7, 9), 16) / 255) * 100) : 100
|
||||||
|
return { rgb, alpha: a }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** #rrggbb with an opacity: #rrggbb when it is solid, #rrggbbaa otherwise. */
|
||||||
|
export function joinAlpha(rgb, alpha) {
|
||||||
|
const a = Math.max(0, Math.min(100, Math.round(alpha)))
|
||||||
|
return a >= 100 ? rgb : `${rgb}${Math.round((a / 100) * 255).toString(16).padStart(2, '0')}`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A colour typed by hand: #rgb, #rrggbb or #rrggbbaa (the # optional) → #rrggbb(aa), or null. */
|
||||||
|
export function typedColour(text) {
|
||||||
|
let h = String(text || '').trim().toLowerCase().replace(/^#/, '')
|
||||||
|
if (/^[0-9a-f]{3}$/.test(h)) h = h.split('').map(x => x + x).join('')
|
||||||
|
return /^[0-9a-f]{6}([0-9a-f]{2})?$/.test(h) ? `#${h}` : null
|
||||||
|
}
|
||||||
|
|
||||||
// ── widgets moved and sized on the preview (2026-11-21) ──────────────────────
|
// ── widgets moved and sized on the preview (2026-11-21) ──────────────────────
|
||||||
|
|
||||||
@@ -309,3 +334,14 @@ export function toggleMonthDay(line, key) {
|
|||||||
|
|
||||||
/** A menu's colours until the venue picks its own (the TV's data, as the player draws them). */
|
/** A menu's colours until the venue picks its own (the TV's data, as the player draws them). */
|
||||||
export const MENU_COLOURS = { accent: '#f59e0b', text: '#ffffff' }
|
export const MENU_COLOURS = { accent: '#f59e0b', text: '#ffffff' }
|
||||||
|
|
||||||
|
/** A menu's look as new ("Reset the look", owner review 4): every part back to the board's. */
|
||||||
|
export const MENU_LOOK_DEFAULTS = {
|
||||||
|
font: 'sans', text_size: 100, text_colour: MENU_COLOURS.text, accent_colour: MENU_COLOURS.accent, badge_text_colour: null,
|
||||||
|
heading_style: {}, item_style: {}, price_style: {}, dot_style: {},
|
||||||
|
line_height: null, letter_spacing: null, photo_size: 100, photo_shape: 'rounded',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Line spacing (× the text) and letter spacing (em) offered beside "Auto". */
|
||||||
|
export const LINE_HEIGHTS = [0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2, 2.5]
|
||||||
|
export const LETTER_SPACINGS = [-0.05, -0.02, 0.02, 0.05, 0.1, 0.15, 0.2, 0.3]
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import { placeWidget } from './signageLogic'
|
|||||||
|
|
||||||
// what doesn't change what the server adds (where things sit, how they look): left out of the key
|
// what doesn't change what the server adds (where things sit, how they look): left out of the key
|
||||||
const LOOK = new Set(['box', 'position', 'size', 'align', 'background', 'text_colour', 'accent_colour', 'font', 'text_size',
|
const LOOK = new Set(['box', 'position', 'size', 'align', 'background', 'text_colour', 'accent_colour', 'font', 'text_size',
|
||||||
'board_width', 'board_align', 'title', 'body', 'vertical', 'columns', 'page_seconds', 'direction', 'share', 'clock_seconds', 'date_style'])
|
'board_width', 'board_align', 'title', 'body', 'vertical', 'columns', 'page_seconds', 'direction', 'share', 'clock_seconds', 'date_style',
|
||||||
|
'heading_style', 'item_style', 'price_style', 'dot_style', 'line_height', 'letter_spacing', 'photo_size', 'photo_shape', 'badge_text_colour'])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The draft as the server resolves it for the preview (2026-11-21): a menu board's products
|
* The draft as the server resolves it for the preview (2026-11-21): a menu board's products
|
||||||
|
|||||||
@@ -101,3 +101,16 @@ test('the Slides library: what is saved, and a copy for a playlist', async () =>
|
|||||||
copy.content.widgets[0].kind = 'clock'
|
copy.content.widgets[0].kind = 'clock'
|
||||||
assert.equal(saved.content.widgets[0].kind, 'name') // a copy, never the kept slide
|
assert.equal(saved.content.widgets[0].kind, 'name') // a copy, never the kept slide
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('a colour with its opacity: #rrggbbaa, typed by hand (owner review 4)', async () => {
|
||||||
|
const { COLOUR_PRESETS, joinAlpha, splitAlpha, typedColour } = await import('../src/pages/signage/signageLogic.js')
|
||||||
|
assert.equal(COLOUR_PRESETS.length, 12)
|
||||||
|
assert.deepEqual(splitAlpha('#FF0000'), { rgb: '#ff0000', alpha: 100 })
|
||||||
|
assert.deepEqual(splitAlpha('#ff000080'), { rgb: '#ff0000', alpha: 50 })
|
||||||
|
assert.equal(joinAlpha('#ff0000', 100), '#ff0000')
|
||||||
|
assert.equal(joinAlpha('#ff0000', 50), '#ff000080')
|
||||||
|
assert.equal(joinAlpha('#ff0000', 0), '#ff000000')
|
||||||
|
assert.equal(typedColour('abc'), '#aabbcc')
|
||||||
|
assert.equal(typedColour(' #11223344 '), '#11223344')
|
||||||
|
assert.equal(typedColour('#12345'), null)
|
||||||
|
})
|
||||||
|
|||||||
@@ -1527,16 +1527,19 @@
|
|||||||
"column": "Το ένα κάτω από το άλλο",
|
"column": "Το ένα κάτω από το άλλο",
|
||||||
"parts": "Πόσα",
|
"parts": "Πόσα",
|
||||||
"even": "Ίση μοιρασιά",
|
"even": "Ίση μοιρασιά",
|
||||||
"shows": "Δείχνει",
|
|
||||||
"nothing": "Τίποτα",
|
"nothing": "Τίποτα",
|
||||||
"aSlide": "Μια διαφάνεια από τις Διαφάνειες",
|
|
||||||
"slide": "Διαφάνεια",
|
"slide": "Διαφάνεια",
|
||||||
"noSlides": "Δεν υπάρχουν ακόμα διαφάνειες",
|
"noSlides": "Δεν υπάρχουν ακόμα διαφάνειες",
|
||||||
"barHint": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για να αλλάξετε το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια).",
|
"barHint": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια). Τα widgets ενός τμήματος μπαίνουν το ένα κάτω από το άλλο.",
|
||||||
"partTitle": "Τμήμα {{n}}",
|
"partTitle": "Τμήμα {{n}}",
|
||||||
"line": "Η γραμμή ανάμεσα στα τμήματα {{a}} και {{b}}",
|
"line": "Η γραμμή ανάμεσα στα τμήματα {{a}} και {{b}}",
|
||||||
"add": "Προσθήκη widget",
|
"add": "Προσθήκη widget",
|
||||||
"replace": "Κάτι άλλο"
|
"barHintColumn": "Σύρετε τις γραμμές ανάμεσα στα τμήματα για το μέγεθός τους (ή εστιάστε σε μια γραμμή και χρησιμοποιήστε τα βελάκια). Τα widgets ενός τμήματος μπαίνουν δίπλα-δίπλα.",
|
||||||
|
"aSlideInstead": "Μια διαφάνεια από τις Διαφάνειες (αντί για τα widgets)",
|
||||||
|
"removeSlide": "Αφαίρεση της διαφάνειας από αυτό το τμήμα",
|
||||||
|
"removeWidget": "Αφαίρεση αυτού του widget",
|
||||||
|
"before": "Μετακίνηση πριν",
|
||||||
|
"after": "Μετακίνηση μετά"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
@@ -1673,21 +1676,10 @@
|
|||||||
"kept": "Κρατήθηκε στις Διαφάνειες."
|
"kept": "Κρατήθηκε στις Διαφάνειες."
|
||||||
},
|
},
|
||||||
"look": {
|
"look": {
|
||||||
"headings": "Επικεφαλίδες",
|
|
||||||
"names": "Ονόματα προϊόντων",
|
|
||||||
"prices": "Τιμές",
|
|
||||||
"dots": "Τελείες",
|
|
||||||
"spacing": "Αποστάσεις",
|
|
||||||
"size": "Μέγεθος",
|
|
||||||
"colour": "Χρώμα",
|
|
||||||
"font": "Γραμματοσειρά",
|
|
||||||
"style": "Στυλ",
|
|
||||||
"align": "Στοίχιση",
|
|
||||||
"sameFont": "Όπως τα ονόματα",
|
"sameFont": "Όπως τα ονόματα",
|
||||||
"bold": "Έντονα",
|
"bold": "Έντονα",
|
||||||
"italic": "Πλάγια",
|
"italic": "Πλάγια",
|
||||||
"underline": "Υπογράμμιση",
|
"underline": "Υπογράμμιση",
|
||||||
"dotStyle": "Γραμμή",
|
|
||||||
"dotStyles": {
|
"dotStyles": {
|
||||||
"dotted": "Τελείες",
|
"dotted": "Τελείες",
|
||||||
"dashed": "Παύλες",
|
"dashed": "Παύλες",
|
||||||
@@ -1704,8 +1696,46 @@
|
|||||||
"rounded": "Στρογγυλεμένο",
|
"rounded": "Στρογγυλεμένο",
|
||||||
"round": "Στρογγυλό"
|
"round": "Στρογγυλό"
|
||||||
},
|
},
|
||||||
"accent": "Σήματα και τελείες σελίδων",
|
"hint": "Κάθε πεδίο αλλάζει μόνο τον εαυτό του. Οι επικεφαλίδες και οι τιμές ξεκινούν με το μέγεθος και τη γραμματοσειρά των ονομάτων («Όπως τα ονόματα»). Το χρώμα των σημάτων χρωματίζει και τις τελείες σελίδας. Τα ονόματα με δεξιά στοίχιση τελειώνουν όλα στο ίδιο σημείο, με ίσες τελείες πριν από τις τιμές.",
|
||||||
"hint": "Τα ονόματα προϊόντων ορίζουν το μέγεθος, το χρώμα και τη γραμματοσειρά του πίνακα· οι επικεφαλίδες και οι τιμές τα ακολουθούν (στο χρώμα έμφασης) μέχρι να αλλάξετε τα δικά τους. Με στοίχιση δεξιά τα ονόματα τελειώνουν στο ίδιο σημείο, με ίσες τελείες πριν τις τιμές. Διάστιχο: π.χ. 1.3 (× το κείμενο)· απόσταση γραμμάτων: π.χ. 0.05 (ενός γράμματος)· κενό = αυτόματο."
|
"f": {
|
||||||
|
"heading": {
|
||||||
|
"size": "Μέγεθος επικεφαλίδων",
|
||||||
|
"colour": "Χρώμα επικεφαλίδων",
|
||||||
|
"font": "Γραμματοσειρά επικεφαλίδων",
|
||||||
|
"style": "Στυλ επικεφαλίδων",
|
||||||
|
"align": "Στοίχιση επικεφαλίδων"
|
||||||
|
},
|
||||||
|
"item": {
|
||||||
|
"size": "Μέγεθος ονομάτων",
|
||||||
|
"colour": "Χρώμα ονομάτων",
|
||||||
|
"font": "Γραμματοσειρά ονομάτων",
|
||||||
|
"style": "Στυλ ονομάτων",
|
||||||
|
"align": "Στοίχιση ονομάτων"
|
||||||
|
},
|
||||||
|
"price": {
|
||||||
|
"size": "Μέγεθος τιμών",
|
||||||
|
"colour": "Χρώμα τιμών",
|
||||||
|
"font": "Γραμματοσειρά τιμών",
|
||||||
|
"style": "Στυλ τιμών",
|
||||||
|
"align": "Στοίχιση τιμών"
|
||||||
|
},
|
||||||
|
"dots": {
|
||||||
|
"size": "Μέγεθος τελειών",
|
||||||
|
"colour": "Χρώμα τελειών",
|
||||||
|
"line": "Γραμμή τελειών"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"badgeColour": "Χρώμα σημάτων",
|
||||||
|
"badgeText": "Κείμενο σημάτων",
|
||||||
|
"badgeTextAuto": "Αυτόματο",
|
||||||
|
"reset": "Επαναφορά εμφάνισης",
|
||||||
|
"resetTitle": "Επαναφορά της εμφάνισης αυτού του μενού;",
|
||||||
|
"resetBody": "Κάθε μέγεθος, χρώμα, γραμματοσειρά, στυλ, στοίχιση και διάστιχο γυρίζει στην αρχή. Τα προϊόντα, η σειρά και τα ονόματά τους μένουν. Η «Αναίρεση αλλαγών» τα φέρνει πίσω μέχρι να αποθηκεύσετε."
|
||||||
|
},
|
||||||
|
"colourPick": {
|
||||||
|
"custom": "Δικό σας χρώμα",
|
||||||
|
"code": "Κωδικός χρώματος",
|
||||||
|
"opacity": "Αδιαφάνεια"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overview": {
|
"overview": {
|
||||||
|
|||||||
@@ -1527,16 +1527,19 @@
|
|||||||
"column": "One over the other",
|
"column": "One over the other",
|
||||||
"parts": "How many",
|
"parts": "How many",
|
||||||
"even": "Split evenly",
|
"even": "Split evenly",
|
||||||
"shows": "Shows",
|
|
||||||
"nothing": "Nothing",
|
"nothing": "Nothing",
|
||||||
"aSlide": "A slide from Slides",
|
|
||||||
"slide": "Slide",
|
"slide": "Slide",
|
||||||
"noSlides": "No slides in Slides yet",
|
"noSlides": "No slides in Slides yet",
|
||||||
"barHint": "Drag the lines between the parts to size them (or focus a line and use the arrow keys).",
|
"barHint": "Drag the lines between the parts to size them (or focus a line and use the arrow keys). Widgets in one part sit one over the other.",
|
||||||
"partTitle": "Part {{n}}",
|
"partTitle": "Part {{n}}",
|
||||||
"line": "The line between parts {{a}} and {{b}}",
|
"line": "The line between parts {{a}} and {{b}}",
|
||||||
"add": "Add a widget",
|
"add": "Add a widget",
|
||||||
"replace": "Put something else"
|
"barHintColumn": "Drag the lines between the parts to size them (or focus a line and use the arrow keys). Widgets in one part sit side by side.",
|
||||||
|
"aSlideInstead": "A slide from Slides (instead of the widgets)",
|
||||||
|
"removeSlide": "Take the slide out of this part",
|
||||||
|
"removeWidget": "Remove this widget",
|
||||||
|
"before": "Move before",
|
||||||
|
"after": "Move after"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tabs": {
|
"tabs": {
|
||||||
@@ -1673,21 +1676,10 @@
|
|||||||
"kept": "Kept in Slides."
|
"kept": "Kept in Slides."
|
||||||
},
|
},
|
||||||
"look": {
|
"look": {
|
||||||
"headings": "Headings",
|
|
||||||
"names": "Product names",
|
|
||||||
"prices": "Prices",
|
|
||||||
"dots": "Dots",
|
|
||||||
"spacing": "Spacing",
|
|
||||||
"size": "Size",
|
|
||||||
"colour": "Colour",
|
|
||||||
"font": "Font",
|
|
||||||
"style": "Style",
|
|
||||||
"align": "Alignment",
|
|
||||||
"sameFont": "As the names",
|
"sameFont": "As the names",
|
||||||
"bold": "Bold",
|
"bold": "Bold",
|
||||||
"italic": "Italic",
|
"italic": "Italic",
|
||||||
"underline": "Underline",
|
"underline": "Underline",
|
||||||
"dotStyle": "Line",
|
|
||||||
"dotStyles": {
|
"dotStyles": {
|
||||||
"dotted": "Dots",
|
"dotted": "Dots",
|
||||||
"dashed": "Dashes",
|
"dashed": "Dashes",
|
||||||
@@ -1704,8 +1696,46 @@
|
|||||||
"rounded": "Rounded",
|
"rounded": "Rounded",
|
||||||
"round": "Round"
|
"round": "Round"
|
||||||
},
|
},
|
||||||
"accent": "Badges and page dots",
|
"hint": "Each field changes only itself. Headings and prices start in the names' size and font (\"As the names\"). The badges' colour also colours the page dots. Names aligned right all end at the same point, with equal dots before the prices.",
|
||||||
"hint": "Product names set the board's text size, colour and font; headings and prices follow them (in the accent colour) until you change theirs. Names aligned right all end at the same point, with equal dots before the prices. Line spacing: e.g. 1.3 (× the text); letter spacing: e.g. 0.05 (of a letter); empty = auto."
|
"f": {
|
||||||
|
"heading": {
|
||||||
|
"size": "Headings size",
|
||||||
|
"colour": "Headings colour",
|
||||||
|
"font": "Headings font",
|
||||||
|
"style": "Headings style",
|
||||||
|
"align": "Headings alignment"
|
||||||
|
},
|
||||||
|
"item": {
|
||||||
|
"size": "Names size",
|
||||||
|
"colour": "Names colour",
|
||||||
|
"font": "Names font",
|
||||||
|
"style": "Names style",
|
||||||
|
"align": "Names alignment"
|
||||||
|
},
|
||||||
|
"price": {
|
||||||
|
"size": "Prices size",
|
||||||
|
"colour": "Prices colour",
|
||||||
|
"font": "Prices font",
|
||||||
|
"style": "Prices style",
|
||||||
|
"align": "Prices alignment"
|
||||||
|
},
|
||||||
|
"dots": {
|
||||||
|
"size": "Dots size",
|
||||||
|
"colour": "Dots colour",
|
||||||
|
"line": "Dots line"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"badgeColour": "Badges colour",
|
||||||
|
"badgeText": "Badges text",
|
||||||
|
"badgeTextAuto": "Automatic",
|
||||||
|
"reset": "Reset the look",
|
||||||
|
"resetTitle": "Reset the look of this menu?",
|
||||||
|
"resetBody": "Every size, colour, font, style, alignment and spacing goes back to the start. The products, their order and names stay. \"Undo changes\" brings it back until you save."
|
||||||
|
},
|
||||||
|
"colourPick": {
|
||||||
|
"custom": "Your own colour",
|
||||||
|
"code": "Colour code",
|
||||||
|
"opacity": "Opacity"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"overview": {
|
"overview": {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
import { Cloud, CloudFog, CloudLightning, CloudMoon, CloudRain, CloudSnow, CloudSun, Moon, Sun } from 'lucide-react'
|
||||||
import { QRCodeSVG } from 'qrcode.react'
|
import { QRCodeSVG } from 'qrcode.react'
|
||||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||||
import { fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
import { cellWidgets, fitUnit, FONTS, menuLook, menuPages, pageAt, priceChars, textWidth, visibleGroups, weatherIcon, widgetAlign } from './logic'
|
||||||
|
|
||||||
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
|
/** A slide's background: a colour, or a photo (cover / contain) with a darkening layer. */
|
||||||
export function Background({ bg, media }) {
|
export function Background({ bg, media }) {
|
||||||
@@ -64,7 +64,7 @@ export function MenuSlide({ slide, media, venue, now, page, pages, extras, embed
|
|||||||
{/* the list: the whole width, or narrower and placed left / centre / right (2026-11-21) */}
|
{/* the list: the whole width, or narrower and placed left / centre / right (2026-11-21) */}
|
||||||
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', width: `${c.board_width || 100}%`,
|
<div style={{ flex: 1, minHeight: 0, display: 'flex', flexDirection: 'column', width: `${c.board_width || 100}%`,
|
||||||
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start' }} data-testid="signage-menu-board" data-align={c.board_align || 'left'}>
|
alignSelf: BOARD_ALIGN[c.board_align] || 'flex-start' }} data-testid="signage-menu-board" data-align={c.board_align || 'left'}>
|
||||||
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: accent, lineHeight: 1.1,
|
{c.title && <h1 style={{ fontSize: `${7 * scale}cqmin`, fontWeight: 800, margin: '0 0 2cqmin', color: c.heading_style?.colour || accent, lineHeight: 1.1,
|
||||||
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
textAlign: c.board_align || 'left' }}>{c.title}</h1>}
|
||||||
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
<div style={{ columnCount: c.columns || 2, columnGap: '5cqmin', fontSize: `${3.2 * scale}cqmin`, flex: 1, minHeight: 0, overflow: 'hidden', columnFill: 'auto', ...listSpacing(c) }}
|
||||||
data-testid="signage-menu-list">
|
data-testid="signage-menu-list">
|
||||||
@@ -100,7 +100,6 @@ export function MenuGroups({ c, groups }) {
|
|||||||
const { t } = useTranslation('terminal')
|
const { t } = useTranslation('terminal')
|
||||||
const { formatMoney } = useFormat()
|
const { formatMoney } = useFormat()
|
||||||
const look = menuLook(c)
|
const look = menuLook(c)
|
||||||
const accent = c.accent_colour || '#f59e0b'
|
|
||||||
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
|
const priceW = `${(priceChars(groups, formatMoney) * 0.62).toFixed(2)}em`
|
||||||
const nameFills = look.itemAlign !== 'left'
|
const nameFills = look.itemAlign !== 'left'
|
||||||
return (
|
return (
|
||||||
@@ -123,7 +122,7 @@ export function MenuGroups({ c, groups }) {
|
|||||||
<span style={{ ...look.item, textDecoration: it.available ? look.item.textDecoration : 'line-through',
|
<span style={{ ...look.item, textDecoration: it.available ? look.item.textDecoration : 'line-through',
|
||||||
...(nameFills ? { flex: 1, minWidth: 0, textAlign: look.itemAlign } : {}) }} data-testid="signage-menu-name">{it.name}</span>
|
...(nameFills ? { flex: 1, minWidth: 0, textAlign: look.itemAlign } : {}) }} data-testid="signage-menu-name">{it.name}</span>
|
||||||
{it.badge && (
|
{it.badge && (
|
||||||
<span style={{ background: accent, color: '#111', fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.5em', borderRadius: '99em',
|
<span style={{ ...look.badge, fontSize: '0.55em', fontWeight: 800, padding: '0.1em 0.5em', borderRadius: '99em',
|
||||||
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4 }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
textTransform: 'uppercase', letterSpacing: '0.05em', whiteSpace: 'nowrap', lineHeight: 1.4 }} data-testid="signage-badge">{t(`signage.badges.${it.badge}`)}</span>
|
||||||
)}
|
)}
|
||||||
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
{!it.available && <span style={{ fontSize: '0.6em', whiteSpace: 'nowrap' }} data-testid="signage-sold-out">{t('signage.soldOut')}</span>}
|
||||||
@@ -327,7 +326,7 @@ function MenuWidget({ board: b, menu, now }) {
|
|||||||
return (
|
return (
|
||||||
<div style={{ width: '100%', height: '100%', overflow: 'hidden', fontSize, color: b.text_colour || '#fff', fontFamily: FONTS[b.font] || FONTS.sans, textAlign: 'left' }}
|
<div style={{ width: '100%', height: '100%', overflow: 'hidden', fontSize, color: b.text_colour || '#fff', fontFamily: FONTS[b.font] || FONTS.sans, textAlign: 'left' }}
|
||||||
data-testid="signage-w-menu" data-page={page} data-pages={pages.length}>
|
data-testid="signage-w-menu" data-page={page} data-pages={pages.length}>
|
||||||
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
{b.title && <div style={{ fontSize: '1.5em', fontWeight: 800, color: b.heading_style?.colour || accent, lineHeight: 1.15, marginBottom: '0.3em' }}>{b.title}</div>}
|
||||||
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
|
<div style={{ columnCount: cols, columnGap: '1.2em', columnFill: 'auto', ...listSpacing(b) }} data-testid="signage-menu-list">
|
||||||
<MenuGroups c={b} groups={pages[page] || []} />
|
<MenuGroups c={b} groups={pages[page] || []} />
|
||||||
</div>
|
</div>
|
||||||
@@ -337,25 +336,32 @@ function MenuWidget({ board: b, menu, now }) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A stack (2026-11-21): parts side by side ("row") or one over the other ("column"), each its share
|
* A stack (2026-11-21): parts side by side ("row") or one over the other ("column"), each its share
|
||||||
* of the stack, showing a widget (filling the part) or a whole library slide.
|
* of the stack, showing widgets (each filling its place; several share the part, one over the other
|
||||||
|
* in a side-by-side stack and side by side in the other: owner review 4) or a whole library slide.
|
||||||
*/
|
*/
|
||||||
function Stack({ w, path, ctx }) {
|
function Stack({ w, path, ctx }) {
|
||||||
const cells = w.cells || []
|
const cells = w.cells || []
|
||||||
const Embed = ctx.embed
|
const Embed = ctx.embed
|
||||||
|
const across = w.direction === 'column' ? 'row' : 'column'
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', flexDirection: w.direction === 'column' ? 'column' : 'row', width: '100%', height: '100%' }}
|
<div style={{ display: 'flex', flexDirection: w.direction === 'column' ? 'column' : 'row', width: '100%', height: '100%' }}
|
||||||
data-testid="signage-w-stack" data-direction={w.direction || 'row'}>
|
data-testid="signage-w-stack" data-direction={w.direction || 'row'}>
|
||||||
{cells.map((c, j) => {
|
{cells.map((c, j) => {
|
||||||
const cp = `${path}.${j}`
|
const cp = `${path}.${j}`
|
||||||
const slide = c.slide_id ? ctx.extras[cp]?.slide : null
|
const ws = cellWidgets(c)
|
||||||
const body = c.widget ? widgetBody(c.widget, ctx, true, cp) : null
|
const slide = !ws.length && c.slide_id ? ctx.extras[cp]?.slide : null
|
||||||
const align = c.widget?.align && c.widget.align !== 'auto' ? c.widget.align : 'center'
|
|
||||||
return (
|
return (
|
||||||
<div key={j} style={{ flex: `${c.share || 1} 1 0%`, minWidth: 0, minHeight: 0, position: 'relative', overflow: 'hidden', containerType: 'size' }}
|
<div key={j} style={{ flex: `${c.share || 1} 1 0%`, minWidth: 0, minHeight: 0, position: 'relative', overflow: 'hidden', containerType: 'size',
|
||||||
data-testid="signage-stack-cell" data-share={c.share}>
|
display: 'flex', flexDirection: across }} data-testid="signage-stack-cell" data-share={c.share}>
|
||||||
{body && (
|
{ws.map((cw, k) => {
|
||||||
<div style={{ width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: SELF[align], textAlign: align }}>{body}</div>
|
const align = cw.align && cw.align !== 'auto' ? cw.align : 'center'
|
||||||
)}
|
return (
|
||||||
|
<div key={k} style={{ flex: '1 1 0%', minWidth: 0, minHeight: 0, overflow: 'hidden', containerType: 'size',
|
||||||
|
display: 'flex', alignItems: 'center', justifyContent: SELF[align], textAlign: align }} data-testid="signage-stack-place">
|
||||||
|
{widgetBody(cw, ctx, true, `${cp}.${k}`)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})}
|
||||||
{slide && Embed && <Embed slide={slide} media={ctx.media} venue={ctx.venue} now={ctx.now} />}
|
{slide && Embed && <Embed slide={slide} media={ctx.media} venue={ctx.venue} now={ctx.now} />}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -321,7 +321,8 @@ const DOTS = { dotted: 'dotted', dashed: 'dashed', solid: 'solid' }
|
|||||||
* board's text size): headings, names and prices each their own size, colour, font, bold / italic /
|
* board's text size): headings, names and prices each their own size, colour, font, bold / italic /
|
||||||
* underline and alignment (empty: the board's text size and font, the text colour for names and the
|
* underline and alignment (empty: the board's text size and font, the text colour for names and the
|
||||||
* accent colour for headings and prices); the dots between name and price; line and letter spacing
|
* accent colour for headings and prices); the dots between name and price; line and letter spacing
|
||||||
* (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape.
|
* (auto: 1.25 and normal; set on the list, never inherited from the page); photos' size and shape;
|
||||||
|
* the badges' colours (2026-11-21: their text the venue's, or white / black to read on them).
|
||||||
*/
|
*/
|
||||||
export function menuLook(c = {}) {
|
export function menuLook(c = {}) {
|
||||||
const base = c.text_size || 100
|
const base = c.text_size || 100
|
||||||
@@ -345,6 +346,9 @@ export function menuLook(c = {}) {
|
|||||||
dots: d.style === 'none'
|
dots: d.style === 'none'
|
||||||
? { borderBottom: 'none' }
|
? { borderBottom: 'none' }
|
||||||
: { borderBottom: `${+(0.08 * (d.size || 100) / 100).toFixed(3)}em ${DOTS[d.style] || 'dotted'} ${d.colour || 'currentColor'}`, opacity: d.colour ? 1 : 0.35 },
|
: { borderBottom: `${+(0.08 * (d.size || 100) / 100).toFixed(3)}em ${DOTS[d.style] || 'dotted'} ${d.colour || 'currentColor'}`, opacity: d.colour ? 1 : 0.35 },
|
||||||
|
// badges: the accent (also the page dots), their text the venue's or one that reads on it
|
||||||
|
badge: { background: accent, color: c.badge_text_colour || readableOn(accent) },
|
||||||
|
title: c.heading_style?.colour || accent,
|
||||||
lineHeight: c.line_height || 1.25,
|
lineHeight: c.line_height || 1.25,
|
||||||
letterSpacing: c.letter_spacing != null ? `${c.letter_spacing}em` : 'normal',
|
letterSpacing: c.letter_spacing != null ? `${c.letter_spacing}em` : 'normal',
|
||||||
photo: { size: `${+(2.2 * (c.photo_size || 100) / 100).toFixed(3)}em`, radius: RADIUS[c.photo_shape] || RADIUS.rounded },
|
photo: { size: `${+(2.2 * (c.photo_size || 100) / 100).toFixed(3)}em`, radius: RADIUS[c.photo_shape] || RADIUS.rounded },
|
||||||
@@ -354,6 +358,28 @@ export function menuLook(c = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A stack part's widgets (a part stored before owner review 4 has one `widget`). */
|
||||||
|
export function cellWidgets(c) {
|
||||||
|
return c?.widgets?.length ? c.widgets : c?.widget ? [c.widget] : []
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A text colour that reads on `hex` (#rgb, #rrggbb or #rrggbbaa; the alpha is ignored): white on a
|
||||||
|
* dark colour, near-black on a light one (a badge's text when the venue chose none, 2026-11-21).
|
||||||
|
*/
|
||||||
|
export function readableOn(hex) {
|
||||||
|
let h = String(hex || '').replace('#', '')
|
||||||
|
if (h.length === 3 || h.length === 4) h = h.slice(0, 3).split('').map(x => x + x).join('')
|
||||||
|
if (!/^[0-9a-f]{6}/i.test(h)) return '#111111'
|
||||||
|
const [r, g, b] = [0, 2, 4].map(i => {
|
||||||
|
const v = parseInt(h.slice(i, i + 2), 16) / 255
|
||||||
|
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4
|
||||||
|
})
|
||||||
|
const lum = 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||||||
|
// the text with the better contrast (WCAG): white beats near-black below ~0.18
|
||||||
|
return lum < 0.18 ? '#ffffff' : '#111111'
|
||||||
|
}
|
||||||
|
|
||||||
/** A page's widest price, in characters: the price column's width, so names and dots line up. */
|
/** A page's widest price, in characters: the price column's width, so names and dots line up. */
|
||||||
export function priceChars(groups, format) {
|
export function priceChars(groups, format) {
|
||||||
let n = 0
|
let n = 0
|
||||||
|
|||||||
@@ -192,3 +192,17 @@ test("a menu's look part by part: sizes against the board's text, colours fall b
|
|||||||
assert.deepEqual(menuLook({ dot_style: { style: 'none' } }).dots, { borderBottom: 'none' })
|
assert.deepEqual(menuLook({ dot_style: { style: 'none' } }).dots, { borderBottom: 'none' })
|
||||||
assert.equal(priceChars([{ items: [{ price: 4.5 }, { price: 12 }, { price: null }] }], p => `€${p.toFixed(2)}`), 6)
|
assert.equal(priceChars([{ items: [{ price: 4.5 }, { price: 12 }, { price: null }] }], p => `€${p.toFixed(2)}`), 6)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('owner review 4: a part\'s widgets (one stored as `widget` too), badges that read', async () => {
|
||||||
|
const { cellWidgets, menuLook, readableOn } = await import('../src/logic.js')
|
||||||
|
assert.deepEqual(cellWidgets({ widgets: [{ kind: 'clock' }, { kind: 'date' }] }).map(w => w.kind), ['clock', 'date'])
|
||||||
|
assert.deepEqual(cellWidgets({ widget: { kind: 'qr' } }).map(w => w.kind), ['qr'])
|
||||||
|
assert.deepEqual(cellWidgets({ slide_id: 3 }), [])
|
||||||
|
assert.equal(readableOn('#111827'), '#ffffff')
|
||||||
|
assert.equal(readableOn('#1e3a8acc'), '#ffffff')
|
||||||
|
assert.equal(readableOn('#f59e0b'), '#111111')
|
||||||
|
assert.equal(readableOn('#fff'), '#111111')
|
||||||
|
assert.deepEqual(menuLook({ accent_colour: '#1e3a8a' }).badge, { background: '#1e3a8a', color: '#ffffff' })
|
||||||
|
assert.deepEqual(menuLook({ accent_colour: '#1e3a8a', badge_text_colour: '#fde68a' }).badge, { background: '#1e3a8a', color: '#fde68a' })
|
||||||
|
assert.equal(menuLook({ accent_colour: '#123456', heading_style: { colour: '#ff0000' } }).title, '#ff0000')
|
||||||
|
})
|
||||||
|
|||||||
@@ -465,6 +465,15 @@
|
|||||||
box-shadow: var(--x-shadow-popover); outline: none;
|
box-shadow: var(--x-shadow-popover); outline: none;
|
||||||
animation: x-fade-in var(--x-duration-fast) var(--x-ease);
|
animation: x-fade-in var(--x-duration-fast) var(--x-ease);
|
||||||
}
|
}
|
||||||
|
/* ── Popover (2026-11-21): a small panel under a button, kept inside the window ── */
|
||||||
|
.x-popover {
|
||||||
|
position: fixed; z-index: var(--x-z-popover); box-sizing: border-box;
|
||||||
|
max-width: calc(100vw - 16px); overflow: auto;
|
||||||
|
background: var(--x-surface); color: var(--x-ink); color-scheme: var(--x-color-scheme);
|
||||||
|
border: var(--x-border-width) solid var(--x-line); border-radius: var(--x-radius-card);
|
||||||
|
box-shadow: var(--x-shadow-popover); outline: none;
|
||||||
|
animation: x-fade-in var(--x-duration-fast) var(--x-ease);
|
||||||
|
}
|
||||||
.x-dropdown__search { padding: var(--x-space-2); border-bottom: var(--x-border-width) solid var(--x-line); }
|
.x-dropdown__search { padding: var(--x-space-2); border-bottom: var(--x-border-width) solid var(--x-line); }
|
||||||
.x-dropdown__list { list-style: none; margin: 0; padding: var(--x-space-1); overflow-y: auto; min-height: 0; }
|
.x-dropdown__list { list-style: none; margin: 0; padding: var(--x-space-1); overflow-y: auto; min-height: 0; }
|
||||||
.x-dropdown__option {
|
.x-dropdown__option {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { cx } from '../internal/cx.js'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The page rule (2026-11-20): every app page's root. It scrolls on its own, fills the area up to
|
* The page rule (2026-11-20): every app page's root. It scrolls on its own, fills the area up to
|
||||||
* a 16:9 screen's width (--x-page-max) and is centred beyond it (ultrawides), with the same
|
* 2200 px (--x-page-max: a 1080p screen is filled; the window's height never narrows it) and is centred beyond it (ultrawides), with the same
|
||||||
* padding and gaps everywhere. Never put padding, max-width or overflow on a page's root yourself.
|
* padding and gaps everywhere. Never put padding, max-width or overflow on a page's root yourself.
|
||||||
*
|
*
|
||||||
* <Page testId="contacts-page">
|
* <Page testId="contacts-page">
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||||
|
import { cx } from '../internal/cx.js'
|
||||||
|
import { Portal } from '../internal/Portal.jsx'
|
||||||
|
|
||||||
|
const GAP = 6
|
||||||
|
const MARGIN = 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A small floating panel under a button (2026-11-21): a colour picker, an "Add…" menu. Drawn over
|
||||||
|
* everything (portal, fixed), like the Dropdown's list: below its button, above when there's no
|
||||||
|
* room, and always kept inside the window, so it never makes a page or a section scroll sideways.
|
||||||
|
* Closes on a click outside (the button excluded) and on Escape.
|
||||||
|
*
|
||||||
|
* const btn = useRef(null)
|
||||||
|
* <Button ref={btn} onClick={() => setOpen(o => !o)}>Add</Button>
|
||||||
|
* <Popover open={open} anchor={btn} onClose={() => setOpen(false)} role="menu">…</Popover>
|
||||||
|
*/
|
||||||
|
export function Popover({ open, anchor, onClose, className, style, children, role = 'dialog', ...rest }) {
|
||||||
|
const panel = useRef(null)
|
||||||
|
const [pos, setPos] = useState(null)
|
||||||
|
|
||||||
|
const place = useCallback(() => {
|
||||||
|
const b = anchor?.current?.getBoundingClientRect()
|
||||||
|
const p = panel.current?.getBoundingClientRect()
|
||||||
|
if (!b || !p) return
|
||||||
|
const below = window.innerHeight - b.bottom - GAP - MARGIN
|
||||||
|
const above = b.top - GAP - MARGIN
|
||||||
|
const up = p.height > below && above > below
|
||||||
|
const left = Math.min(Math.max(MARGIN, b.left), Math.max(MARGIN, window.innerWidth - MARGIN - p.width))
|
||||||
|
const top = up ? Math.max(MARGIN, b.top - GAP - p.height) : b.bottom + GAP
|
||||||
|
setPos({ left, top, maxHeight: Math.max(160, up ? above : below) })
|
||||||
|
}, [anchor])
|
||||||
|
|
||||||
|
useLayoutEffect(() => { if (open) place(); else setPos(null) }, [open, place])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return undefined
|
||||||
|
const away = e => {
|
||||||
|
if (panel.current?.contains(e.target) || anchor?.current?.contains(e.target)) return
|
||||||
|
onClose?.()
|
||||||
|
}
|
||||||
|
const esc = e => { if (e.key === 'Escape') { e.stopPropagation(); onClose?.() } }
|
||||||
|
const onScroll = e => { if (!panel.current?.contains(e.target)) place() }
|
||||||
|
document.addEventListener('pointerdown', away)
|
||||||
|
window.addEventListener('keydown', esc)
|
||||||
|
window.addEventListener('resize', place)
|
||||||
|
window.addEventListener('scroll', onScroll, true)
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('pointerdown', away)
|
||||||
|
window.removeEventListener('keydown', esc)
|
||||||
|
window.removeEventListener('resize', place)
|
||||||
|
window.removeEventListener('scroll', onScroll, true)
|
||||||
|
}
|
||||||
|
}, [open, anchor, onClose, place])
|
||||||
|
|
||||||
|
if (!open) return null
|
||||||
|
return (
|
||||||
|
<Portal>
|
||||||
|
<div ref={panel} role={role} className={cx('x-popover', className)} {...rest}
|
||||||
|
style={{ ...style, ...(pos ? { left: pos.left, top: pos.top, maxHeight: pos.maxHeight } : { left: 0, top: 0, visibility: 'hidden' }) }}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ export { EmptyState } from './components/EmptyState.jsx'
|
|||||||
export { Spinner } from './components/Spinner.jsx'
|
export { Spinner } from './components/Spinner.jsx'
|
||||||
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
export { Field, Input, Textarea, Select } from './components/Field.jsx'
|
||||||
export { Dropdown } from './components/Dropdown.jsx'
|
export { Dropdown } from './components/Dropdown.jsx'
|
||||||
|
export { Popover } from './components/Popover.jsx'
|
||||||
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
export { Page, PageHeader, Pane, Toolbar, ToolbarSpacer } from './components/Page.jsx'
|
||||||
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
export { SearchInput, FilterChip, Segmented, Tabs } from './components/Controls.jsx'
|
||||||
export { Switch } from './components/Switch.jsx'
|
export { Switch } from './components/Switch.jsx'
|
||||||
|
|||||||
@@ -588,9 +588,10 @@
|
|||||||
--x-pad-card: 20px;
|
--x-pad-card: 20px;
|
||||||
--x-pad-card-y: 14px; /* a card's header row and list rows */
|
--x-pad-card-y: 14px; /* a card's header row and list rows */
|
||||||
|
|
||||||
/* Pages (the page rule, 2026-11-20): a page fills its area up to a 16:9 screen's width and
|
/* Pages (the page rule, 2026-11-20; owner 2026-11-21): a page fills its area up to 2200 px
|
||||||
is centred beyond it, so ultrawides keep a 16:9 page instead of stretched content. */
|
(a 1080p screen is filled) and is centred beyond it, so ultrawides don't stretch the content.
|
||||||
--x-page-max: max(1280px, calc(100vh * 16 / 9));
|
A fixed width: a short window never makes the page narrower. */
|
||||||
|
--x-page-max: 2200px;
|
||||||
--x-page-pad: 24px;
|
--x-page-pad: 24px;
|
||||||
--x-page-gap: 20px;
|
--x-page-gap: 20px;
|
||||||
--x-page-form-max: 880px; /* forms and settings that read badly when stretched */
|
--x-page-form-max: 880px; /* forms and settings that read badly when stretched */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// The page rule (2026-11-20): every manager page is a <Page> that scrolls on its own, fills a
|
// The page rule (2026-11-20): every manager page is a <Page> that scrolls on its own, fills a
|
||||||
// 1080p screen and stays at 16:9 width, centred, on an ultrawide. For each page, at 1920×1080
|
// 1080p screen and stays at 2200 px (never narrowed by a short window), centred, on an ultrawide. For each page, at 1920×1080
|
||||||
// and 3440×1440: the page body exists, fills the content area (1080p) or is capped and centred
|
// and 3440×1440: the page body exists, fills the content area (1080p) or is capped and centred
|
||||||
// (ultrawide), and the page scrolls when its content is taller than the screen. Screenshots of a
|
// (ultrawide), and the page scrolls when its content is taller than the screen. Screenshots of a
|
||||||
// few key screens (and the open dropdowns / the day summary) go to out/manager-layout/.
|
// few key screens (and the open dropdowns / the day summary) go to out/manager-layout/.
|
||||||
@@ -37,7 +37,7 @@ const vite = spawn('npx', ['vite', '--port', '5191', '--strictPort'], {
|
|||||||
stdio: ['ignore', log, log], env: { ...process.env, XENIA_BACKEND: backend.url },
|
stdio: ['ignore', log, log], env: { ...process.env, XENIA_BACKEND: backend.url },
|
||||||
})
|
})
|
||||||
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||||
const r = reporter('manager layout (the page rule): fills 1080p, 16:9 and centred on ultrawides, scrolls')
|
const r = reporter('manager layout (the page rule): fills 1080p, 2200 px and centred on ultrawides, scrolls')
|
||||||
const name = p => p.replace(/[/?=]/g, '-')
|
const name = p => p.replace(/[/?=]/g, '-')
|
||||||
try {
|
try {
|
||||||
await waitHttp(APP)
|
await waitHttp(APP)
|
||||||
@@ -71,7 +71,7 @@ try {
|
|||||||
const a = { left: s.left, right: s.left + scroll.clientWidth, width: scroll.clientWidth }
|
const a = { left: s.left, right: s.left + scroll.clientWidth, width: scroll.clientWidth }
|
||||||
// a form page (settings) is centred at its own width
|
// a form page (settings) is centred at its own width
|
||||||
const form = body.classList.contains('x-page__body--form')
|
const form = body.classList.contains('x-page__body--form')
|
||||||
return { form, left: b.left - a.left, right: a.right - b.right, width: b.width, area: a.width, cap: Math.max(1280, innerHeight * 16 / 9),
|
return { form, left: b.left - a.left, right: a.right - b.right, width: b.width, area: a.width, cap: 2200,
|
||||||
scrolls: scroll.scrollHeight <= scroll.clientHeight + 1 || getComputedStyle(scroll).overflowY === 'auto' }
|
scrolls: scroll.scrollHeight <= scroll.clientHeight + 1 || getComputedStyle(scroll).overflowY === 'auto' }
|
||||||
})
|
})
|
||||||
if (!m) { bad.push(`${p}: no <Page>`); continue }
|
if (!m) { bad.push(`${p}: no <Page>`); continue }
|
||||||
@@ -80,7 +80,7 @@ try {
|
|||||||
if (!centred || !fills || !m.scrolls) bad.push(`${p}: ${JSON.stringify(m)}`)
|
if (!centred || !fills || !m.scrolls) bad.push(`${p}: ${JSON.stringify(m)}`)
|
||||||
if (SHOTS.includes(p)) await page.screenshot({ path: path.join(DIR, `${name(p)}-${screen.id}.png`) })
|
if (SHOTS.includes(p)) await page.screenshot({ path: path.join(DIR, `${name(p)}-${screen.id}.png`) })
|
||||||
}
|
}
|
||||||
r.check(`${screen.id}: every page fills its area up to 16:9, centred, and scrolls`, bad.length === 0, bad.join('\n'))
|
r.check(`${screen.id}: every page fills its area up to 2200 px, centred, and scrolls`, bad.length === 0, bad.join('\n'))
|
||||||
|
|
||||||
// Products (2026-11-21): the page doesn't scroll, its two panes do, each on its own
|
// Products (2026-11-21): the page doesn't scroll, its two panes do, each on its own
|
||||||
await page.goto(`${APP}/management/products`)
|
await page.goto(`${APP}/management/products`)
|
||||||
|
|||||||
+36
-2
@@ -318,8 +318,8 @@ try {
|
|||||||
await waitFor(async () => (await textCard.getByTestId('signage-widget-position').textContent()).includes('Custom'), 4000, 200) === true)
|
await waitFor(async () => (await textCard.getByTestId('signage-widget-position').textContent()).includes('Custom'), 4000, 200) === true)
|
||||||
await mgr.getByTestId('signage-widget-add-hstack').click()
|
await mgr.getByTestId('signage-widget-add-hstack').click()
|
||||||
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
const stackCard = mgr.locator('[data-testid="signage-widget"][data-kind="stack"]')
|
||||||
await stackCard.getByTestId('signage-stack-shows').first().click()
|
await stackCard.getByTestId('signage-stack-cell-editor').first().getByTestId('signage-stack-add').click()
|
||||||
await mgr.getByRole('option', { name: 'Clock', exact: true }).click()
|
await mgr.getByTestId('signage-stack-add-clock').click()
|
||||||
// the parts sized by dragging the line between them on the bar (owner review 3)
|
// the parts sized by dragging the line between them on the bar (owner review 3)
|
||||||
const bar = await stackCard.getByTestId('signage-stack-bar').first().boundingBox()
|
const bar = await stackCard.getByTestId('signage-stack-bar').first().boundingBox()
|
||||||
const ln = await stackCard.getByTestId('signage-stack-line').first().boundingBox()
|
const ln = await stackCard.getByTestId('signage-stack-line').first().boundingBox()
|
||||||
@@ -338,6 +338,17 @@ try {
|
|||||||
await mgr.getByTestId('signage-stack-add-date').click()
|
await mgr.getByTestId('signage-stack-add-date').click()
|
||||||
r.check('2026-11-21 (3): "Add a widget" puts a date in the second part',
|
r.check('2026-11-21 (3): "Add a widget" puts a date in the second part',
|
||||||
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1).getByTestId('signage-w-date').count()) === 1, 6000, 300) === true)
|
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1).getByTestId('signage-w-date').count()) === 1, 6000, 300) === true)
|
||||||
|
// owner review 4: a second widget in the same part, then one removed
|
||||||
|
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).getByTestId('signage-stack-add').click()
|
||||||
|
await mgr.getByTestId('signage-stack-add-text').click()
|
||||||
|
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="text"]').getByTestId('signage-widget-own-text').fill('Two in one')
|
||||||
|
const part2 = () => mgr.getByTestId('signage-preview').getByTestId('signage-stack-cell').nth(1)
|
||||||
|
r.check('2026-11-21 (4): a part holds two widgets (a date and a text), one over the other',
|
||||||
|
await waitFor(async () => (await part2().getByTestId('signage-stack-place').count()) === 2 && (await part2().getByTestId('signage-w-text').count()) === 1
|
||||||
|
&& (await part2().getByTestId('signage-w-date').count()) === 1, 6000, 300) === true)
|
||||||
|
await stackCard.getByTestId('signage-stack-cell-editor').nth(1).locator('[data-testid="signage-stack-part-widget"][data-kind="date"]').getByTestId('signage-stack-part-remove').click()
|
||||||
|
r.check('2026-11-21 (4): …and one of them removed',
|
||||||
|
await waitFor(async () => (await part2().getByTestId('signage-stack-place').count()) === 1 && (await part2().getByTestId('signage-w-date').count()) === 0, 6000, 300) === true)
|
||||||
// Delete removes the picked widget (picked on its card)
|
// Delete removes the picked widget (picked on its card)
|
||||||
await stackCard.locator('span', { hasText: 'Horizontal stack' }).first().click()
|
await stackCard.locator('span', { hasText: 'Horizontal stack' }).first().click()
|
||||||
await mgr.keyboard.press('Delete')
|
await mgr.keyboard.press('Delete')
|
||||||
@@ -349,6 +360,29 @@ try {
|
|||||||
await mgr.getByTestId('signage-item-name-input').fill('Signature dish')
|
await mgr.getByTestId('signage-item-name-input').fill('Signature dish')
|
||||||
await mgr.getByTestId('signage-item-name-input').press('Enter')
|
await mgr.getByTestId('signage-item-name-input').press('Enter')
|
||||||
await mgr.getByTestId('signage-look-item_style-align-right').click()
|
await mgr.getByTestId('signage-look-item_style-align-right').click()
|
||||||
|
// owner review 4: each look field changes only itself; the colour panel stays inside the window
|
||||||
|
r.check('2026-11-21 (4): names align left or right only', (await mgr.getByTestId('signage-look-item_style-align-center').count()) === 0)
|
||||||
|
const setRange = (loc, v) => loc.evaluate((el, x) => {
|
||||||
|
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(el, String(x))
|
||||||
|
el.dispatchEvent(new Event('input', { bubbles: true }))
|
||||||
|
}, v)
|
||||||
|
const headSize = async () => mgr.getByTestId('signage-look-heading_style-size').inputValue()
|
||||||
|
const before = await headSize()
|
||||||
|
await setRange(mgr.getByTestId('signage-look-item_style-size'), 180)
|
||||||
|
const headColour = async () => (await mgr.getByTestId('signage-look-heading_style-colour-open').textContent()).trim()
|
||||||
|
const colourBefore = await headColour()
|
||||||
|
await mgr.getByTestId('signage-accent-open').click()
|
||||||
|
const panel = await mgr.getByTestId('signage-accent-panel').boundingBox()
|
||||||
|
const vw = await mgr.evaluate(() => innerWidth)
|
||||||
|
r.check('2026-11-21 (4): the colour panel opens inside the window (12 ready colours)',
|
||||||
|
panel && panel.x >= 0 && panel.x + panel.width <= vw && (await mgr.getByTestId('signage-accent-preset').count()) === 12, JSON.stringify(panel))
|
||||||
|
await mgr.getByTestId('signage-accent-preset').nth(10).click()
|
||||||
|
r.check('2026-11-21 (4): the names size and the badges colour leave the headings as they were',
|
||||||
|
(await headSize()) === before && (await headColour()) === colourBefore, `${before} → ${await headSize()}, ${colourBefore} → ${await headColour()}`)
|
||||||
|
await mgr.getByTestId('signage-look-dots-colour-open').click()
|
||||||
|
await setRange(mgr.getByTestId('signage-look-dots-colour-opacity'), 50)
|
||||||
|
r.check('2026-11-21 (4): a see-through colour (#rrggbbaa)', /^#[0-9a-f]{8}$/.test((await mgr.getByTestId('signage-look-dots-colour-open').textContent()).trim()))
|
||||||
|
await mgr.keyboard.press('Escape')
|
||||||
r.check('2026-11-21 (3): a product named for this board only shows on the preview, the catalogue name under it in the list',
|
r.check('2026-11-21 (3): a product named for this board only shows on the preview, the catalogue name under it in the list',
|
||||||
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByText('Signature dish').count()) > 0
|
await waitFor(async () => (await mgr.getByTestId('signage-preview').getByText('Signature dish').count()) > 0
|
||||||
&& (await mgr.getByTestId('signage-menu-board').getByText(/Catalogue:/).count()) > 0, 6000, 300) === true)
|
&& (await mgr.getByTestId('signage-menu-board').getByText(/Catalogue:/).count()) > 0, 6000, 300) === true)
|
||||||
|
|||||||
Reference in New Issue
Block a user