magpie
+
diff --git a/internal/gui/assets/theme.js b/internal/gui/assets/theme.js
new file mode 100644
index 00000000..d3e2b782
--- /dev/null
+++ b/internal/gui/assets/theme.js
@@ -0,0 +1,11 @@
+// The saved theme (boot.js), or one the page's address asks for, on the page
+// before its styles first apply: set only once app.js ran, at the foot of the
+// page, a window kept dark under a light system was first drawn light, and
+// the header's buttons faded from light to dark as it loaded. app.js sets it
+// again; this one is for the first paint.
+(function () {
+ var asked = new URLSearchParams(location.search).get("theme");
+ var saved = window.bootPrefs && window.bootPrefs.theme;
+ var theme = asked || (saved && saved !== "system" ? saved : "");
+ if (theme) document.documentElement.dataset.theme = theme;
+})();
diff --git a/internal/gui/tests/api-key-theme.test.cjs b/internal/gui/tests/api-key-theme.test.cjs
index 554758d6..59a9cde8 100644
--- a/internal/gui/tests/api-key-theme.test.cjs
+++ b/internal/gui/tests/api-key-theme.test.cjs
@@ -12,7 +12,7 @@ async function palette(page, selectors) {
const hex = root.getPropertyValue(name).trim();
return `rgb(${[1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16)).join(", ")})`;
};
- const colors = Object.fromEntries(["bg", "card", "card-2", "fg", "fg-2", "muted", "pill", "line", "accent", "accent-fg"]
+ const colors = Object.fromEntries(["bg", "card", "card-2", "fg", "fg-2", "muted", "ctl-fg", "pill", "line", "accent", "accent-fg"]
.map((name) => [name, rgb("--" + name)]));
const elements = Object.fromEntries(Object.entries(selectors).map(([name, selector]) => {
const s = getComputedStyle(document.querySelector(selector));
@@ -60,7 +60,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(input.bg, c.card, "key inputs must not use the browser's default background");
assert.equal(input.color, c.fg);
}
- assert.equal(e.rotate.color, c.muted);
+ assert.equal(e.rotate.color, c["ctl-fg"]); // a text button, in a control's quiet text (#477)
assert.equal(e.keyPick.bg, "rgba(0, 0, 0, 0)");
assert.equal(e.create.bg, c.accent);
assert.equal(e.create.color, c["accent-fg"]);
diff --git a/internal/gui/tests/old-webkit.test.cjs b/internal/gui/tests/old-webkit.test.cjs
index 8cabee9f..56ea56cf 100644
--- a/internal/gui/tests/old-webkit.test.cjs
+++ b/internal/gui/tests/old-webkit.test.cjs
@@ -132,10 +132,12 @@ test("no built-in newer than Safari 15.0 unless compat.js fills it in", async ()
test("compat.js is the first of the page's own scripts", async () => {
const html = await read("index.html");
- // boot.js and omarchy.js run in the head, before the first paint:
- // omarchy.js does nothing off Omarchy, whose WebKitGTK is a current one
+ // boot.js, theme.js and omarchy.js run in the head, before the first
+ // paint: theme.js is ES5 with nothing newer than Safari 10.1's
+ // URLSearchParams, and omarchy.js does nothing off Omarchy, whose
+ // WebKitGTK is a current one
const all = [...html.matchAll(/