@seanyeh77/ui 0.53.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/css/Card.css CHANGED
@@ -47,7 +47,7 @@
47
47
  flex: 1 1 8em;
48
48
  min-width: min(8em, 100%);
49
49
  margin: 0;
50
- font-size: var(--text-title);
50
+ font-size: var(--text-lead);
51
51
  font-weight: 700;
52
52
  white-space: nowrap;
53
53
  overflow: hidden;
@@ -28,11 +28,11 @@
28
28
  --dt-zebra: var(--surface-sub);
29
29
  --dt-hover: color-mix(in srgb, var(--surface), var(--ink) 6%);
30
30
  }
31
- /* Dark: surface-sub rows stood out too much; half-way between surface and surface-sub. A 5 % wash keeps
32
- accent-text, danger-text and info-text above 4.5:1 (6 % gave 4.4:1). */
31
+ /* Dark: rows go darker, toward the page ground, not lighter. Text colors are made to read on both the surface and the
32
+ page ground, so every row between them keeps 4.5:1 for ink-muted and every accent and *-text color. */
33
33
  [data-theme='dark'] .ui-dt {
34
- --dt-zebra: color-mix(in srgb, var(--surface), var(--surface-sub) 50%);
35
- --dt-hover: color-mix(in srgb, var(--surface), var(--ink) 5%);
34
+ --dt-zebra: color-mix(in srgb, var(--surface), var(--bg) 30%);
35
+ --dt-hover: color-mix(in srgb, var(--surface), var(--bg) 60%);
36
36
  }
37
37
  .ui-dt-caption {
38
38
  /* The same size as a Card title: a table's heading is a block heading whether or not it sits in a card. */
@@ -362,7 +362,7 @@
362
362
  display: grid;
363
363
  align-items: center;
364
364
  min-height: 48px;
365
- border-bottom: 1px solid var(--line);
365
+ border-bottom: 1px solid var(--line-soft);
366
366
  background: var(--dt-row-bg);
367
367
  }
368
368
  .ui-dt-body .ui-dt-row.is-even {
@@ -370,6 +370,8 @@
370
370
  }
371
371
  .ui-dt-body {
372
372
  position: relative;
373
+ /* Table text 14 px; headings, toolbar and secondary lines keep their own sizes. */
374
+ font-size: var(--text-compact);
373
375
  }
374
376
  .ui-dt-body .ui-dt-row {
375
377
  transition: background-color 0.12s ease;
@@ -869,7 +871,7 @@
869
871
  }
870
872
  .ui-dt-detail {
871
873
  background: var(--surface);
872
- border-bottom: 1px solid var(--line);
874
+ border-bottom: 1px solid var(--line-soft);
873
875
  }
