From f8a52a2477f7478ba7a3b28b9e15a1472b973c3a Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 11 Nov 2026 10:10:36 +0800 Subject: [PATCH] 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 --- packages/day-card/day-card.test.mjs | 7 +++++++ packages/day-card/package.json | 2 +- packages/day-card/page/app.js | 2 +- packages/day-card/page/backgrounds.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/day-card/day-card.test.mjs b/packages/day-card/day-card.test.mjs index 6753ef7..ac84cc4 100644 --- a/packages/day-card/day-card.test.mjs +++ b/packages/day-card/day-card.test.mjs @@ -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)') +}) diff --git a/packages/day-card/package.json b/packages/day-card/package.json index 0eab18b..3cccf6a 100644 --- a/packages/day-card/package.json +++ b/packages/day-card/package.json @@ -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"], diff --git a/packages/day-card/page/app.js b/packages/day-card/page/app.js index 113d5f1..e6c7b21 100644 --- a/packages/day-card/page/app.js +++ b/packages/day-card/page/app.js @@ -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() { diff --git a/packages/day-card/page/backgrounds.js b/packages/day-card/page/backgrounds.js index 2b2c0d6..e72917a 100644 --- a/packages/day-card/page/backgrounds.js +++ b/packages/day-card/page/backgrounds.js @@ -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)" };