A buttons widget: a grid of presses on one message

Several stateless instructions where a single button is one — six presets are
otherwise six tiles to place, six titles to read, and the message they share
repeated six times. Nothing is read back, as for a single button: what these
send is an instruction, and the last one sent is not a state to draw.

Auto-fit columns rather than a configured count: a tile is resized in the
editor and scaled again to whatever panel it hangs on, so how many fit is not
something the document can know.

The editor reads `cfg.buttons` raw rather than through `buttonsOf`, which
drops the blanks — a row being typed into is blank until the first keystroke.

Also carried along by the hooks: the generated SDK was stale (it had no
`RunsReadMetricNames`) and one pre-existing block in `test_panels.py` was
unformatted.
This commit is contained in:
2026-09-04 08:44:16 +02:00
parent 8e62c7726b
commit 10fe2fd760
11 changed files with 252 additions and 10 deletions
+20
View File
@@ -151,6 +151,20 @@ test.beforeAll(async ({ browser }) => {
],
},
},
{
id: "scenes",
type: "buttons",
title: "Scenes",
layout: { lg: { x: 9, y: 0, w: 3, h: 2 } },
config: {
target: w("mode"),
dtype: "str",
buttons: [
{ label: "Night", value: "night" },
{ label: "Away", value: "away" },
],
},
},
{
id: "lamp",
type: "switch",
@@ -488,6 +502,12 @@ test("a control reads back what it published", async ({ page }) => {
await boost.click()
await expect(boost).toHaveAttribute("aria-pressed", "true")
// A grid draws one press per entry and publishes the value of the one
// pressed — nothing is read back, so the segmented control beside it, bound
// to the same message, is what says the publish landed.
await page.getByRole("button", { name: "Night" }).click()
await expect(boost).toHaveAttribute("aria-pressed", "false")
// The latching button names its state; two presses are a round trip.
const lamp = page.getByRole("button", { name: "Lamp" })
await expect(lamp).toHaveText("Off")