frontend: remove the stylix overlay and add hyperhive and Catppuccin light and dark themes
This commit is contained in:
parent
989d1d578c
commit
91e2d26133
1 changed files with 486 additions and 413 deletions
|
|
@ -27,25 +27,36 @@ function boot(stored) {
|
|||
return dataset;
|
||||
}
|
||||
|
||||
test("nothing stored sets the dark default and leaves motion to the system", () => {
|
||||
assert.deepEqual(boot({}), { theme: "dark" });
|
||||
test("nothing stored sets the hyperhive dark default and leaves motion to the system", () => {
|
||||
assert.deepEqual(boot({}), { theme: "hyperhive-dark" });
|
||||
});
|
||||
|
||||
test("a stored light theme and a motion override are set", () => {
|
||||
test("a stored theme and a motion override are set", () => {
|
||||
const set = boot({
|
||||
"swarm-ui:theme-override": '"light"',
|
||||
"swarm-ui:motion-override": '"reduce"',
|
||||
});
|
||||
assert.deepEqual(set, { theme: "light", motion: "reduce" });
|
||||
assert.deepEqual(set, { theme: "hyperhive-light", motion: "reduce" });
|
||||
assert.deepEqual(
|
||||
boot({ "swarm-ui:theme-override": '"catppuccin-mocha-mauve"' }),
|
||||
{ theme: "catppuccin-mocha-mauve" },
|
||||
);
|
||||
});
|
||||
|
||||
test("system leaves the attribute off, so the media query decides", () => {
|
||||
test("a stored dark, from before themes existed, is hyperhive dark", () => {
|
||||
assert.deepEqual(boot({ "swarm-ui:theme-override": '"dark"' }), {
|
||||
theme: "hyperhive-dark",
|
||||
});
|
||||
});
|
||||
|
||||
test("auto, and system from before themes existed, leave the attribute off, so the media query decides", () => {
|
||||
assert.deepEqual(boot({ "swarm-ui:theme-override": '"auto"' }), {});
|
||||
assert.deepEqual(boot({ "swarm-ui:theme-override": '"system"' }), {});
|
||||
});
|
||||
|
||||
test("a value that is not JSON, or not one of the choices, is ignored", () => {
|
||||
assert.deepEqual(boot({ "swarm-ui:theme-override": "light" }), {
|
||||
theme: "dark",
|
||||
theme: "hyperhive-dark",
|
||||
});
|
||||
assert.deepEqual(boot({ "swarm-ui:theme-override": '"blue"' }), {});
|
||||
});
|
||||
|
|
@ -60,7 +71,31 @@ test("storage that throws behaves as if nothing were stored", () => {
|
|||
},
|
||||
document: { documentElement: { dataset } },
|
||||
});
|
||||
assert.deepEqual(dataset, { theme: "dark" });
|
||||
assert.deepEqual(dataset, { theme: "hyperhive-dark" });
|
||||
});
|
||||
|
||||
test("the theme ids are the registry's", () => {
|
||||
const registry = readFileSync(
|
||||
new URL("../../shared/src/settings/themes.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const ids = (text) =>
|
||||
[...text.matchAll(/"((?:hyperhive|catppuccin)-[a-z-]+)"/g)].map(
|
||||
(m) => m[1],
|
||||
);
|
||||
const listed = script.slice(
|
||||
script.indexOf("var themes"),
|
||||
script.indexOf("];"),
|
||||
);
|
||||
assert.deepEqual(
|
||||
ids(listed),
|
||||
ids(
|
||||
registry.slice(
|
||||
registry.indexOf("THEMES"),
|
||||
registry.indexOf("AUTO_THEME"),
|
||||
),
|
||||
).filter((id, i, all) => all.indexOf(id) === i),
|
||||
);
|
||||
});
|
||||
|
||||
test("the keys are the shell's", () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue