day-card 0.2.1: the blur and dim sliders stay put while a slider is dragged (#957)

paintPicker called pop.classList.toggle("photo", B.meta(bg.bg).photo).
A pattern's photo was undefined, not false, and toggle(name, undefined)
flips the class. So each input event of the margin or blur slider hid
or showed the blur and dim sliders in turn. The reporter saw both
states with the teal backdrop picked.

Every backdrop's photo is now a boolean, and the toggle asks for
=== true.

Run, on mote:
- bun test packages/day-card: 15 pass. bun scripts/check.mjs: exit 0.
- A Playwright repro (not committed) loads the page with a stub bridge,
  picks teal, fires input on the margin slider four times, then picks
  alpine and drags blur, then goes back to teal. In Chromium and WebKit
  the old page shows blur as false,true,false,true,false. The new page
  keeps it hidden on teal and shown on alpine on every tick.

Broken by hand: with backgrounds.js from main, the new test goes red
(1 of 15).

Not tried: in magpie's own window on Windows, where the reporter is.

Reported-by: lbjxr
This commit is contained in:
yetone
2026-11-11 10:10:36 +08:00
parent 9001e6f082
commit f8a52a2477
4 changed files with 10 additions and 3 deletions
+7
View File
@@ -247,3 +247,10 @@ test("a saved backdrop is made sound before it is drawn", () => {
expect(B.meta("custom").photo).toBe(true)
expect(B.meta("nope").id).toBe("teal")
})
test("the blur and dim sliders stay put while a slider is dragged (#957)", () => {
// classList.toggle(name, undefined) flips the class, so a pattern's photo
// must be false, not missing, or every input event hides or shows them
for (const id of [...B.list.map((b) => b.id), "custom"]) expect([id, typeof B.meta(id).photo]).toEqual([id, "boolean"])
expect(read("app.js")).toContain('pop.classList.toggle("photo", B.meta(bg.bg).photo === true)')
})
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/page-day-card",
"version": "0.2.0",
"version": "0.2.1",
"description": "A page in magpie's window that draws a day of your AI usage as a card: tokens, cost, each agent and its models, your streak and your average day. Copy it as a picture or save it as a PNG",
"files": ["page", "README.md"],
"keywords": ["magpie", "magpie-page", "usage", "tokens", "cost", "card"],
+1 -1
View File
@@ -574,7 +574,7 @@
$("pad").value = bg.pad;
$("blur").value = bg.blur;
$("dim").value = bg.dim;
pop.classList.toggle("photo", B.meta(bg.bg).photo);
pop.classList.toggle("photo", B.meta(bg.bg).photo === true);
paintChip();
}
async function paintChip() {
+1 -1
View File
@@ -24,7 +24,7 @@
{ id: "sea", photo: true, shadow: "rgba(20, 30, 50, .35)" },
{ id: "dunes", photo: true, shadow: "rgba(70, 30, 0, .4)" },
{ id: "lake", photo: true, shadow: "rgba(0, 20, 12, .5)" },
];
].map((b) => ({ ...b, photo: b.photo === true })); // photo is always a boolean: classList.toggle(name, undefined) flips
const BY = new Map(LIST.map((b) => [b.id, b]));
const CUSTOM = { id: "custom", photo: true, shadow: "rgba(0, 0, 0, .45)" };