874
876
  .ui-dt-detail.is-even {
875
877
  background: var(--dt-zebra);
@@ -136,8 +136,8 @@ button.ui-md-link.is-row {
136
136
  .ui-md-table th,
137
137
  .ui-md-table td {
138
138
  padding: 10px 12px;
139
- border-right: 1px solid var(--line);
140
- border-bottom: 1px solid var(--line);
139
+ border-right: 1px solid var(--line-soft);
140
+ border-bottom: 1px solid var(--line-soft);
141
141
  vertical-align: top;
142
142
  }
143
143
  .ui-md-table th:last-child,
@@ -263,7 +263,7 @@ button.ui-md-link.is-row {
263
263
  }
264
264
  .ui-md-table tr {
265
265
  padding: var(--space-2) var(--space-3);
266
- border-bottom: 1px solid var(--line);
266
+ border-bottom: 1px solid var(--line-soft);
267
267
  }
268
268
  .ui-md-table tbody tr:last-child {
269
269
  border-bottom: 0;
@@ -21,7 +21,7 @@
21
21
  .ui-pagehead-title {
22
22
  min-width: 0;
23
23
  margin: 0;
24
- font-size: var(--text-h4);
24
+ font-size: var(--text-h3);
25
25
  line-height: 40px;
26
26
  font-weight: 700;
27
27
  white-space: nowrap;
@@ -65,7 +65,7 @@
65
65
  .ui-sec-title {
66
66
  flex: none;
67
67
  max-width: 100%;
68
- font-size: var(--text-h4);
68
+ font-size: var(--text-lead);
69
69
  line-height: 28px;
70
70
  font-weight: 700;
71
71
  white-space: nowrap;
@@ -19,8 +19,8 @@
19
19
  }
20
20
  .ui-topbar-title {
21
21
  margin: 0;
22
- font-size: var(--text-h4);
23
- line-height: 28px;
22
+ font-size: var(--text-h3);
23
+ line-height: 32px;
24
24
  font-weight: 700;
25
25
  white-space: nowrap;
26
26
  overflow: hidden;
@@ -105,4 +105,11 @@
105
105
  flex: 0 0 auto;
106
106
  margin-left: calc(-1 * var(--space-2));
107
107
  }
108
+ /* Phones: the page title stays 20 px beside the project switcher and search (24 px leaves the title no room). */
109
+ @media (max-width: 599px) {
110
+ .ui-topbar-title {
111
+ font-size: var(--text-h4);
112
+ line-height: 28px;
113
+ }
114
+ }
108
115
  }
@@ -6,19 +6,19 @@ const DEFAULT_ACCENT = "#2457d6";
6
6
  const GROUNDS = {
7
7
  bg: {
8
8
  light: "#fcfbfb",
9
- dark: "#2f2a25"
9
+ dark: "#292725"
10
10
  },
11
11
  surface: {
12
12
  light: "#ffffff",
13
- dark: "#393530"
13
+ dark: "#393632"
14
14
  },
15
15
  "surface-sub": {
16
16
  light: "#f6f5f4",
17
- dark: "#443f3b"
17
+ dark: "#413d38"
18
18
  },
19
19
  "surface-chrome": {
20
20
  light: "#ffffff",
21
- dark: "#3d3834"
21
+ dark: "#34312e"
22
22
  },
23
23
  ink: {
24
24
  light: "#171512",
@@ -1 +1 @@
1
- {"version":3,"file":"themeDefaults.js","names":[],"sources":["../../src/generated/themeDefaults.ts"],"sourcesContent":["/* Generated from packages/tokens/tokens.json by scripts/theme-defaults.ts. Do not edit by hand. */\n\n/** The default accent (the light theme's accent token). */\nexport const DEFAULT_ACCENT = '#2457d6';\n\n/** Light and dark values of the grounds setAccent checks contrast on, used when tokens.css is not loaded. */\nexport const GROUNDS = {\n bg: {\n light: '#fcfbfb',\n dark: '#2f2a25',\n },\n surface: {\n light: '#ffffff',\n dark: '#393530',\n },\n 'surface-sub': {\n light: '#f6f5f4',\n dark: '#443f3b',\n },\n 'surface-chrome': {\n light: '#ffffff',\n dark: '#3d3834',\n },\n ink: {\n light: '#171512',\n dark: '#f6f5f4',\n },\n} as const;\n\n/** The presets of tokens.json: their color scheme and accent. */\nexport const PRESETS = {\n teaching: {\n scheme: 'light',\n accent: '#027874',\n },\n} as const;\n\nexport type ThemePreset = keyof typeof PRESETS;\n"],"mappings":";;;AAGA,MAAa,iBAAiB;;AAG9B,MAAa,UAAU;CACrB,IAAI;EACF,OAAO;EACP,MAAM;CACR;CACA,SAAS;EACP,OAAO;EACP,MAAM;CACR;CACA,eAAe;EACb,OAAO;EACP,MAAM;CACR;CACA,kBAAkB;EAChB,OAAO;EACP,MAAM;CACR;CACA,KAAK;EACH,OAAO;EACP,MAAM;CACR;AACF;;AAGA,MAAa,UAAU,EACrB,UAAU;CACR,QAAQ;CACR,QAAQ;AACV,EACF"}
1
+ {"version":3,"file":"themeDefaults.js","names":[],"sources":["../../src/generated/themeDefaults.ts"],"sourcesContent":["/* Generated from packages/tokens/tokens.json by scripts/theme-defaults.ts. Do not edit by hand. */\n\n/** The default accent (the light theme's accent token). */\nexport const DEFAULT_ACCENT = '#2457d6';\n\n/** Light and dark values of the grounds setAccent checks contrast on, used when tokens.css is not loaded. */\nexport const GROUNDS = {\n bg: {\n light: '#fcfbfb',\n dark: '#292725',\n },\n surface: {\n light: '#ffffff',\n dark: '#393632',\n },\n 'surface-sub': {\n light: '#f6f5f4',\n dark: '#413d38',\n },\n 'surface-chrome': {\n light: '#ffffff',\n dark: '#34312e',\n },\n ink: {\n light: '#171512',\n dark: '#f6f5f4',\n },\n} as const;\n\n/** The presets of tokens.json: their color scheme and accent. */\nexport const PRESETS = {\n teaching: {\n scheme: 'light',\n accent: '#027874',\n },\n} as const;\n\nexport type ThemePreset = keyof typeof PRESETS;\n"],"mappings":";;;AAGA,MAAa,iBAAiB;;AAG9B,MAAa,UAAU;CACrB,IAAI;EACF,OAAO;EACP,MAAM;CACR;CACA,SAAS;EACP,OAAO;EACP,MAAM;CACR;CACA,eAAe;EACb,OAAO;EACP,MAAM;CACR;CACA,kBAAkB;EAChB,OAAO;EACP,MAAM;CACR;CACA,KAAK;EACH,OAAO;EACP,MAAM;CACR;AACF;;AAGA,MAAa,UAAU,EACrB,UAAU;CACR,QAAQ;CACR,QAAQ;AACV,EACF"}
package/dist/styles.css CHANGED
@@ -2510,8 +2510,8 @@ div.ui-toast[role='status'] {
2510
2510
  }
2511
2511
  .ui-topbar-title {
2512
2512
  margin: 0;
2513
- font-size: var(--text-h4);
2514
- line-height: 28px;
2513
+ font-size: var(--text-h3);
2514
+ line-height: 32px;
2515
2515
  font-weight: 700;
2516
2516
  white-space: nowrap;
2517
2517
  overflow: hidden;
@@ -2596,6 +2596,13 @@ div.ui-toast[role='status'] {
2596
2596
  flex: 0 0 auto;
2597
2597
  margin-left: calc(-1 * var(--space-2));
2598
2598
  }
2599
+ /* Phones: the page title stays 20 px beside the project switcher and search (24 px leaves the title no room). */
2600
+ @media (max-width: 599px) {
2601
+ .ui-topbar-title {
2602
+ font-size: var(--text-h4);
2603
+ line-height: 28px;
2604
+ }
2605
+ }
2599
2606
  .ui-sidenav {
2600
2607
  position: relative;
2601
2608
  box-sizing: border-box;
@@ -2973,7 +2980,7 @@ div.ui-toast[role='status'] {
2973
2980
  .ui-pagehead-title {
2974
2981
  min-width: 0;
2975
2982
  margin: 0;
2976
- font-size: var(--text-h4);
2983
+ font-size: var(--text-h3);
2977
2984
  line-height: 40px;
2978
2985
  font-weight: 700;
2979
2986
  white-space: nowrap;
@@ -3629,11 +3636,11 @@ div.ui-toast[role='status'] {
3629
3636
  --dt-zebra: var(--surface-sub);
3630
3637
  --dt-hover: color-mix(in srgb, var(--surface), var(--ink) 6%);
3631
3638
  }
3632
- /* Dark: surface-sub rows stood out too much; half-way between surface and surface-sub. A 5 % wash keeps
3633
- accent-text, danger-text and info-text above 4.5:1 (6 % gave 4.4:1). */
3639
+ /* Dark: rows go darker, toward the page ground, not lighter. Text colors are made to read on both the surface and the
3640
+ page ground, so every row between them keeps 4.5:1 for ink-muted and every accent and *-text color. */
3634
3641
  [data-theme='dark'] .ui-dt {
3635
- --dt-zebra: color-mix(in srgb, var(--surface), var(--surface-sub) 50%);
3636
- --dt-hover: color-mix(in srgb, var(--surface), var(--ink) 5%);
3642
+ --dt-zebra: color-mix(in srgb, var(--surface), var(--bg) 30%);
3643
+ --dt-hover: color-mix(in srgb, var(--surface), var(--bg) 60%);
3637
3644
  }
3638
3645
  .ui-dt-caption {
3639
3646
  /* The same size as a Card title: a table's heading is a block heading whether or not it sits in a card. */
@@ -3963,7 +3970,7 @@ div.ui-toast[role='status'] {
3963
3970
  display: grid;
3964
3971
  align-items: center;
3965
3972
  min-height: 48px;
3966
- border-bottom: 1px solid var(--line);
3973
+ border-bottom: 1px solid var(--line-soft);
3967
3974
  background: var(--dt-row-bg);
3968
3975
  }
3969
3976
  .ui-dt-body .ui-dt-row.is-even {
@@ -3971,6 +3978,8 @@ div.ui-toast[role='status'] {
3971
3978
  }
3972
3979
  .ui-dt-body {
3973
3980
  position: relative;
3981
+ /* Table text 14 px; headings, toolbar and secondary lines keep their own sizes. */
3982
+ font-size: var(--text-compact);
3974
3983
  }
3975
3984
  .ui-dt-body .ui-dt-row {
3976
3985
  transition: background-color 0.12s ease;
@@ -4470,7 +4479,7 @@ div.ui-toast[role='status'] {
4470
4479
  }
4471
4480
  .ui-dt-detail {
4472
4481
  background: var(--surface);
4473
- border-bottom: 1px solid var(--line);
4482
+ border-bottom: 1px solid var(--line-soft);
4474
4483
  }
4475
4484
  .ui-dt-detail.is-even {
4476
4485
  background: var(--dt-zebra);
@@ -6362,7 +6371,7 @@ div.ui-toast[role='status'] {
6362
6371
  flex: 1 1 8em;
6363
6372
  min-width: min(8em, 100%);
6364
6373
  margin: 0;
6365
- font-size: var(--text-title);
6374
+ font-size: var(--text-lead);
6366
6375
  font-weight: 700;
6367
6376
  white-space: nowrap;
6368
6377
  overflow: hidden;
@@ -8555,7 +8564,7 @@ div.ui-toast[role='status'] {
8555
8564
  .ui-sec-title {
8556
8565
  flex: none;
8557
8566
  max-width: 100%;
8558
- font-size: var(--text-h4);
8567
+ font-size: var(--text-lead);
8559
8568
  line-height: 28px;
8560
8569
  font-weight: 700;
8561
8570
  white-space: nowrap;
@@ -8730,8 +8739,8 @@ button.ui-md-link.is-row {
8730
8739
  .ui-md-table th,
8731
8740
  .ui-md-table td {
8732
8741
  padding: 10px 12px;
8733
- border-right: 1px solid var(--line);
8734
- border-bottom: 1px solid var(--line);
8742
+ border-right: 1px solid var(--line-soft);
8743
+ border-bottom: 1px solid var(--line-soft);
8735
8744
  vertical-align: top;
8736
8745
  }
8737
8746
  .ui-md-table th:last-child,
@@ -8857,7 +8866,7 @@ button.ui-md-link.is-row {
8857
8866
  }
8858
8867
  .ui-md-table tr {
8859
8868
  padding: var(--space-2) var(--space-3);
8860
- border-bottom: 1px solid var(--line);
8869
+ border-bottom: 1px solid var(--line-soft);
8861
8870
  }
8862
8871
  .ui-md-table tbody tr:last-child {
8863
8872
  border-bottom: 0;
package/dist/theme.js CHANGED
@@ -184,9 +184,9 @@ const ACCENT_VARS = [
184
184
  ];
185
185
  /** Every accent token for one color on one theme's grounds. */
186
186
  function accentVars(hex, dark, surface, bg, sub, chrome) {
187
- const soft = dark ? mixHex(surface, hex, .22) : mixHex("#ffffff", hex, .12);
187
+ const soft = dark ? mixHex(bg, hex, .18) : mixHex("#ffffff", hex, .12);
188
188
  const text = accentText(hex, dark, bg, surface, sub, chrome, soft);
189
- const fill = accentFill(hex, dark, bg, surface, sub, chrome, soft);
189
+ const fill = dark ? text : accentFill(hex, dark, bg, surface, sub, chrome, soft);
190
190
  const away = dark ? "#ffffff" : "#000000";
191
191
  return {
192
192
  "--accent": fill,
package/dist/theme.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","names":[],"sources":["../src/theme.ts"],"sourcesContent":["import { ensureAnnouncer } from './announce';\nimport { DEFAULT_ACCENT, GROUNDS, PRESETS, type ThemePreset } from './generated/themeDefaults';\nimport { installFocusMain } from './internal/focusMain';\nimport { readStored, writeStored } from './internal/stored';\nimport { reduced } from './internal/util';\n\n/* Theme and accent color. 'auto' follows prefers-color-scheme; colors cross-fade for 300 ms on a change.\n The choice is kept in localStorage, so initTheme() on the next visit restores it. A preset (data-theme-preset on\n <html>, or initTheme({ preset })) replaces light and dark: the teaching preset is light only. The accent comes from\n tokens.css until the person picks one (setAccent); only then are inline --accent variables written. */\n\nexport type ThemeSetting = 'auto' | 'light' | 'dark';\nexport type { ThemePreset };\nexport { DEFAULT_ACCENT };\n\nexport const THEME_KEY = 'ui-theme';\nexport const ACCENT_KEY = 'ui-accent';\n/** The picked accent's derived tokens, for themeScript. */\nconst ACCENT_VARS_KEY = 'ui-accent-vars';\nconst PRESET_ATTR = 'data-theme-preset';\n\nconst isSetting = (v: string | null): v is ThemeSetting => v === 'auto' || v === 'light' || v === 'dark';\nconst hasDom = () => typeof window !== 'undefined' && typeof document !== 'undefined';\n\n/** A stored theme setting as text to the setting, 'auto' for anything else. */\nexport const parseTheme = (raw: string): ThemeSetting => (isSetting(raw) ? raw : 'auto');\n\n/** The stored theme setting, 'auto' when there is none (and on the server). */\nexport function storedTheme(): ThemeSetting {\n return hasDom() ? parseTheme(readStored(THEME_KEY) ?? '') : 'auto';\n}\n\n/** The preset on <html data-theme-preset>, or null (the light and dark themes). */\nexport function themePreset(): ThemePreset | null {\n if (typeof document === 'undefined') return null;\n const v = document.documentElement.getAttribute(PRESET_ATTR);\n return v && Object.hasOwn(PRESETS, v) ? (v as ThemePreset) : null;\n}\n\nfunction resolveTheme(t: ThemeSetting): 'light' | 'dark' {\n if (t !== 'auto') return t;\n return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n}\n\nlet fadeTimer: ReturnType<typeof setTimeout> | undefined;\n\n/** Switches the theme on <html data-theme> and remembers it. Under a preset the setting is remembered but the\n * preset stays (the teaching preset is light only). */\nexport function setTheme(t: ThemeSetting): void {\n if (!hasDom()) return;\n const root = document.documentElement;\n if (!reduced()) {\n root.classList.add('ui-theme-fade');\n clearTimeout(fadeTimer);\n fadeTimer = setTimeout(() => root.classList.remove('ui-theme-fade'), 320);\n }\n root.setAttribute('data-theme', themePreset() ?? resolveTheme(t));\n root.setAttribute('data-theme-setting', t);\n writeStored(THEME_KEY, t);\n // The accent's text and soft colors depend on the theme.\n applyAccent();\n}\n\n/** Swatches whose color changed so they read as text on every ground: a stored old value moves to the new one. */\nconst RENAMED_SWATCHES: Record<string, string> = {\n '#8a4fd6': '#864ad1',\n '#c2407a': '#ba3873',\n '#cd3a2f': '#c53228',\n '#b85a0e': '#ab5101',\n '#1a844a': '#077b42',\n '#0e827d': '#027874',\n};\n\n/** A stored accent as text to #rrggbb, an old swatch value moved to its current one; null for anything else. */\nexport function parseAccent(raw: string): string | null {\n const v = raw.trim().toLowerCase();\n if (!/^#[0-9a-f]{6}$/.test(v)) return null;\n return RENAMED_SWATCHES[v] ?? v;\n}\n\n/** The accent the person picked (stored), with an old swatch value moved to its current one (and stored again);\n * null when they picked none, so tokens.css decides. */\nexport function pickedAccent(): string | null {\n if (!hasDom()) return null;\n const raw = readStored(ACCENT_KEY);\n const v = raw ? parseAccent(raw) : null;\n if (v && v !== raw) writeStored(ACCENT_KEY, v);\n return v;\n}\n\n/** The accent in use: the picked one, else the preset's accent, else the default (DEFAULT_ACCENT). */\nexport function storedAccent(): string {\n return pickedAccent() ?? defaultAccent();\n}\n\n/** The accent tokens.css gives when nothing is picked: the preset's, else DEFAULT_ACCENT. */\nexport function defaultAccent(): string {\n const p = themePreset();\n return p ? PRESETS[p].accent : DEFAULT_ACCENT;\n}\n\nconst hexRgb = (x: string): number[] => [1, 3, 5].map((i) => parseInt(x.slice(i, i + 2), 16));\n\n/** A CSS color as #rrggbb: #rgb, #rgba, #rrggbb, #rrggbbaa (alpha dropped), rgb() and rgba() with commas or spaces.\n * null for anything else (a name, a var(), an empty value). Bundlers shorten #ffffff to #fff in tokens.css, so the\n * short form must read the same. */\nexport function toHex(c: string): string | null {\n const v = c.trim().toLowerCase();\n const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]?$/.exec(v);\n if (short) return '#' + short[1] + short[1] + short[2] + short[2] + short[3] + short[3];\n const long = /^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/.exec(v);\n if (long) return '#' + long[1];\n const fn = /^rgba?\\(\\s*([\\d.]+)[\\s,]+([\\d.]+)[\\s,]+([\\d.]+)(?:\\s*[,/]\\s*[\\d.]+%?)?\\s*\\)$/.exec(v);\n if (fn) {\n const n = fn.slice(1, 4).map(Number);\n if (n.every((x) => x >= 0 && x <= 255)) return '#' + n.map((x) => Math.round(x).toString(16).padStart(2, '0')).join('');\n }\n return null;\n}\n\nfunction mixHex(a: string, b: string, t: number): string {\n const p = hexRgb(a);\n const q = hexRgb(b);\n return (\n '#' +\n p\n .map((v, i) =>\n Math.round(v + (q[i] - v) * t)\n .toString(16)\n .padStart(2, '0'),\n )\n .join('')\n );\n}\n\nfunction lum(x: string): number {\n const w = [0.2126, 0.7152, 0.0722];\n return hexRgb(x)\n .map((v) => {\n v /= 255;\n return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n })\n .reduce((s, v, i) => s + v * w[i], 0);\n}\n\nfunction contrast(a: string, b: string): number {\n const x = lum(a);\n const y = lum(b);\n return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);\n}\n\n/** The accent's text color (accent-text, and the focus outline): the accent itself when it reads (4.5:1) on bg,\n * surface and every extra ground passed (setAccent passes surface-sub, surface-chrome and accent-soft); else, in\n * light, the accent mixed with black 4 % at a time, in dark with white 5 % at a time, until it reads on all of them. */\nexport function accentText(hex: string, dark: boolean, bg: string, surface: string, ...grounds: string[]): string {\n const all = [bg, surface, ...grounds].map(toHex);\n // A background that cannot be read: keep the accent itself rather than mixing it toward black or white blindly.\n if (all.some((g) => !g)) return hex;\n const reads = (c: string) => all.every((g) => contrast(c, g as string) >= 4.5);\n const toward = dark ? '#ffffff' : '#000000';\n const step = dark ? 0.05 : 0.04;\n let text = hex;\n for (let k = 1; k * step <= 1 && !reads(text); k++) text = mixHex(hex, toward, k * step);\n return text;\n}\n\nconst INK = GROUNDS.ink.light;\n\n/** The text on an accent fill (on-accent): white or the near-black ink (#171512), whichever contrasts more. */\nexport function onFill(fill: string): '#ffffff' | '#171512' {\n return contrast('#ffffff', fill) >= contrast(INK, fill) ? '#ffffff' : INK;\n}\n\n/** The accent's fill color (accent: buttons, switches, progress, selected marks): the accent itself when it reaches\n * 3:1 on bg, surface and every extra ground passed (setAccent passes surface-sub, surface-chrome and accent-soft) and\n * its on-accent text reaches 4.5:1 on it; else, in light, the accent mixed with black 4 % at a time, in dark with\n * white 5 % at a time, until both hold. The preset swatches pass in light as they are. */\nexport function accentFill(hex: string, dark: boolean, bg: string, surface: string, ...grounds: string[]): string {\n const all = [bg, surface, ...grounds].map(toHex);\n if (all.some((g) => !g)) return hex;\n const ok = (c: string) => all.every((g) => contrast(c, g as string) >= 3) && contrast(onFill(c), c) >= 4.5;\n const toward = dark ? '#ffffff' : '#000000';\n const step = dark ? 0.05 : 0.04;\n let fill = hex;\n for (let k = 1; k * step <= 1 && !ok(fill); k++) fill = mixHex(hex, toward, k * step);\n return fill;\n}\n\n/** The preset swatches of AccentPicker. In light (and the teaching preset) each one reads as text by itself (4.5:1 on\n * bg, surface, surface-sub, surface-chrome and its own accent-soft), so accentText returns it unchanged; white text\n * reads on it (4.5:1). In dark, accentText lightens it. Checked in tokens-contrast.test.tsx. */\nexport const ACCENT_SWATCHES: readonly (readonly [name: string, hex: string])[] = [\n ['藍', '#2457d6'],\n ['靛', '#5b4fd6'],\n ['紫', '#864ad1'],\n ['桃紅', '#ba3873'],\n ['紅', '#c53228'],\n ['橘', '#ab5101'],\n ['綠', '#077b42'],\n ['青', '#027874'],\n];\n\nconst ACCENT_VARS = ['--accent', '--accent-hover', '--accent-press', '--accent-soft', '--accent-text', '--on-accent', '--focus', '--focus-ring'];\n\n/** Every accent token for one color on one theme's grounds. */\nfunction accentVars(hex: string, dark: boolean, surface: string, bg: string, sub: string, chrome: string): Record<string, string> {\n const soft = dark ? mixHex(surface, hex, 0.22) : mixHex('#ffffff', hex, 0.12);\n // Text in the accent also sits on zebra rows, code blocks, the top bar and its own soft fill (a selected row).\n const text = accentText(hex, dark, bg, surface, sub, chrome, soft);\n // The fill reaches 3:1 on the same grounds (a checked box in a selected row); hover and press go away from the page:\n // darker in light, lighter in dark, so they keep 3:1 and their text.\n const fill = accentFill(hex, dark, bg, surface, sub, chrome, soft);\n const away = dark ? '#ffffff' : '#000000';\n return {\n '--accent': fill,\n '--accent-hover': mixHex(fill, away, 0.12),\n '--accent-press': mixHex(fill, away, 0.22),\n '--accent-soft': soft,\n '--accent-text': text,\n '--on-accent': onFill(fill),\n // One focus style everywhere: a 2 px outline in the accent's text color, 3:1 or more on every ground.\n '--focus': text,\n // Old name of --focus, kept for pages written before it.\n '--focus-ring': text,\n };\n}\n\n/** Derives every accent token from one color (自訂強調色的換算 in docs/theme.md) and writes them on <html>.\n * Returns false for anything but #rrggbb. quiet: apply without storing. */\nexport function setAccent(hex: string, quiet = false): boolean {\n if (!/^#[0-9a-fA-F]{6}$/.test(hex)) return false;\n if (!hasDom()) return true;\n hex = hex.toLowerCase();\n const root = document.documentElement;\n const dark = root.getAttribute('data-theme') === 'dark';\n const mode = dark ? 'dark' : 'light';\n const cs = getComputedStyle(root);\n // Read the theme's colors as #rrggbb (bundlers may have shortened #ffffff to #fff); the theme's defaults when unset.\n const surface = toHex(cs.getPropertyValue('--surface')) ?? GROUNDS.surface[mode];\n const bg = toHex(cs.getPropertyValue('--bg')) ?? GROUNDS.bg[mode];\n const sub = toHex(cs.getPropertyValue('--surface-sub')) ?? GROUNDS['surface-sub'][mode];\n const chrome = toHex(cs.getPropertyValue('--surface-chrome')) ?? GROUNDS['surface-chrome'][mode];\n const vars = accentVars(hex, dark, surface, bg, sub, chrome);\n for (const [k, v] of Object.entries(vars)) root.style.setProperty(k, v);\n if (!quiet) writeStored(ACCENT_KEY, hex);\n // The picked accent's tokens for themeScript, which applies them before the first paint: this theme as drawn, the\n // other from the theme defaults (a preset is light only).\n if (readStored(ACCENT_KEY) === hex) {\n const other = !dark;\n const o = other ? 'dark' : 'light';\n const cache: Record<string, unknown> = { hex, [mode]: vars };\n if (!themePreset()) cache[o] = accentVars(hex, other, GROUNDS.surface[o], GROUNDS.bg[o], GROUNDS['surface-sub'][o], GROUNDS['surface-chrome'][o]);\n writeStored(ACCENT_VARS_KEY, JSON.stringify(cache));\n }\n return true;\n}\n\n/** Forgets the picked accent and removes the inline accent variables, so tokens.css (the theme or preset) decides. */\nexport function resetAccent(): void {\n if (!hasDom()) return;\n for (const k of ACCENT_VARS) document.documentElement.style.removeProperty(k);\n writeStored(ACCENT_KEY, null);\n writeStored(ACCENT_VARS_KEY, null);\n}\n\n/** Applies the picked accent for the current theme, or removes the inline variables when none is picked. */\nfunction applyAccent(): void {\n const picked = pickedAccent();\n if (picked) setAccent(picked, true);\n else for (const k of ACCENT_VARS) document.documentElement.style.removeProperty(k);\n}\n\nlet following = false;\n\n/** Applies the stored theme and accent; call once when the page starts. preset: a preset of tokens.json (such as\n * 'teaching') that replaces light and dark, kept on <html data-theme-preset>; null removes it; without the option a\n * data-theme-preset already on <html> is kept. Pages do not set data-theme themselves. */\nexport function initTheme(options: { preset?: ThemePreset | null } = {}): void {\n if (!hasDom()) return;\n const root = document.documentElement;\n if (options.preset === null) root.removeAttribute(PRESET_ATTR);\n else if (options.preset) root.setAttribute(PRESET_ATTR, options.preset);\n setTheme(storedTheme());\n ensureAnnouncer();\n installFocusMain();\n if (following || typeof window.matchMedia !== 'function') return;\n following = true;\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {\n if (storedTheme() === 'auto') setTheme('auto');\n });\n}\n\n/** The text color for something drawn on a fill (a heat-scale zone, a status band): the near-black ink of the light\n * theme (#171512) or white, whichever contrasts more with the fill. `fill` is a color (#hex, rgb()) or a token name\n * such as 'heat-6', read from el (default: the root) so it follows the theme. Every step of heat-*, diverge-* and\n * chart-* reaches 4.5:1 with its pick. Unreadable colors give the near-black ink. */\nexport function textOn(fill: string, el?: Element): '#171512' | '#ffffff' {\n let c = fill.trim();\n if (/^[a-z][a-z0-9-]*$/.test(c) && typeof document !== 'undefined') c = getComputedStyle(el ?? document.documentElement).getPropertyValue('--' + c);\n const hex = toHex(c);\n if (!hex) return '#171512';\n return contrast(hex, '#171512') >= contrast(hex, '#ffffff') ? '#171512' : '#ffffff';\n}\n\n/** The heat-scale token for a value: min (or below) is heat-1, max (or above) is heat-7, evenly in between. */\nexport function heatToken(value: number, min: number, max: number): `heat-${1 | 2 | 3 | 4 | 5 | 6 | 7}` {\n const t = max > min ? (value - min) / (max - min) : 0;\n const step = Math.min(7, Math.max(1, Math.round(t * 6) + 1)) as 1 | 2 | 3 | 4 | 5 | 6 | 7;\n return `heat-${step}`;\n}\n\n/** The diverging-scale token for a difference: within ±zero it is diverge-zero; from ±strong on, the -strong step. */\nexport function divergeToken(\n diff: number,\n limits: { zero: number; strong: number },\n): 'diverge-neg-strong' | 'diverge-neg' | 'diverge-zero' | 'diverge-pos' | 'diverge-pos-strong' {\n const a = Math.abs(diff);\n if (a <= limits.zero) return 'diverge-zero';\n const strong = a >= limits.strong;\n return diff < 0 ? (strong ? 'diverge-neg-strong' : 'diverge-neg') : strong ? 'diverge-pos-strong' : 'diverge-pos';\n}\n\n/**\n * A small script for an inline <script> in <head> of a server-rendered page: applies the stored theme (data-theme,\n * data-theme-setting) and the picked accent before the first paint, so the page does not flash the light theme or the\n * default accent until initTheme runs. A preset goes on <html data-theme-preset> in the server's markup; the script\n * keeps it. Still call initTheme() at startup.\n */\nexport const themeScript = `(function(){try{var d=document.documentElement,s=localStorage,t=s.getItem('${THEME_KEY}');if(t!=='light'&&t!=='dark')t='auto';var p=d.getAttribute('${PRESET_ATTR}');var m=t!=='auto'?t:window.matchMedia&&matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';d.setAttribute('data-theme',p||m);d.setAttribute('data-theme-setting',t);var a=s.getItem('${ACCENT_KEY}'),c=JSON.parse(s.getItem('${ACCENT_VARS_KEY}')||'null'),v=a&&c&&c.hex===a&&c[p?'light':m];if(v)for(var k in v)d.style.setProperty(k,v[k])}catch(e){}})();`;\n"],"mappings":";;;;;;;AAeA,MAAa,YAAY;AACzB,MAAa,aAAa;;AAE1B,MAAM,k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,MACA,QAC8F;CAC9F,MAAM,IAAI,KAAK,IAAI,IAAI;CACvB,IAAI,KAAK,OAAO,MAAM,OAAO;CAC7B,MAAM,SAAS,KAAK,OAAO;CAC3B,OAAO,OAAO,IAAK,SAAS,uBAAuB,gBAAiB,SAAS,uBAAuB;AACtG;;;;;;;AAQA,MAAa,cAAc,8EAA8E,UAAU,+DAA+D,YAAY,uMAAuM,WAAW,6BAA6B,gBAAgB"}
1
+ {"version":3,"file":"theme.js","names":[],"sources":["../src/theme.ts"],"sourcesContent":["import { ensureAnnouncer } from './announce';\nimport { DEFAULT_ACCENT, GROUNDS, PRESETS, type ThemePreset } from './generated/themeDefaults';\nimport { installFocusMain } from './internal/focusMain';\nimport { readStored, writeStored } from './internal/stored';\nimport { reduced } from './internal/util';\n\n/* Theme and accent color. 'auto' follows prefers-color-scheme; colors cross-fade for 300 ms on a change.\n The choice is kept in localStorage, so initTheme() on the next visit restores it. A preset (data-theme-preset on\n <html>, or initTheme({ preset })) replaces light and dark: the teaching preset is light only. The accent comes from\n tokens.css until the person picks one (setAccent); only then are inline --accent variables written. */\n\nexport type ThemeSetting = 'auto' | 'light' | 'dark';\nexport type { ThemePreset };\nexport { DEFAULT_ACCENT };\n\nexport const THEME_KEY = 'ui-theme';\nexport const ACCENT_KEY = 'ui-accent';\n/** The picked accent's derived tokens, for themeScript. */\nconst ACCENT_VARS_KEY = 'ui-accent-vars';\nconst PRESET_ATTR = 'data-theme-preset';\n\nconst isSetting = (v: string | null): v is ThemeSetting => v === 'auto' || v === 'light' || v === 'dark';\nconst hasDom = () => typeof window !== 'undefined' && typeof document !== 'undefined';\n\n/** A stored theme setting as text to the setting, 'auto' for anything else. */\nexport const parseTheme = (raw: string): ThemeSetting => (isSetting(raw) ? raw : 'auto');\n\n/** The stored theme setting, 'auto' when there is none (and on the server). */\nexport function storedTheme(): ThemeSetting {\n return hasDom() ? parseTheme(readStored(THEME_KEY) ?? '') : 'auto';\n}\n\n/** The preset on <html data-theme-preset>, or null (the light and dark themes). */\nexport function themePreset(): ThemePreset | null {\n if (typeof document === 'undefined') return null;\n const v = document.documentElement.getAttribute(PRESET_ATTR);\n return v && Object.hasOwn(PRESETS, v) ? (v as ThemePreset) : null;\n}\n\nfunction resolveTheme(t: ThemeSetting): 'light' | 'dark' {\n if (t !== 'auto') return t;\n return typeof window.matchMedia === 'function' && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n}\n\nlet fadeTimer: ReturnType<typeof setTimeout> | undefined;\n\n/** Switches the theme on <html data-theme> and remembers it. Under a preset the setting is remembered but the\n * preset stays (the teaching preset is light only). */\nexport function setTheme(t: ThemeSetting): void {\n if (!hasDom()) return;\n const root = document.documentElement;\n if (!reduced()) {\n root.classList.add('ui-theme-fade');\n clearTimeout(fadeTimer);\n fadeTimer = setTimeout(() => root.classList.remove('ui-theme-fade'), 320);\n }\n root.setAttribute('data-theme', themePreset() ?? resolveTheme(t));\n root.setAttribute('data-theme-setting', t);\n writeStored(THEME_KEY, t);\n // The accent's text and soft colors depend on the theme.\n applyAccent();\n}\n\n/** Swatches whose color changed so they read as text on every ground: a stored old value moves to the new one. */\nconst RENAMED_SWATCHES: Record<string, string> = {\n '#8a4fd6': '#864ad1',\n '#c2407a': '#ba3873',\n '#cd3a2f': '#c53228',\n '#b85a0e': '#ab5101',\n '#1a844a': '#077b42',\n '#0e827d': '#027874',\n};\n\n/** A stored accent as text to #rrggbb, an old swatch value moved to its current one; null for anything else. */\nexport function parseAccent(raw: string): string | null {\n const v = raw.trim().toLowerCase();\n if (!/^#[0-9a-f]{6}$/.test(v)) return null;\n return RENAMED_SWATCHES[v] ?? v;\n}\n\n/** The accent the person picked (stored), with an old swatch value moved to its current one (and stored again);\n * null when they picked none, so tokens.css decides. */\nexport function pickedAccent(): string | null {\n if (!hasDom()) return null;\n const raw = readStored(ACCENT_KEY);\n const v = raw ? parseAccent(raw) : null;\n if (v && v !== raw) writeStored(ACCENT_KEY, v);\n return v;\n}\n\n/** The accent in use: the picked one, else the preset's accent, else the default (DEFAULT_ACCENT). */\nexport function storedAccent(): string {\n return pickedAccent() ?? defaultAccent();\n}\n\n/** The accent tokens.css gives when nothing is picked: the preset's, else DEFAULT_ACCENT. */\nexport function defaultAccent(): string {\n const p = themePreset();\n return p ? PRESETS[p].accent : DEFAULT_ACCENT;\n}\n\nconst hexRgb = (x: string): number[] => [1, 3, 5].map((i) => parseInt(x.slice(i, i + 2), 16));\n\n/** A CSS color as #rrggbb: #rgb, #rgba, #rrggbb, #rrggbbaa (alpha dropped), rgb() and rgba() with commas or spaces.\n * null for anything else (a name, a var(), an empty value). Bundlers shorten #ffffff to #fff in tokens.css, so the\n * short form must read the same. */\nexport function toHex(c: string): string | null {\n const v = c.trim().toLowerCase();\n const short = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]?$/.exec(v);\n if (short) return '#' + short[1] + short[1] + short[2] + short[2] + short[3] + short[3];\n const long = /^#([0-9a-f]{6})(?:[0-9a-f]{2})?$/.exec(v);\n if (long) return '#' + long[1];\n const fn = /^rgba?\\(\\s*([\\d.]+)[\\s,]+([\\d.]+)[\\s,]+([\\d.]+)(?:\\s*[,/]\\s*[\\d.]+%?)?\\s*\\)$/.exec(v);\n if (fn) {\n const n = fn.slice(1, 4).map(Number);\n if (n.every((x) => x >= 0 && x <= 255)) return '#' + n.map((x) => Math.round(x).toString(16).padStart(2, '0')).join('');\n }\n return null;\n}\n\nfunction mixHex(a: string, b: string, t: number): string {\n const p = hexRgb(a);\n const q = hexRgb(b);\n return (\n '#' +\n p\n .map((v, i) =>\n Math.round(v + (q[i] - v) * t)\n .toString(16)\n .padStart(2, '0'),\n )\n .join('')\n );\n}\n\nfunction lum(x: string): number {\n const w = [0.2126, 0.7152, 0.0722];\n return hexRgb(x)\n .map((v) => {\n v /= 255;\n return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n })\n .reduce((s, v, i) => s + v * w[i], 0);\n}\n\nfunction contrast(a: string, b: string): number {\n const x = lum(a);\n const y = lum(b);\n return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);\n}\n\n/** The accent's text color (accent-text, and the focus outline): the accent itself when it reads (4.5:1) on bg,\n * surface and every extra ground passed (setAccent passes surface-sub, surface-chrome and accent-soft); else, in\n * light, the accent mixed with black 4 % at a time, in dark with white 5 % at a time, until it reads on all of them. */\nexport function accentText(hex: string, dark: boolean, bg: string, surface: string, ...grounds: string[]): string {\n const all = [bg, surface, ...grounds].map(toHex);\n // A background that cannot be read: keep the accent itself rather than mixing it toward black or white blindly.\n if (all.some((g) => !g)) return hex;\n const reads = (c: string) => all.every((g) => contrast(c, g as string) >= 4.5);\n const toward = dark ? '#ffffff' : '#000000';\n const step = dark ? 0.05 : 0.04;\n let text = hex;\n for (let k = 1; k * step <= 1 && !reads(text); k++) text = mixHex(hex, toward, k * step);\n return text;\n}\n\nconst INK = GROUNDS.ink.light;\n\n/** The text on an accent fill (on-accent): white or the near-black ink (#171512), whichever contrasts more. */\nexport function onFill(fill: string): '#ffffff' | '#171512' {\n return contrast('#ffffff', fill) >= contrast(INK, fill) ? '#ffffff' : INK;\n}\n\n/** The accent's fill color (accent: buttons, switches, progress, selected marks): the accent itself when it reaches\n * 3:1 on bg, surface and every extra ground passed (setAccent passes surface-sub, surface-chrome and accent-soft) and\n * its on-accent text reaches 4.5:1 on it; else, in light, the accent mixed with black 4 % at a time, in dark with\n * white 5 % at a time, until both hold. The preset swatches pass in light as they are. */\nexport function accentFill(hex: string, dark: boolean, bg: string, surface: string, ...grounds: string[]): string {\n const all = [bg, surface, ...grounds].map(toHex);\n if (all.some((g) => !g)) return hex;\n const ok = (c: string) => all.every((g) => contrast(c, g as string) >= 3) && contrast(onFill(c), c) >= 4.5;\n const toward = dark ? '#ffffff' : '#000000';\n const step = dark ? 0.05 : 0.04;\n let fill = hex;\n for (let k = 1; k * step <= 1 && !ok(fill); k++) fill = mixHex(hex, toward, k * step);\n return fill;\n}\n\n/** The preset swatches of AccentPicker. In light (and the teaching preset) each one reads as text by itself (4.5:1 on\n * bg, surface, surface-sub, surface-chrome and its own accent-soft), so accentText returns it unchanged; white text\n * reads on it (4.5:1). In dark, accentText lightens it. Checked in tokens-contrast.test.tsx. */\nexport const ACCENT_SWATCHES: readonly (readonly [name: string, hex: string])[] = [\n ['藍', '#2457d6'],\n ['靛', '#5b4fd6'],\n ['紫', '#864ad1'],\n ['桃紅', '#ba3873'],\n ['紅', '#c53228'],\n ['橘', '#ab5101'],\n ['綠', '#077b42'],\n ['青', '#027874'],\n];\n\nconst ACCENT_VARS = ['--accent', '--accent-hover', '--accent-press', '--accent-soft', '--accent-text', '--on-accent', '--focus', '--focus-ring'];\n\n/** Every accent token for one color on one theme's grounds. */\nfunction accentVars(hex: string, dark: boolean, surface: string, bg: string, sub: string, chrome: string): Record<string, string> {\n // Dark: the accent 18 % into the page ground, so muted and status text still read 4.5:1 on a selected row.\n const soft = dark ? mixHex(bg, hex, 0.18) : mixHex('#ffffff', hex, 0.12);\n // Text in the accent also sits on zebra rows, code blocks, the top bar and its own soft fill (a selected row).\n const text = accentText(hex, dark, bg, surface, sub, chrome, soft);\n // The fill reaches 3:1 on the same grounds (a checked box in a selected row); hover and press go away from the page:\n // darker in light, lighter in dark, so they keep 3:1 and their text.\n // Dark uses one accent color: the fill is the text color (lighter than a 3:1 fill would need), so buttons, links and\n // marks read as the same blue.\n const fill = dark ? text : accentFill(hex, dark, bg, surface, sub, chrome, soft);\n const away = dark ? '#ffffff' : '#000000';\n return {\n '--accent': fill,\n '--accent-hover': mixHex(fill, away, 0.12),\n '--accent-press': mixHex(fill, away, 0.22),\n '--accent-soft': soft,\n '--accent-text': text,\n '--on-accent': onFill(fill),\n // One focus style everywhere: a 2 px outline in the accent's text color, 3:1 or more on every ground.\n '--focus': text,\n // Old name of --focus, kept for pages written before it.\n '--focus-ring': text,\n };\n}\n\n/** Derives every accent token from one color (自訂強調色的換算 in docs/theme.md) and writes them on <html>.\n * Returns false for anything but #rrggbb. quiet: apply without storing. */\nexport function setAccent(hex: string, quiet = false): boolean {\n if (!/^#[0-9a-fA-F]{6}$/.test(hex)) return false;\n if (!hasDom()) return true;\n hex = hex.toLowerCase();\n const root = document.documentElement;\n const dark = root.getAttribute('data-theme') === 'dark';\n const mode = dark ? 'dark' : 'light';\n const cs = getComputedStyle(root);\n // Read the theme's colors as #rrggbb (bundlers may have shortened #ffffff to #fff); the theme's defaults when unset.\n const surface = toHex(cs.getPropertyValue('--surface')) ?? GROUNDS.surface[mode];\n const bg = toHex(cs.getPropertyValue('--bg')) ?? GROUNDS.bg[mode];\n const sub = toHex(cs.getPropertyValue('--surface-sub')) ?? GROUNDS['surface-sub'][mode];\n const chrome = toHex(cs.getPropertyValue('--surface-chrome')) ?? GROUNDS['surface-chrome'][mode];\n const vars = accentVars(hex, dark, surface, bg, sub, chrome);\n for (const [k, v] of Object.entries(vars)) root.style.setProperty(k, v);\n if (!quiet) writeStored(ACCENT_KEY, hex);\n // The picked accent's tokens for themeScript, which applies them before the first paint: this theme as drawn, the\n // other from the theme defaults (a preset is light only).\n if (readStored(ACCENT_KEY) === hex) {\n const other = !dark;\n const o = other ? 'dark' : 'light';\n const cache: Record<string, unknown> = { hex, [mode]: vars };\n if (!themePreset()) cache[o] = accentVars(hex, other, GROUNDS.surface[o], GROUNDS.bg[o], GROUNDS['surface-sub'][o], GROUNDS['surface-chrome'][o]);\n writeStored(ACCENT_VARS_KEY, JSON.stringify(cache));\n }\n return true;\n}\n\n/** Forgets the picked accent and removes the inline accent variables, so tokens.css (the theme or preset) decides. */\nexport function resetAccent(): void {\n if (!hasDom()) return;\n for (const k of ACCENT_VARS) document.documentElement.style.removeProperty(k);\n writeStored(ACCENT_KEY, null);\n writeStored(ACCENT_VARS_KEY, null);\n}\n\n/** Applies the picked accent for the current theme, or removes the inline variables when none is picked. */\nfunction applyAccent(): void {\n const picked = pickedAccent();\n if (picked) setAccent(picked, true);\n else for (const k of ACCENT_VARS) document.documentElement.style.removeProperty(k);\n}\n\nlet following = false;\n\n/** Applies the stored theme and accent; call once when the page starts. preset: a preset of tokens.json (such as\n * 'teaching') that replaces light and dark, kept on <html data-theme-preset>; null removes it; without the option a\n * data-theme-preset already on <html> is kept. Pages do not set data-theme themselves. */\nexport function initTheme(options: { preset?: ThemePreset | null } = {}): void {\n if (!hasDom()) return;\n const root = document.documentElement;\n if (options.preset === null) root.removeAttribute(PRESET_ATTR);\n else if (options.preset) root.setAttribute(PRESET_ATTR, options.preset);\n setTheme(storedTheme());\n ensureAnnouncer();\n installFocusMain();\n if (following || typeof window.matchMedia !== 'function') return;\n following = true;\n window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {\n if (storedTheme() === 'auto') setTheme('auto');\n });\n}\n\n/** The text color for something drawn on a fill (a heat-scale zone, a status band): the near-black ink of the light\n * theme (#171512) or white, whichever contrasts more with the fill. `fill` is a color (#hex, rgb()) or a token name\n * such as 'heat-6', read from el (default: the root) so it follows the theme. Every step of heat-*, diverge-* and\n * chart-* reaches 4.5:1 with its pick. Unreadable colors give the near-black ink. */\nexport function textOn(fill: string, el?: Element): '#171512' | '#ffffff' {\n let c = fill.trim();\n if (/^[a-z][a-z0-9-]*$/.test(c) && typeof document !== 'undefined') c = getComputedStyle(el ?? document.documentElement).getPropertyValue('--' + c);\n const hex = toHex(c);\n if (!hex) return '#171512';\n return contrast(hex, '#171512') >= contrast(hex, '#ffffff') ? '#171512' : '#ffffff';\n}\n\n/** The heat-scale token for a value: min (or below) is heat-1, max (or above) is heat-7, evenly in between. */\nexport function heatToken(value: number, min: number, max: number): `heat-${1 | 2 | 3 | 4 | 5 | 6 | 7}` {\n const t = max > min ? (value - min) / (max - min) : 0;\n const step = Math.min(7, Math.max(1, Math.round(t * 6) + 1)) as 1 | 2 | 3 | 4 | 5 | 6 | 7;\n return `heat-${step}`;\n}\n\n/** The diverging-scale token for a difference: within ±zero it is diverge-zero; from ±strong on, the -strong step. */\nexport function divergeToken(\n diff: number,\n limits: { zero: number; strong: number },\n): 'diverge-neg-strong' | 'diverge-neg' | 'diverge-zero' | 'diverge-pos' | 'diverge-pos-strong' {\n const a = Math.abs(diff);\n if (a <= limits.zero) return 'diverge-zero';\n const strong = a >= limits.strong;\n return diff < 0 ? (strong ? 'diverge-neg-strong' : 'diverge-neg') : strong ? 'diverge-pos-strong' : 'diverge-pos';\n}\n\n/**\n * A small script for an inline <script> in <head> of a server-rendered page: applies the stored theme (data-theme,\n * data-theme-setting) and the picked accent before the first paint, so the page does not flash the light theme or the\n * default accent until initTheme runs. A preset goes on <html data-theme-preset> in the server's markup; the script\n * keeps it. Still call initTheme() at startup.\n */\nexport const themeScript = `(function(){try{var d=document.documentElement,s=localStorage,t=s.getItem('${THEME_KEY}');if(t!=='light'&&t!=='dark')t='auto';var p=d.getAttribute('${PRESET_ATTR}');var m=t!=='auto'?t:window.matchMedia&&matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light';d.setAttribute('data-theme',p||m);d.setAttribute('data-theme-setting',t);var a=s.getItem('${ACCENT_KEY}'),c=JSON.parse(s.getItem('${ACCENT_VARS_KEY}')||'null'),v=a&&c&&c.hex===a&&c[p?'light':m];if(v)for(var k in v)d.style.setProperty(k,v[k])}catch(e){}})();`;\n"],"mappings":";;;;;;;AAeA,MAAa,YAAY;AACzB,MAAa,aAAa;;AAE1B,MAAM,kBAAkB;AACxB,MAAM,cAAc;AAEpB,MAAM,aAAa,MAAwC,MAAM,UAAU,MAAM,WAAW,MAAM;AAClG,MAAM,eAAe,OAAO,WAAW,eAAe,OAAO,aAAa;;AAG1E,MAAa,cAAc,QAA+B,UAAU,GAAG,IAAI,MAAM;;AAGjF,SAAgB,cAA4B;CAC1C,OAAO,OAAO,IAAI,WAAW,WAAA,UAAoB,KAAK,EAAE,IAAI;AAC9D;;AAGA,SAAgB,cAAkC;CAChD,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,MAAM,IAAI,SAAS,gBAAgB,aAAa,WAAW;CAC3D,OAAO,KAAK,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--line-soft: #f1efed;
16
17
  --graph-edge: #8c8073;
17
18
  --graph-node: #f6f5f4;
18
19
  --code-keyword: #2457d6;
@@ -91,10 +92,10 @@
91
92
  --block-gap: 32px;
92
93
  --space-12: 48px;
93
94
  --radius-xs: 4px;
94
- --radius-sm: 6px;
95
+ --radius-sm: 8px;
95
96
  --radius-chip: 8px;
96
97
  --radius-md: 10px;
97
- --radius-lg: 14px;
98
+ --radius-lg: 12px;
98
99
  --radius-full: 9999px;
99
100
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.12);
100
101
  --shadow-chip: 0 1px 2px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.08);
@@ -105,7 +106,7 @@
105
106
  --chip-height: 32px;
106
107
  --touch-target: 48px;
107
108
  --header-height: 64px;
108
- --sidebar-width: 240px;
109
+ --sidebar-width: 208px;
109
110
  --sidebar-collapsed: 72px;
110
111
  --tabbar-height: 68px;
111
112
  --icon-stroke: 2px;
@@ -114,14 +115,14 @@
114
115
  --bp-desktop: 960px;
115
116
  --bp-wide: 1280px;
116
117
  --text-mini: 12px;
117
- --text-small: 13px;
118
+ --text-small: 12px;
118
119
  --text-compact: 14px;
119
120
  --text-control: 15px;
120
121
  --text-body: 16px;
121
122
  --text-title: 17px;
122
123
  --text-lead: 18px;
123
124
  --text-h4: 20px;
124
- --text-h3: 25px;
125
+ --text-h3: 24px;
125
126
  --text-h2: 31px;
126
127
  --text-h1: 39px;
127
128
  --text-display: 49px;
@@ -157,40 +158,41 @@
157
158
  }
158
159
  [data-theme="dark"] {
159
160
  color-scheme: dark;
160
- --bg: #2f2a25;
161
- --surface: #393530;
162
- --surface-sub: #443f3b;
163
- --surface-chrome: #3d3834;
161
+ --bg: #292725;
162
+ --surface: #393632;
163
+ --surface-sub: #413d38;
164
+ --surface-chrome: #34312e;
164
165
  --surface-input: #26221e;
165
166
  --ink: #f6f5f4;
166
- --ink-muted: #b3aba2;
167
+ --ink-muted: #ada8a0;
167
168
  --line: #4c4844;
168
169
  --line-strong: #988c80;
169
- --graph-edge: #b3aba2;
170
- --graph-node: #443f3b;
170
+ --line-soft: #433f3b;
171
+ --graph-edge: #ada8a0;
172
+ --graph-node: #413d38;
171
173
  --code-keyword: #a3b7ee;
172
174
  --code-constant: #3cc4ae;
173
- --accent: #6689e2;
174
- --accent-hover: #7897e5;
175
- --accent-press: #88a3e8;
175
+ --accent: #92abeb;
176
+ --accent-hover: #9fb5ed;
177
+ --accent-press: #aabdef;
176
178
  --accent-text: #92abeb;
177
- --accent-soft: #343c55;
179
+ --accent-soft: #283045;
178
180
  --on-accent: #171512;
179
181
  --focus: #92abeb;
180
182
  --focus-ring: #92abeb;
181
- --success: #1ca655;
182
- --success-text: #82cea2;
183
+ --success: #80cba5;
184
+ --success-text: #80cba5;
183
185
  --success-soft: #2c3e2d;
184
- --warning: #d68710;
185
- --warning-text: #e8bd7c;
186
+ --warning: #e6b66d;
187
+ --warning-text: #e6b66d;
186
188
  --warning-soft: #4a3922;
187
- --danger: #dc6965;
189
+ --danger: #e58d8d;
188
190
  --on-danger: #171512;
189
- --danger-text: #e79593;
191
+ --danger-text: #e69292;
190
192
  --danger-soft: #482a25;
191
193
  --info-text: #90aaea;
192
194
  --info-soft: #2d3141;
193
- --danger-ring: #e79593;
195
+ --danger-ring: #e69292;
194
196
  --mark: #7c5d12;
195
197
  --chart-1: #819ee7;
196
198
  --chart-2: #3cc4ae;
@@ -209,10 +211,10 @@
209
211
  --diverge-pos: #d9772f;
210
212
  --diverge-pos-strong: #f0a35e;
211
213
  --forecast-stripe: rgba(246, 245, 244, 0.14);
212
- --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
213
- --shadow-chip: 0 1px 2px rgba(0, 0, 0, 0.45);
214
- --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.6), 0 8px 24px rgba(0, 0, 0, 0.55);
215
- --shadow-card-hover: 0 2px 4px rgba(0, 0, 0, 0.6), 0 16px 36px rgba(0, 0, 0, 0.6);
214
+ --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
215
+ --shadow-chip: 0 1px 2px rgba(0, 0, 0, 0.28);
216
+ --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.24);
217
+ --shadow-card-hover: 0 2px 6px rgba(0, 0, 0, 0.3);
216
218
  --shadow-overlay: 0 20px 48px rgba(0, 0, 0, 0.5);
217
219
  }
218
220
  [data-theme="teaching"] {
package/docs/AiMark.md CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  ## 細節
18
18
 
19
- - 13 px、`ink-muted` 灰字,和前面的文字隔 8 px,不換行。
19
+ - 12 px、`ink-muted` 灰字,和前面的文字隔 8 px,不換行。
20
20
  - 不是連結也不是按鈕,Tab 不會停在上面。
21
21
  - 畫面上的字對螢幕閱讀器隱藏,改念「(AI 撰寫)」;`label` 可以另外指定(沒給時跟著 `UI.t()` 的語言)。
22
22
  - Markdown 的寫法放在段落、清單項目或表格格子的開頭或結尾都可以。
package/docs/AppShell.md CHANGED
@@ -34,8 +34,8 @@ Dashboard 類頁面的外框:側邊欄、頂部列和內容區,平板的導
34
34
  ## 細節
35
35
 
36
36
  - 大於 1024 px:側邊欄預設不釘選,平常是 72 px 的圖示列,點圖示就能換頁。
37
- - 滑鼠停在圖示列上 100 ms,展開成 240 px,疊在內容上、帶陰影,內容不移動;滑鼠離開 300 ms 後收回。用 Tab 移進側邊欄時也會展開,焦點離開或按 Esc 時收回;選了頁面後收回。
38
- - 左下角的圖釘按鈕「釘選側邊欄」:釘選後側邊欄固定在內容旁邊(240 px),旁邊多一個收合按鈕,可以收合成 72 px。圖釘變成實心強調色,按了「取消釘選」回到自動展開。
37
+ - 滑鼠停在圖示列上 100 ms,展開成 208 px,疊在內容上、帶陰影,內容不移動;滑鼠離開 300 ms 後收回。用 Tab 移進側邊欄時也會展開,焦點離開或按 Esc 時收回;選了頁面後收回。
38
+ - 左下角的圖釘按鈕「釘選側邊欄」:釘選後側邊欄固定在內容旁邊(208 px),旁邊多一個收合按鈕,可以收合成 72 px。圖釘變成實心強調色,按了「取消釘選」回到自動展開。
39
39
  - 釘選和收合都記在瀏覽器。
40
40
  - `defaultPinned`:沒有存過選擇時是否一開始就釘選,預設 false。
41
41
  - 平板和窄視窗(600 到 1024 px,含 1024 px):沒有側邊欄,內容用滿整個寬度;頂部列左邊有選單按鈕(「開啟導覽」),點了從左邊打開完整導覽的抽屜,選了頁面後關閉。1024 px 是導覽自己的邊界,頁面排版的斷點(600、960、1280 px)不受影響。
@@ -52,7 +52,7 @@ Dashboard 類頁面的外框:側邊欄、頂部列和內容區,平板的導
52
52
  ```
53
53
 
54
54
  - 收合(72 px,包括沒釘選時平常的圖示列和釘選後收合):只顯示 `mark`,名稱藏起來。仍是回首頁的連結,Tab 可以停,`aria-label` 是完整的 `name`。
55
- - 展開或釘選(240 px):`mark` 加 `name`。名稱跟著側邊欄展開淡入(300 ms,和變寬同一條曲線,晚 80 ms 開始),收回時 100 ms 淡出。
55
+ - 展開或釘選(208 px):`mark` 加 `name`。名稱跟著側邊欄展開淡入(300 ms,和變寬同一條曲線,晚 80 ms 開始),收回時 100 ms 淡出。
56
56
  - `mark` 的位置在每個狀態都一樣:中心對齊下面項目的圖示(離左邊 31 px),展開時不移動。`mark` 最大 24 × 24 px。
57
57
  - 只傳文字(`brand="專案中心"`)或沒給 `mark`:用名稱的第一個字放在 24 px 的強調色方塊裡當 `mark`(「專」)。沒有 `href` 時不是連結,螢幕閱讀器念完整名稱。
58
58
  - `onClick` 可以代替 `href`(例如 app 自己切換頁面)。
package/docs/BarChart.md CHANGED
@@ -15,7 +15,7 @@
15
15
  />
16
16
  ```
17
17
 
18
- - `label` 必填,是圖表的無障礙名稱;`unit` 寫在數值後面,也寫在 y 軸上方(13 px 以下的 `ink-muted` 小字)。
18
+ - `label` 必填,是圖表的無障礙名稱;`unit` 寫在數值後面,也寫在 y 軸上方(12 px 以下的 `ink-muted` 小字)。
19
19
  - 數值上萬時給 `format="compact"`:軸和數值卡片寫「50 萬」「1.5 億」(英文 1.5M),不寫「1,500,000」。不給時 y 軸的寬度也會依標籤量,不會畫到卡片外。
20
20
  - 和旁邊較高的卡片並排時給 `height="fill"`:長條區填滿 Card 剩下的高度(最矮 160 px),不留空白;預設 200 px,也可以給數字(px)。等寬的 Grid 一排本來就一樣高;比例 Grid(`columns={[2, 1]}`)靠上對齊,要撐滿時那個 Grid 給 `align="stretch"`。
21
21
  - 顏色 `chart-1`,柱子頂部 4 px 圓角,間距 8 px。滑過或用鍵盤移到柱子時,上方浮起卡片顯示數值。
package/docs/Card.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## 用法
4
4
 
5
- 頁面上的區塊容器:`surface` 底、`shadow-card` 陰影、14 px 圓角,內距 16 px。每個區塊一張 Card,用 `Grid` 排。
5
+ 頁面上的區塊容器:`surface` 底、`shadow-card` 陰影、12 px 圓角,內距 16 px。每個區塊一張 Card,用 `Grid` 排。
6
6
 
7
7
  ```tsx
8
8
  <Card title="每個程式的耗時" actions={<Button icon="download-simple">匯出</Button>} padding={false}>
@@ -50,4 +50,4 @@ h('div', { className: 'ui-forecast', style: { background: 'var(--heat-4)' } }, '
50
50
 
51
51
  ## 監控畫面的字級
52
52
 
53
- 全螢幕、常駐、遠看的監控畫面:最小字 13 px,SVG 軸標 12 px。大螢幕等比放大,倍數是「視窗寬 ÷ 1440」與「視窗高 ÷ 900」的較小者,下限 1、上限 1.5。
53
+ 全螢幕、常駐、遠看的監控畫面:最小字 12 px(SVG 軸標也是 12 px)。大螢幕等比放大,倍數是「視窗寬 ÷ 1440」與「視窗高 ÷ 900」的較小者,下限 1、上限 1.5。
@@ -15,19 +15,19 @@
15
15
  />
16
16
  ```
17
17
 
18
- - 依照元件本身的寬度切換:600 px 以上名稱在左(13 px 次要文字,不換行)、值在右;比較窄時名稱在上、值在下,全部靠左,和手機表格卡片一致。
18
+ - 依照元件本身的寬度切換:600 px 以上名稱在左(12 px 次要文字,不換行)、值在右;比較窄時名稱在上、值在下,全部靠左,和手機表格卡片一致。
19
19
  - 值可以放任何元素:`InlineCode`、`Tag`、`Badge`。
20
20
  - 值要連到別處時給那一列 `href`(另一個網站加 `external`),不要在 `value` 裡自己放 `Link` 或有 `href` 的 `InlineCode`:值變成連結,整列都能點,列高至少 48 px(觸控目標);自己放的連結只有一行字高,`ui check` 會判定觸控目標太小。
21
21
  - 寬面板(例如 1300 px 的側邊面板):設 `labelWidth="auto"` 與 `labelSize="body"`。
22
22
 
23
23
  ## 細節
24
24
 
25
- - 寬面板設定時,左欄寬度依最長的名稱(最多 40%),每列對齊,名稱和值隔 24 px;名稱改成和值同字級(16 px)、ink 色。600 px 以下仍是名稱在上、值在下,名稱 13 px。
25
+ - 寬面板設定時,左欄寬度依最長的名稱(最多 40%),每列對齊,名稱和值隔 24 px;名稱改成和值同字級(16 px)、ink 色。600 px 以下仍是名稱在上、值在下,名稱 12 px。
26
26
 
27
27
  | Prop | 說明 |
28
28
  | ------------ | ------------------------------------------------------------------------ |
29
29
  | `labelWidth` | 左欄寬度。預設 30%(至少 96 px);`'auto'` 依最長的名稱;數字是固定 px。 |
30
- | `labelSize` | `'small'`(預設)13 px 次要色;`'body'` 與值同字級、ink 色。 |
30
+ | `labelSize` | `'small'`(預設)12 px 次要色;`'body'` 與值同字級、ink 色。 |
31
31
 
32
32
  每一列(`items`):
33
33
 
@@ -27,7 +27,7 @@
27
27
 
28
28
  ## 細節
29
29
 
30
- - 時間用 Geist Mono 灰字(24 小時制),和說明同一個大小(同一列一種字級);做的人灰字、不拆開換行;日期 13 px 灰色粗體(自成一列)。
30
+ - 時間用 Geist Mono 灰字(24 小時制),和說明同一個大小(同一列一種字級);做的人灰字、不拆開換行;日期 12 px 灰色粗體(自成一列)。
31
31
  - 圖示 20 px、沒有底色,螢幕閱讀器念類型名稱。內建類型:`alert` warning 圖示、`warning-text` 色;`switch` 左右箭頭、`accent-text`;`ai` 星芒、灰;`manual` 人像、灰。
32
32
  - `tone` 的顏色:`info` 用 `accent-text`,`success`、`warning`、`danger` 用各自的文字色。
33
33
  - 沒有定義的 `kind` 顯示一個灰色圓點,開發模式會提醒加進 `kinds`。
package/docs/FloorPlan.md CHANGED
@@ -85,12 +85,12 @@ h(UI.FloorPlan, {
85
85
 
86
86
  ## 細節
87
87
 
88
- - 標籤:在分區裡放得下時寫名稱(16 px 半粗)、主數值(25 px Geist Mono,單位 16 px)和狀態(13 px 半粗);外框包圍盒長寬比大於 4 的細長分區,或完整標籤放不下時,改用一行膠囊(13 px,`surface` 底);膠囊也會和別的標籤重疊時不顯示。標籤一律同樣大小,放大後放得下的就會出現。
88
+ - 標籤:在分區裡放得下時寫名稱(16 px 半粗)、主數值(24 px Geist Mono,單位 16 px)和狀態(12 px 半粗);外框包圍盒長寬比大於 4 的細長分區,或完整標籤放不下時,改用一行膠囊(12 px,`surface` 底);膠囊也會和別的標籤重疊時不顯示。標籤一律同樣大小,放大後放得下的就會出現。
89
89
  - 標籤的優先序:選取中的分區最先,接著 `labelPriority` 大的先(預設 0),再來 primary 在 muted 之前,各自面積小的先;被捨棄的分區仍然有游標提示,也在 Tab 順序裡。Tab 順序不受 `labelPriority` 和選取影響。
90
- - `emphasis: 'muted'`:次要區域,填色是原色 40 % 混 `surface`,標籤 13 px 名稱加 16 px 數值,字用 `ink`;可以選,`tone` 的 4 px 內框和「⚠」照常顯示;螢幕閱讀器多念「次要」。有 muted 分區時圖例多一行「淡色=次要區域」。
90
+ - `emphasis: 'muted'`:次要區域,填色是原色 40 % 混 `surface`,標籤 12 px 名稱加 16 px 數值,字用 `ink`;可以選,`tone` 的 4 px 內框和「⚠」照常顯示;螢幕閱讀器多念「次要」。有 muted 分區時圖例多一行「淡色=次要區域」。
91
91
  - 填色、字色、4 px 注意內框、預測斜線、沒有資料的虛線框、數值和單位之間的空格,都和 ZoneMap 相同(見 `ui docs ZoneMap`)。
92
92
  - 選取:`ink` 色 2 px 外框,在分區外 4 px。鍵盤焦點:`focus` 色 2 px 外框,緊貼分區外側,並顯示提示。
93
- - `groups`:同一組的分區外面畫一圈 1.5 px `ink-muted` 細框(沿著整組的外形),左上角寫組名(13 px)。不計算也不顯示整組的數值。
93
+ - `groups`:同一組的分區外面畫一圈 1.5 px `ink-muted` 細框(沿著整組的外形),左上角寫組名(12 px)。不計算也不顯示整組的數值。
94
94
  - `shell`:建築外框,`surface-sub` 底加 `line-strong` 邊。`edges`:分區之間的邊界,1.5 px `ink-muted` 虛線。
95
95
  - 視角:`defaultView`(`{ x, y, zoom }`,中心點的公尺座標,y 向上;`zoom` 1 是全景,最多 8)是一開始的視角;`onViewChange(view)` 在視角停下來時(拖曳、雙指放開、滾輪一格、按鍵或按鈕的動畫結束)給出新的視角。元件被卸載再掛上時(例如切到清單檢視再切回來),把最後一次的 `view` 存起來、當 `defaultView` 傳回去,就會停在原來的地方。
96
96
  - 縮放與平移:滾輪、雙指縮放、拖曳平移;右下角「放大」「縮小」「重設視角」;鍵盤在圖上(包括分區上)按 + − 縮放、方向鍵平移。最多放大 8 倍,全景時不能平移。按鈕和鍵盤的變化有 200 ms 的動畫,`prefers-reduced-motion` 時直接跳過去。拖曳超過 4 px 不算點選。