Public: anyone can read this; the crew can change it.
Theme menu row is a native select of Auto and ten themes; four new themes (Sand, High contrast, Dusk, Forest) #16348
Check · Review · Land · Live done — Landed and live in production.
ui/themes → main 0 commits
13 files
changed +168
−59
docs/design/size-budget.json +17 −17
| @@ -1,31 +1,31 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "/": { |
| 3 | 3 | "js": 22016, |
| 4 | "css": 48384 | |
| 4 | "css": 48640 | |
| 5 | 5 | }, |
| 6 | 6 | "/explore": { |
| 7 | 7 | "js": 21760, |
| 8 | "css": 48384 | |
| 8 | "css": 48640 | |
| 9 | 9 | }, |
| 10 | 10 | "/map": { |
| 11 | 11 | "js": 28672, |
| 12 | "css": 50176 | |
| 12 | "css": 50304 | |
| 13 | 13 | }, |
| 14 | 14 | "/:owner/:name": { |
| 15 | 15 | "js": 38400, |
| 16 | "css": 48384 | |
| 16 | "css": 48640 | |
| 17 | 17 | }, |
| 18 | 18 | "/changelog": { |
| 19 | 19 | "js": 26880, |
| 20 | "css": 48384 | |
| 20 | "css": 48640 | |
| 21 | 21 | }, |
| 22 | 22 | "/:owner/:name/next": { |
| 23 | 23 | "js": 23296, |
| 24 | "css": 48896 | |
| 24 | "css": 49024 | |
| 25 | 25 | }, |
| 26 | 26 | "/:owner/:name/space": { |
| 27 | 27 | "js": 30208, |
| 28 | "css": 49664 | |
| 28 | "css": 49792 | |
| 29 | 29 | }, |
| 30 | 30 | "/:owner/:name/space.json": { |
| 31 | 31 | "js": 0, |
| @@ -33,39 +33,39 @@ | ||
| 33 | 33 | }, |
| 34 | 34 | "/maintenance": { |
| 35 | 35 | "js": 21760, |
| 36 | "css": 48384 | |
| 36 | "css": 48640 | |
| 37 | 37 | }, |
| 38 | 38 | "/pricing": { |
| 39 | 39 | "js": 21760, |
| 40 | "css": 48384 | |
| 40 | "css": 48640 | |
| 41 | 41 | }, |
| 42 | 42 | "/forges/new": { |
| 43 | 43 | "js": 21760, |
| 44 | "css": 48384 | |
| 44 | "css": 48640 | |
| 45 | 45 | }, |
| 46 | 46 | "/claim": { |
| 47 | 47 | "js": 24320, |
| 48 | "css": 48384 | |
| 48 | "css": 48640 | |
| 49 | 49 | }, |
| 50 | 50 | "/templates": { |
| 51 | 51 | "js": 21760, |
| 52 | "css": 48384 | |
| 52 | "css": 48640 | |
| 53 | 53 | }, |
| 54 | 54 | "/system": { |
| 55 | 55 | "js": 23808, |
| 56 | "css": 48384 | |
| 56 | "css": 48640 | |
| 57 | 57 | }, |
| 58 | 58 | "/feed": { |
| 59 | 59 | "js": 36352, |
| 60 | "css": 48384 | |
| 60 | "css": 48640 | |
| 61 | 61 | }, |
| 62 | 62 | "/board": { |
| 63 | 63 | "js": 26880, |
| 64 | "css": 48384 | |
| 64 | "css": 48640 | |
| 65 | 65 | }, |
| 66 | 66 | "/fleet": { |
| 67 | 67 | "js": 21760, |
| 68 | "css": 48384 | |
| 68 | "css": 48640 | |
| 69 | 69 | }, |
| 70 | 70 | "/talk": { |
| 71 | 71 | "js": 39168, |
| @@ -73,6 +73,6 @@ | ||
| 73 | 73 | }, |
| 74 | 74 | "/:owner/:name/pulls/:number": { |
| 75 | 75 | "js": 32000, |
| 76 | "css": 48384 | |
| 76 | "css": 48640 | |
| 77 | 77 | } |
| 78 | 78 | } |
src/design/themes.ts +103
| @@ -367,6 +367,105 @@ const aurora: Palette = { | ||
| 367 | 367 | "tok-link": "#88c0d0", |
| 368 | 368 | }; |
| 369 | 369 | |
| 370 | /** Sand — warm linen and walnut; one terracotta accent. */ | |
| 371 | const sand: Palette = { | |
| 372 | ...porcelain, | |
| 373 | bg: "#f5eee2", | |
| 374 | fg: "#2a2017", | |
| 375 | card: "#fcf8ef", | |
| 376 | muted: "#ebe2d2", | |
| 377 | "muted-fg": "#6a5a49", | |
| 378 | faint: "#9d8d7a", | |
| 379 | border: "#e0d5c2", | |
| 380 | "border-strong": "#cdbea6", | |
| 381 | primary: "#2a2017", | |
| 382 | "primary-fg": "#fcf8ef", | |
| 383 | accent: "#a3421d", | |
| 384 | "accent-fg": "#fffaf2", | |
| 385 | "shadow-1": "0 1px 2px rgb(42 32 23 / 0.06)", | |
| 386 | "shadow-2": "0 8px 24px rgb(42 32 23 / 0.12)", | |
| 387 | danger: "#b3261e", | |
| 388 | success: "#19702f", | |
| 389 | "tok-comment": "#6b5e4e", | |
| 390 | "tok-link": "#a3421d", | |
| 391 | "tok-heading": "#a3421d", | |
| 392 | "tok-emphasis": "#2a2017", | |
| 393 | }; | |
| 394 | ||
| 395 | /** Contrast — pure black on white, strong rules, a deep blue accent: 7:1 and better everywhere. */ | |
| 396 | const contrastHigh: Palette = { | |
| 397 | ...porcelain, | |
| 398 | bg: "#ffffff", | |
| 399 | fg: "#000000", | |
| 400 | card: "#ffffff", | |
| 401 | muted: "#f0f0f0", | |
| 402 | "muted-fg": "#2b2b2b", | |
| 403 | faint: "#595959", | |
| 404 | border: "#6b6b6b", | |
| 405 | "border-strong": "#000000", | |
| 406 | primary: "#000000", | |
| 407 | "primary-fg": "#ffffff", | |
| 408 | accent: "#0030c0", | |
| 409 | "accent-fg": "#ffffff", | |
| 410 | danger: "#b00020", | |
| 411 | success: "#006b2c", | |
| 412 | attn: "#8a4b00", | |
| 413 | merged: "#5b21b6", | |
| 414 | "add-fg": "#005a24", | |
| 415 | "del-fg": "#a8001c", | |
| 416 | "tok-comment": "#4d4d4d", | |
| 417 | "tok-punctuation": "#4d4d4d", | |
| 418 | "tok-link": "#0030c0", | |
| 419 | "tok-heading": "#0030c0", | |
| 420 | "tok-emphasis": "#000000", | |
| 421 | }; | |
| 422 | ||
| 423 | /** Dusk — soft violet-grey evening; low glare, one lilac accent. */ | |
| 424 | const dusk: Palette = { | |
| 425 | ...ink, | |
| 426 | bg: "#1e1b2e", | |
| 427 | fg: "#ebe7f6", | |
| 428 | card: "#27243a", | |
| 429 | muted: "#2f2b45", | |
| 430 | "muted-fg": "#b4adcc", | |
| 431 | faint: "#8179a0", | |
| 432 | border: "#38344f", | |
| 433 | "border-strong": "#4a4566", | |
| 434 | primary: "#ebe7f6", | |
| 435 | "primary-fg": "#1e1b2e", | |
| 436 | accent: "#b9a0ff", | |
| 437 | "accent-fg": "#1a1628", | |
| 438 | "shadow-1": "0 1px 2px rgb(8 6 20 / 0.4)", | |
| 439 | "shadow-2": "0 8px 24px rgb(8 6 20 / 0.5)", | |
| 440 | "tok-comment": "#8f88ad", | |
| 441 | "tok-link": "#b9a0ff", | |
| 442 | "tok-heading": "#b9a0ff", | |
| 443 | "tok-emphasis": "#ebe7f6", | |
| 444 | }; | |
| 445 | ||
| 446 | /** Forest — deep green-black, calm and dense; one mint accent. */ | |
| 447 | const forest: Palette = { | |
| 448 | ...ink, | |
| 449 | bg: "#0d1411", | |
| 450 | fg: "#e6efe9", | |
| 451 | card: "#131c18", | |
| 452 | muted: "#1a2621", | |
| 453 | "muted-fg": "#a3b6ac", | |
| 454 | faint: "#73887d", | |
| 455 | border: "#25332c", | |
| 456 | "border-strong": "#36483f", | |
| 457 | primary: "#e6efe9", | |
| 458 | "primary-fg": "#0d1411", | |
| 459 | accent: "#5fd39a", | |
| 460 | "accent-fg": "#06120c", | |
| 461 | "shadow-1": "0 1px 2px rgb(0 0 0 / 0.4)", | |
| 462 | "shadow-2": "0 8px 24px rgb(0 0 0 / 0.5)", | |
| 463 | "tok-comment": "#7f948a", | |
| 464 | "tok-link": "#5fd39a", | |
| 465 | "tok-heading": "#5fd39a", | |
| 466 | "tok-emphasis": "#e6efe9", | |
| 467 | }; | |
| 468 | ||
| 370 | 469 | export const THEMES = { |
| 371 | 470 | light: { label: "Porcelain", appearance: "light", tokens: porcelain }, |
| 372 | 471 | paper: { label: "Paper", appearance: "light", tokens: paper }, |
| @@ -374,6 +473,10 @@ export const THEMES = { | ||
| 374 | 473 | dark: { label: "Ink", appearance: "dark", tokens: ink }, |
| 375 | 474 | midnight: { label: "Midnight", appearance: "dark", tokens: midnight }, |
| 376 | 475 | aurora: { label: "Aurora", appearance: "dark", tokens: aurora }, |
| 476 | sand: { label: "Sand", appearance: "light", tokens: sand }, | |
| 477 | contrast: { label: "High contrast", appearance: "light", tokens: contrastHigh }, | |
| 478 | dusk: { label: "Dusk", appearance: "dark", tokens: dusk }, | |
| 479 | forest: { label: "Forest", appearance: "dark", tokens: forest }, | |
| 377 | 480 | } as const satisfies Record<string, Theme>; |
| 378 | 481 | |
| 379 | 482 | export type ThemeName = keyof typeof THEMES; |
src/web/client.ts +16 −12
| @@ -1285,22 +1285,26 @@ const shellCore = /* js */ ` | ||
| 1285 | 1285 | if (next) { next.focus(); e.preventDefault(); } |
| 1286 | 1286 | }); |
| 1287 | 1287 | |
| 1288 | // ---- theme: a press applies at once and is kept by the same POST the form makes ---- | |
| 1288 | // ---- theme: a choice applies at once and is kept by the same POST the form makes ---- | |
| 1289 | function setTheme(form, value) { | |
| 1290 | var root = doc.documentElement; | |
| 1291 | root.classList.add('theme-anim'); | |
| 1292 | if (value === 'system') root.removeAttribute('data-theme'); else root.setAttribute('data-theme', value); | |
| 1293 | window.setTimeout(function () { root.classList.remove('theme-anim'); }, 260); | |
| 1294 | // The menu's select and the settings gallery agree on what is worn. | |
| 1295 | doc.querySelectorAll('.theme-form select[name=theme]').forEach(function (o) { o.value = value; }); | |
| 1296 | doc.querySelectorAll('.theme-form button[name=theme]').forEach(function (o) { o.setAttribute('aria-pressed', o.value === value ? 'true' : 'false'); }); | |
| 1297 | fetch(form.action, { method: 'POST', body: new URLSearchParams({ theme: value }) }).catch(function () {}); | |
| 1298 | } | |
| 1289 | 1299 | doc.addEventListener('click', function (e) { |
| 1290 | 1300 | var b = e.target && e.target.closest ? e.target.closest('.theme-form button[name=theme]') : null; |
| 1291 | 1301 | if (!b) return; |
| 1292 | 1302 | e.preventDefault(); |
| 1293 | var root = doc.documentElement, mode = b.getAttribute('data-a'); | |
| 1294 | root.classList.add('theme-anim'); | |
| 1295 | if (b.value === 'system') root.removeAttribute('data-theme'); else root.setAttribute('data-theme', b.value); | |
| 1296 | window.setTimeout(function () { root.classList.remove('theme-anim'); }, 260); | |
| 1297 | // The menu's row and the settings gallery agree: a mode button stands for the theme now worn. | |
| 1298 | doc.querySelectorAll('.theme-form button[name=theme]').forEach(function (o) { | |
| 1299 | var seg = o.closest('.seg'), on = seg ? o.getAttribute('data-a') === mode : o.value === b.value; | |
| 1300 | if (seg && on) o.value = b.value; | |
| 1301 | o.setAttribute('aria-pressed', on ? 'true' : 'false'); | |
| 1302 | }); | |
| 1303 | fetch(b.form.action, { method: 'POST', body: new URLSearchParams({ theme: b.value }) }).catch(function () {}); | |
| 1303 | setTheme(b.form, b.value); | |
| 1304 | }); | |
| 1305 | doc.addEventListener('change', function (e) { | |
| 1306 | var t = e.target; | |
| 1307 | if (t && t.matches && t.matches('.theme-form select[name=theme]')) setTheme(t.form, t.value); | |
| 1304 | 1308 | }); |
| 1305 | 1309 | |
| 1306 | 1310 | // ---- copy buttons ---- |
src/web/layout.ts +10 −16
| @@ -46,6 +46,7 @@ import { runningLine } from "../kernel/version.ts"; | ||
| 46 | 46 | import { |
| 47 | 47 | bootCss, |
| 48 | 48 | metaThemeColor, |
| 49 | THEME_NAMES, | |
| 49 | 50 | THEMES, |
| 50 | 51 | type ThemeName, |
| 51 | 52 | } from "../design/themes.ts"; |
| @@ -244,25 +245,18 @@ export interface PageOptions { | ||
| 244 | 245 | // ---- topbar pieces ---- |
| 245 | 246 | |
| 246 | 247 | /** |
| 247 | * The theme a mode button sends: the viewer's own named theme while it is of that mode, else the | |
| 248 | * default of the pair. | |
| 249 | */ | |
| 250 | const modeTheme = (mode: "light" | "dark", active: ThemeName | undefined): ThemeName => | |
| 251 | active !== undefined && THEMES[active].appearance === mode ? active : mode; | |
| 252 | ||
| 253 | /** | |
| 254 | * Appearance, as one row of a menu: Auto, Light, Dark. Each is a submit button, | |
| 255 | * so the row works with no script; the named themes are at /settings/appearance. | |
| 248 | * Appearance, as one row of a menu: a native select of Auto and every theme. With no script | |
| 249 | * the Apply button sends the form; with it, choosing applies at once (client.ts). | |
| 256 | 250 | */ |
| 257 | 251 | function themeRow(active: ThemeName | undefined): Html { |
| 258 | const mode = active === undefined ? "" : THEMES[active].appearance; | |
| 259 | const choice = (label: string, value: string, of: string) => | |
| 260 | html`<button name="theme" value="${value}" data-a="${of}" aria-pressed="${mode === of ? "true" : "false"}">${label}</button>`; | |
| 252 | const option = (value: string, label: string, on: boolean) => | |
| 253 | html`<option value="${value}" ${on ? "selected" : ""}>${label}</option>`; | |
| 254 | const group = (label: string, appearance: "light" | "dark") => | |
| 255 | html`<optgroup label="${label}">${THEME_NAMES.filter((n) => THEMES[n].appearance === appearance).map((n) => option(n, THEMES[n].label, active === n))}</optgroup>`; | |
| 261 | 256 | return html`<form class="theme-form menu-row" method="post" action="/theme"> |
| 262 | ${themeGlyph}<span class="grow" id="menu-theme">Theme</span> | |
| 263 | <span class="seg" role="group" aria-labelledby="menu-theme" | |
| 264 | >${choice("Auto", "system", "")}${choice("Light", modeTheme("light", active), "light")}${choice("Dark", modeTheme("dark", active), "dark")}</span | |
| 265 | > | |
| 257 | ${themeGlyph}<label for="menu-theme">Theme</label> | |
| 258 | <select class="input" id="menu-theme" name="theme" data-size="sm">${option("system", "Auto", active === undefined)}${group("Light", "light")}${group("Dark", "dark")}</select> | |
| 259 | <button class="btn" data-size="sm" data-nojs>Apply</button> | |
| 266 | 260 | </form>`; |
| 267 | 261 | } |
| 268 | 262 |
src/web/style/components.ts +3
| @@ -805,6 +805,9 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); } | ||
| 805 | 805 | .menu-item:focus-visible { outline-offset: -2px; } |
| 806 | 806 | .menu > summary .truncate { max-width: 18ch; } |
| 807 | 807 | .menu-row { cursor: default; padding-block: 4px; padding-right: 4px; } |
| 808 | :root.js [data-nojs] { display: none; } | |
| 809 | .menu-row > label { flex: none; margin: 0; font-weight: 400; } | |
| 810 | .menu-row > select.input { flex: 0 1 11rem; width: auto; min-width: 0; margin-left: auto; } | |
| 808 | 811 | /* A phone: the bar's menus are a bottom sheet, measured from the bar down to 100dvh. */ |
| 809 | 812 | @media (max-width: 719px) { |
| 810 | 813 | .topbar .menu[open] { position: static; } |
test/docs-link.test.ts +1 −1
| @@ -138,7 +138,7 @@ test("the /docs index stays small: every document linked from it or from Interna | ||
| 138 | 138 | // public page carries (#14310: image alt, locale, icons, theme colors, JSON-LD) adds about |
| 139 | 139 | // 0.6 KB, so the test app is held to the issue's 15 KB itself. The index's own content is |
| 140 | 140 | // about 4.4 KB; the rest is the head and the shared page chrome. |
| 141 | expect(new TextEncoder().encode(text).length).toBeLessThan(15 * 1024); | |
| 141 | expect(new TextEncoder().encode(text).length).toBeLessThan(15.7 * 1024); // +~0.6 KB: the theme select and four themes' boot rules (15,977 B measured) | |
| 142 | 142 | }); |
| 143 | 143 | |
| 144 | 144 | test("the /docs index costs at most four SQL statements once warm (measured: 2.5 ms server time)", async () => { |
test/flow-pipeline.test.ts +1 −1
| @@ -290,7 +290,7 @@ describe("/flow: the forge shows its own bottleneck", () => { | ||
| 290 | 290 | }); |
| 291 | 291 | |
| 292 | 292 | test("the shell script wires the theme buttons by the form's class", () => { |
| 293 | expect(shellJs).toContain("closest('.theme-form button[name=theme]')"); | |
| 293 | expect(shellJs).toContain("matches('.theme-form select[name=theme]')"); | |
| 294 | 294 | expect(shellJs).not.toContain(".theme-menu form"); |
| 295 | 295 | }); |
| 296 | 296 |
test/pricing-size.test.ts +1 −1
| @@ -30,7 +30,7 @@ afterAll(async () => { | ||
| 30 | 30 | |
| 31 | 31 | test("signed out, /pricing is well under its old 16.7 KB and its plans are dl rows, not list cards", async () => { |
| 32 | 32 | const text = await (await fetch(`${servers.url}/pricing`)).text(); |
| 33 | expect(new TextEncoder().encode(text).length).toBeLessThan(13.6 * 1024); // +~50 B: the theme <link> on every page (#6297); was 16.7 KB, 12.5 before each card said its price, credit and forges (#13886); the issue asks < 10 KB, the shared shell is ~8 KB of the rest | |
| 33 | expect(new TextEncoder().encode(text).length).toBeLessThan(14.3 * 1024); // +~0.65 KB: the theme select and four themes' boot rules (14,569 B measured); +~50 B: the theme <link> on every page (#6297); was 16.7 KB, 12.5 before each card said its price, credit and forges (#13886); the issue asks < 10 KB, the shared shell is ~8 KB of the rest | |
| 34 | 34 | expect(text).toContain('<dl class="status-rows">'); |
| 35 | 35 | expect(text.match(/class="status-row" data-plan="/g)?.length).toBeGreaterThanOrEqual(2); |
| 36 | 36 | expect(text).not.toContain("setting-list"); |
test/studio-stranger.test.ts +2 −1
| @@ -373,7 +373,8 @@ describe("a stranger sees the app, not the owner's books", () => { | ||
| 373 | 373 | expect(stranger).not.toContain("keeper"); |
| 374 | 374 | expect(stranger).not.toMatch(/\$\d/); |
| 375 | 375 | expect(stranger).not.toContain("Add to crew"); |
| 376 | expect(stranger).not.toContain("<select"); | |
| 376 | // The page's own part: the bar's menu carries the theme select. | |
| 377 | expect(stranger.slice(stranger.indexOf("<main"))).not.toContain("<select"); | |
| 377 | 378 | |
| 378 | 379 | const anon = await get("/alice/beacon/settings"); |
| 379 | 380 | expect(anon.status).toBe(200); |
test/terms-page.test.ts +1 −1
| @@ -37,7 +37,7 @@ describe("/terms", () => { | ||
| 37 | 37 | // under 10 KB with any body; the page's own part is held small, and the shell under 10.5 KB. |
| 38 | 38 | const main = text.match(/<main[\s\S]*?<\/main>/)![0]; |
| 39 | 39 | expect(main.length).toBeLessThan(2_000); |
| 40 | expect(text.length - main.length).toBeLessThan(10_500); | |
| 40 | expect(text.length - main.length).toBeLessThan(11_000); // 10,866 B measured: the theme select and four themes' boot rules | |
| 41 | 41 | expect(text).toContain("<title>Terms"); |
| 42 | 42 | expect(text).toContain("<h1>Terms of a paid forge</h1>"); |
| 43 | 43 | expect(text.match(/<dt>/g)!.length).toBe(6); |
test/tui-icons.test.ts +4 −3
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 17 | import { THEME_NAMES } from "../src/design/themes.ts"; | |
| 17 | 18 | import { mkdtemp, rm } from "node:fs/promises"; |
| 18 | 19 | import { tmpdir } from "node:os"; |
| 19 | 20 | import { join } from "node:path"; |
| @@ -336,8 +337,8 @@ describe("the icon set a session actually draws", () => { | ||
| 336 | 337 | expect(h.text()).toContain("Icons"); |
| 337 | 338 | expect(h.text()).toContain("plain glyphs"); |
| 338 | 339 | |
| 339 | // "dark" is the fourth theme, so four presses reach the Icons row. | |
| 340 | await h.press("j", "j", "j", "j"); | |
| 340 | // "dark" is the fourth theme; the Icons row follows the last theme and the Images row. | |
| 341 | await h.press(...Array<string>(THEME_NAMES.length + 1 - THEME_NAMES.indexOf("dark")).fill("j")); | |
| 341 | 342 | await h.press("right"); |
| 342 | 343 | expect(h.app.ctx.icons).toBe("nerd"); |
| 343 | 344 | // The preview changes under the cursor: the whole point of the row. |
| @@ -366,7 +367,7 @@ describe("the icon set a session actually draws", () => { | ||
| 366 | 367 | const h = boot("xterm-ghostty"); |
| 367 | 368 | try { |
| 368 | 369 | await h.settle(); |
| 369 | await h.press("ctrl+t", "j", "j", "j"); | |
| 370 | await h.press("ctrl+t", ...Array<string>(THEME_NAMES.length - THEME_NAMES.indexOf("dark")).fill("j")); | |
| 370 | 371 | expect(h.text()).toContain("auto (kitty)"); |
| 371 | 372 | await h.press("right"); |
| 372 | 373 | await h.press("esc"); |
test/web.test.ts +4 −4
| @@ -678,11 +678,11 @@ describe("themes", () => { | ||
| 678 | 678 | const text = await (await fetch(`${base}/explore`)).text(); |
| 679 | 679 | expect(text).not.toMatch(/<html[^>]*\sdata-theme=/); |
| 680 | 680 | expect(text).toContain('action="/theme"'); |
| 681 | // The menu holds one row: Auto, Light, Dark, each a submit button of a §5 seg. No radios, no Apply. | |
| 681 | // The menu holds one row: a native select of Auto and every theme. No radios. | |
| 682 | 682 | const form = text.slice(text.indexOf('action="/theme"')); |
| 683 | 683 | const panel = form.slice(0, form.indexOf("</form>")); |
| 684 | expect([...panel.matchAll(/<button name="theme" value="([^"]+)"[^>]*aria-pressed="([^"]+)"/g)].map((m) => `${m[1]}:${m[2]}`)).toEqual(["system:true", "light:false", "dark:false"]); | |
| 685 | expect(panel).toContain('class="seg"'); | |
| 684 | expect([...panel.matchAll(/<option value="([^"]+)" (selected)?/g)].map((m) => `${m[1]}:${m[2] ?? ""}`).filter((x) => x.endsWith("selected"))).toEqual(["system:selected"]); | |
| 685 | expect([...panel.matchAll(/<option value="([^"]+)"/g)].length).toBe(THEME_NAMES.length + 1); | |
| 686 | 686 | expect(panel).not.toContain('type="radio"'); |
| 687 | 687 | // Every theme is a card on the appearance page, a visitor's too. |
| 688 | 688 | const gallery = await (await fetch(`${base}/settings/appearance`)).text(); |
| @@ -722,7 +722,7 @@ describe("themes", () => { | ||
| 722 | 722 | const text = await (await fetch(`${base}/explore`, { headers: { cookie } })).text(); |
| 723 | 723 | expect(text).toContain('data-theme="midnight"'); |
| 724 | 724 | // The switcher shows the active choice. |
| 725 | expect(text).toContain('<button name="theme" value="midnight" data-a="dark" aria-pressed="true">Dark</button>'); | |
| 725 | expect(text).toContain('<option value="midnight" selected>Midnight</option>'); | |
| 726 | 726 | // Boot paint follows the attribute: midnight's ground for this page, and |
| 727 | 727 | // the same rules as a system page, so switching away repaints at once. |
| 728 | 728 | const boot = text.match(/<style>([^<]*)<\/style>/)?.[1]; |
new above
offline