feat(signage): More settings for every widget (opacity, rotation, shadow, border, entrance animation, a logo's fit; text weight, highlight, typing out; date and clock formats; a logo in a QR code)

Folded under each widget card like Text and colours. The TV puts them on the element
that places the widget (fx), animations on translate / scale so its place's transform
stays (an older TV only fades); an entrance animates to the widget's own opacity.
Calibrating: a strict-mode remount no longer ends it. Plan 6R.17, F-115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 15:01:42 +02:00
co-authored by Claude Opus 5.5
parent 1eb7e5e3a9
commit 673113aff7
11 changed files with 444 additions and 26 deletions
+22 -1
View File
@@ -256,7 +256,7 @@ class Widget(_Strict):
size: Literal["small", "medium", "large", "custom"] = "medium"
box: Optional[Box] = None # position "custom"
align: Literal["auto", "left", "center", "right"] = "auto" # inside its place; auto: by its corner / box
media_id: Optional[int] = None # logo: a picture
media_id: Optional[int] = None # logo: a picture; QR: a logo in its middle (6R.17)
text: Optional[str] = Field(default=None, max_length=500) # message: this text instead of the venue's; text, ticker, a countdown's / hours' title
date_style: Literal["short", "long"] = "long"
clock_seconds: bool = False
@@ -323,6 +323,27 @@ class Widget(_Strict):
gallery_seconds: int = Field(default=5, ge=3, le=120)
gallery_transition: Literal["fade", "slide", "zoom", "none"] = "fade"
gallery_fit: Literal["cover", "contain"] = "cover"
# more settings (6R.17), every widget: on the element that places it
opacity: int = Field(default=100, ge=10, le=100)
rotation: int = Field(default=0, ge=-180, le=180)
shadow: Literal["none", "soft", "strong", "glow"] = "none"
shadow_colour: Optional[str] = Field(default=None, pattern=HEX)
border_width: int = Field(default=0, ge=0, le=20) # tenths of a usual unit
border_colour: Optional[str] = Field(default=None, pattern=HEX)
border_radius: int = Field(default=0, ge=0, le=100) # tenths of a usual unit
animation: Literal["none", "fade", "rise", "drop", "slide-left", "slide-right", "zoom", "pop", "pulse", "float"] = "none"
animation_delay: int = Field(default=0, ge=0, le=50) # tenths of a second
fit: Literal["contain", "cover", "fill"] = "contain" # a logo / picture in its box
# texts
weight: Optional[int] = Field(default=None, ge=100, le=900) # None: as the widget usually is (bold switch)
highlight: Optional[str] = Field(default=None, pattern=HEX) # a marker behind the text
text_effect: Literal["none", "typewriter"] = "none"
# dates and clocks
date_format: Optional[Literal["long", "short", "weekday", "day_month", "weekday_day_month", "numeric", "numeric_short", "iso"]] = None
date_separator: Optional[Literal["/", ".", "-", " "]] = None
clock_format: Literal["24", "12"] = "24"
clock_separator: Literal[":", "."] = ":"
clock_blink: bool = False
@model_validator(mode="after")
def _place(self):
+17
View File
@@ -99,3 +99,20 @@ def test_reviews_typed_in_by_hand(client, owner_h, screens, sent):
assert client.get("/api/signage/reviews", headers=owner_h).json()["reviews"][1]["name"] == "John"
assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 6, "text": "y"}]}).status_code == 422
assert client.put("/api/signage/reviews", headers=owner_h, json={"reviews": [{"name": "x", "stars": 5, "text": ""}]}).status_code == 422
def test_more_settings_of_widgets(client, owner_h, media_dir):
from tests.test_signage import playlist, slide
logo = up(client, owner_h, jpeg(200, 200)).json()
p = playlist(client, owner_h)
w = {"kind": "date", "opacity": 60, "rotation": -15, "shadow": "glow", "border_width": 4, "border_colour": "#ff0000", "border_radius": 20,
"animation": "pop", "animation_delay": 5, "weight": 300, "highlight": "#ffff0080", "text_effect": "typewriter",
"date_format": "numeric", "date_separator": "."}
q = {"kind": "qr", "media_id": logo["id"], "clock_format": "12", "clock_blink": True}
s = slide(client, owner_h, p["id"], "blank", content={"widgets": [w, q]})
got = s["content"]["widgets"][0]
assert {k: got[k] for k in w} == w
assert s["content"]["widgets"][1]["media_id"] == logo["id"]
for bad in ({"kind": "date", "opacity": 5}, {"kind": "date", "animation": "spin"}, {"kind": "date", "date_separator": "|"}, {"kind": "clock", "weight": 1000}):
r = client.post(f"/api/signage/playlists/{p['id']}/slides", headers=owner_h, json={"kind": "blank", "content": {"widgets": [bad]}})
assert err(r) == "signage.content_invalid", bad