@seanyeh77/ui 0.53.0 → 0.54.1

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.
Files changed (59) hide show
  1. package/dist/bundle.js +4 -4
  2. package/dist/components/CodeView/CodeView.js +2 -1
  3. package/dist/components/CodeView/CodeView.js.map +1 -1
  4. package/dist/components/DataTable/SortButton.js +1 -1
  5. package/dist/components/DataTable/SortButton.js.map +1 -1
  6. package/dist/components/DataTable/parts.js +4 -2
  7. package/dist/components/DataTable/parts.js.map +1 -1
  8. package/dist/components/Menu/Menu.js +2 -1
  9. package/dist/components/Menu/Menu.js.map +1 -1
  10. package/dist/components/MultiSelect/MultiSelect.js +1 -0
  11. package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
  12. package/dist/components/ProjectSwitcher/ProjectSwitcher.js +2 -1
  13. package/dist/components/ProjectSwitcher/ProjectSwitcher.js.map +1 -1
  14. package/dist/components/Select/Select.js +2 -0
  15. package/dist/components/Select/Select.js.map +1 -1
  16. package/dist/components/Workbench/Workbench.js +1 -0
  17. package/dist/components/Workbench/Workbench.js.map +1 -1
  18. package/dist/css/Card.css +1 -1
  19. package/dist/css/DataTable.css +18 -8
  20. package/dist/css/Markdown.css +3 -3
  21. package/dist/css/PageHeader.css +1 -1
  22. package/dist/css/Section.css +1 -1
  23. package/dist/css/TopBar.css +9 -2
  24. package/dist/css/base.css +4 -0
  25. package/dist/css/end.css +4 -0
  26. package/dist/generated/themeDefaults.js +4 -4
  27. package/dist/generated/themeDefaults.js.map +1 -1
  28. package/dist/internal/FloatingPanel.js +2 -1
  29. package/dist/internal/FloatingPanel.js.map +1 -1
  30. package/dist/styles.css +41 -16
  31. package/dist/theme.js +2 -2
  32. package/dist/theme.js.map +1 -1
  33. package/dist/tokens.css +29 -27
  34. package/docs/AiMark.md +1 -1
  35. package/docs/AppShell.md +3 -3
  36. package/docs/BarChart.md +1 -1
  37. package/docs/Card.md +1 -1
  38. package/docs/DataColors.md +1 -1
  39. package/docs/DetailList.md +3 -3
  40. package/docs/EventTimeline.md +1 -1
  41. package/docs/FloorPlan.md +3 -3
  42. package/docs/Graph.md +1 -1
  43. package/docs/IconButton.md +1 -1
  44. package/docs/InlineCode.md +2 -2
  45. package/docs/KpiCard.md +1 -1
  46. package/docs/PageHeader.md +1 -1
  47. package/docs/Section.md +1 -1
  48. package/docs/SideNav.md +3 -3
  49. package/docs/TimeControl.md +1 -1
  50. package/docs/Tooltip.md +1 -1
  51. package/docs/TopBar.md +1 -1
  52. package/docs/TreeList.md +1 -1
  53. package/docs/ZoneMap.md +1 -1
  54. package/docs/agents.md +5 -5
  55. package/docs/guidelines.md +1 -1
  56. package/docs/layout.md +1 -1
  57. package/docs/monitoring.md +3 -3
  58. package/docs/theme.md +1 -1
  59. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"FloatingPanel.js","names":[],"sources":["../../src/internal/FloatingPanel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Popover } from '@base-ui/react/popover';\nimport { baseReason, type OpenChangeReason } from './open';\n\nexport interface FloatingPanelProps {\n open: boolean;\n onOpenChange: (open: boolean, reason?: OpenChangeReason) => void;\n /** The element that opens the panel; it must accept a ref (a native element or a component that passes ref on). */\n trigger: React.ReactElement;\n side?: 'top' | 'bottom';\n align?: 'start' | 'center' | 'end';\n sideOffset?: number;\n /** Class of the panel (it carries the look: .ui-datepop, .ui-noti …). */\n className?: string;\n /** Accessible name of the panel. */\n 'aria-label'?: string;\n /** Position against this element instead of the trigger (e.g. the whole field around a calendar button). */\n anchor?: React.RefObject<Element | null>;\n /** Open on hover as well as on press. */\n openOnHover?: boolean;\n /** Keeps the panel inside this element (shifting it sideways, then flipping), not just inside the window: a menu of\n * a table stays over the table instead of covering the panel beside it. */\n boundary?: React.RefObject<Element | null>;\n /** Hover delay before opening, in ms (with openOnHover). Default 0. */\n delay?: number;\n /** Id of the panel, for aria-describedby on the trigger. */\n id?: string;\n /** Move focus into the panel when it opens: true (the first focusable element), false, or a CSS selector of the\n * element to focus inside the panel (the first focusable element when none matches). Default true. */\n focusOnOpen?: boolean | string;\n children: React.ReactNode;\n}\n\n/** A positioned panel next to its trigger: flips when there is no room, closes on Esc and outside press, returns focus. */\nexport function FloatingPanel({\n open,\n onOpenChange,\n trigger,\n side = 'bottom',\n align = 'start',\n sideOffset = 6,\n className,\n openOnHover,\n anchor,\n boundary,\n delay = 0,\n id,\n focusOnOpen = true,\n children,\n ...aria\n}: FloatingPanelProps) {\n const within = boundary?.current ?? undefined;\n const popup = React.useRef<HTMLDivElement>(null);\n const initialFocus =\n focusOnOpen === false ? false : typeof focusOnOpen === 'string' ? () => popup.current?.querySelector<HTMLElement>(focusOnOpen) ?? true : undefined;\n return (\n <Popover.Root open={open} onOpenChange={(next, details) => onOpenChange(next, baseReason(details?.reason))}>\n <Popover.Trigger render={trigger} openOnHover={openOnHover} delay={delay} closeDelay={150} />\n <Popover.Portal>\n <Popover.Positioner\n className=\"ui-float\"\n side={side}\n align={align}\n sideOffset={sideOffset}\n anchor={anchor}\n collisionBoundary={within}\n collisionPadding={within ? 0 : undefined}\n // Inside a boundary: slid sideways until it fits, rather than swapping its alignment.\n collisionAvoidance={within ? { side: 'flip', align: 'shift' } : undefined}\n >\n <Popover.Popup ref={popup} id={id} className={className} aria-label={aria['aria-label']} initialFocus={initialFocus}>\n {children}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"mappings":";;;;;;;AAkCA,SAAgB,cAAc,EAC5B,MACA,cACA,SACA,OAAO,UACP,QAAQ,SACR,aAAa,GACb,WACA,aACA,QACA,UACA,QAAQ,GACR,IACA,cAAc,MACd,UACA,GAAG,QACkB;CACrB,MAAM,SAAS,UAAU,WAAW,KAAA;CACpC,MAAM,QAAQ,MAAM,OAAuB,IAAI;CAC/C,MAAM,eACJ,gBAAgB,QAAQ,QAAQ,OAAO,gBAAgB,iBAAiB,MAAM,SAAS,cAA2B,WAAW,KAAK,OAAO,KAAA;CAC3I,OACE,qBAAC,QAAQ,MAAT;EAAoB;EAAM,eAAe,MAAM,YAAY,aAAa,MAAM,WAAW,SAAS,MAAM,CAAC;EAAzG,UAAA,CACE,oBAAC,QAAQ,SAAT;GAAiB,QAAQ;GAAsB;GAAoB;GAAO,YAAY;EAAM,CAAA,GAC5F,oBAAC,QAAQ,QAAT,EAAA,UACE,oBAAC,QAAQ,YAAT;GACE,WAAU;GACJ;GACC;GACK;GACJ;GACR,mBAAmB;GACnB,kBAAkB,SAAS,IAAI,KAAA;GAE/B,oBAAoB,SAAS;IAAE,MAAM;IAAQ,OAAO;GAAQ,IAAI,KAAA;GAEhE,UAAA,oBAAC,QAAQ,OAAT;IAAe,KAAK;IAAW;IAAe;IAAW,cAAY,KAAK;IAA6B;IACpG;GACY,CAAA;EACG,CAAA,EACN,CAAA,CACJ;;AAElB"}
1
+ {"version":3,"file":"FloatingPanel.js","names":[],"sources":["../../src/internal/FloatingPanel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Popover } from '@base-ui/react/popover';\nimport { baseReason, type OpenChangeReason } from './open';\n\nexport interface FloatingPanelProps {\n open: boolean;\n onOpenChange: (open: boolean, reason?: OpenChangeReason) => void;\n /** The element that opens the panel; it must accept a ref (a native element or a component that passes ref on). */\n trigger: React.ReactElement;\n side?: 'top' | 'bottom';\n align?: 'start' | 'center' | 'end';\n sideOffset?: number;\n /** Class of the panel (it carries the look: .ui-datepop, .ui-noti …). */\n className?: string;\n /** Accessible name of the panel. */\n 'aria-label'?: string;\n /** Position against this element instead of the trigger (e.g. the whole field around a calendar button). */\n anchor?: React.RefObject<Element | null>;\n /** Open on hover as well as on press. */\n openOnHover?: boolean;\n /** Keeps the panel inside this element (shifting it sideways, then flipping), not just inside the window: a menu of\n * a table stays over the table instead of covering the panel beside it. */\n boundary?: React.RefObject<Element | null>;\n /** Hover delay before opening, in ms (with openOnHover). Default 0. */\n delay?: number;\n /** Id of the panel, for aria-describedby on the trigger. */\n id?: string;\n /** Move focus into the panel when it opens: true (the first focusable element), false, or a CSS selector of the\n * element to focus inside the panel (the first focusable element when none matches). Default true. */\n focusOnOpen?: boolean | string;\n children: React.ReactNode;\n}\n\n/** A positioned panel next to its trigger: flips when there is no room, closes on Esc and outside press, returns focus. */\nexport function FloatingPanel({\n open,\n onOpenChange,\n trigger,\n side = 'bottom',\n align = 'start',\n sideOffset = 6,\n className,\n openOnHover,\n anchor,\n boundary,\n delay = 0,\n id,\n focusOnOpen = true,\n children,\n ...aria\n}: FloatingPanelProps) {\n const within = boundary?.current ?? undefined;\n const popup = React.useRef<HTMLDivElement>(null);\n const initialFocus =\n focusOnOpen === false ? false : typeof focusOnOpen === 'string' ? () => popup.current?.querySelector<HTMLElement>(focusOnOpen) ?? true : undefined;\n return (\n <Popover.Root open={open} onOpenChange={(next, details) => onOpenChange(next, baseReason(details?.reason))}>\n <Popover.Trigger render={trigger} openOnHover={openOnHover} delay={delay} closeDelay={150} />\n <Popover.Portal>\n {/* Fixed, and no taller than the room left (floating.css): a tall panel scrolls inside itself instead of making the\n document taller than the window (AppShell scrolls its own main area). */}\n <Popover.Positioner\n className=\"ui-float is-panel\"\n positionMethod=\"fixed\"\n side={side}\n align={align}\n sideOffset={sideOffset}\n anchor={anchor}\n collisionBoundary={within}\n collisionPadding={within ? 0 : undefined}\n // Inside a boundary: slid sideways until it fits, rather than swapping its alignment.\n collisionAvoidance={within ? { side: 'flip', align: 'shift' } : undefined}\n >\n <Popover.Popup ref={popup} id={id} className={className} aria-label={aria['aria-label']} initialFocus={initialFocus}>\n {children}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n"],"mappings":";;;;;;;AAkCA,SAAgB,cAAc,EAC5B,MACA,cACA,SACA,OAAO,UACP,QAAQ,SACR,aAAa,GACb,WACA,aACA,QACA,UACA,QAAQ,GACR,IACA,cAAc,MACd,UACA,GAAG,QACkB;CACrB,MAAM,SAAS,UAAU,WAAW,KAAA;CACpC,MAAM,QAAQ,MAAM,OAAuB,IAAI;CAC/C,MAAM,eACJ,gBAAgB,QAAQ,QAAQ,OAAO,gBAAgB,iBAAiB,MAAM,SAAS,cAA2B,WAAW,KAAK,OAAO,KAAA;CAC3I,OACE,qBAAC,QAAQ,MAAT;EAAoB;EAAM,eAAe,MAAM,YAAY,aAAa,MAAM,WAAW,SAAS,MAAM,CAAC;EAAzG,UAAA,CACE,oBAAC,QAAQ,SAAT;GAAiB,QAAQ;GAAsB;GAAoB;GAAO,YAAY;EAAM,CAAA,GAC5F,oBAAC,QAAQ,QAAT,EAAA,UAGE,oBAAC,QAAQ,YAAT;GACE,WAAU;GACV,gBAAe;GACT;GACC;GACK;GACJ;GACR,mBAAmB;GACnB,kBAAkB,SAAS,IAAI,KAAA;GAE/B,oBAAoB,SAAS;IAAE,MAAM;IAAQ,OAAO;GAAQ,IAAI,KAAA;GAEhE,UAAA,oBAAC,QAAQ,OAAT;IAAe,KAAK;IAAW;IAAe;IAAW,cAAY,KAAK;IAA6B;IACpG;GACY,CAAA;EACG,CAAA,EACN,CAAA,CACJ;;AAElB"}
package/dist/styles.css CHANGED
@@ -85,6 +85,10 @@ html.ui-theme-fade * {
85
85
  .ui-link-btn {
86
86
  border: 0;
87
87
  padding: 0;
88
+ /* At least 24 px tall to point at (WCAG 2.5.8) without changing the line: padding grows the box, margin takes it
89
+ back. */
90
+ padding-block: max(0px, calc((24px - 1lh) / 2));
91
+ margin-block: min(0px, calc((1lh - 24px) / 2));
88
92
  background: transparent;
89
93
  color: var(--accent-text);
90
94
  font: inherit;
@@ -2510,8 +2514,8 @@ div.ui-toast[role='status'] {
2510
2514
  }
2511
2515
  .ui-topbar-title {
2512
2516
  margin: 0;
2513
- font-size: var(--text-h4);
2514
- line-height: 28px;
2517
+ font-size: var(--text-h3);
2518
+ line-height: 32px;
2515
2519
  font-weight: 700;
2516
2520
  white-space: nowrap;
2517
2521
  overflow: hidden;
@@ -2596,6 +2600,13 @@ div.ui-toast[role='status'] {
2596
2600
  flex: 0 0 auto;
2597
2601
  margin-left: calc(-1 * var(--space-2));
2598
2602
  }
2603
+ /* Phones: the page title stays 20 px beside the project switcher and search (24 px leaves the title no room). */
2604
+ @media (max-width: 599px) {
2605
+ .ui-topbar-title {
2606
+ font-size: var(--text-h4);
2607
+ line-height: 28px;
2608
+ }
2609
+ }
2599
2610
  .ui-sidenav {
2600
2611
  position: relative;
2601
2612
  box-sizing: border-box;
@@ -2973,7 +2984,7 @@ div.ui-toast[role='status'] {
2973
2984
  .ui-pagehead-title {
2974
2985
  min-width: 0;
2975
2986
  margin: 0;
2976
- font-size: var(--text-h4);
2987
+ font-size: var(--text-h3);
2977
2988
  line-height: 40px;
2978
2989
  font-weight: 700;
2979
2990
  white-space: nowrap;
@@ -3629,11 +3640,11 @@ div.ui-toast[role='status'] {
3629
3640
  --dt-zebra: var(--surface-sub);
3630
3641
  --dt-hover: color-mix(in srgb, var(--surface), var(--ink) 6%);
3631
3642
  }
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). */
3643
+ /* Dark: rows go darker, toward the page ground, not lighter. Text colors are made to read on both the surface and the
3644
+ page ground, so every row between them keeps 4.5:1 for ink-muted and every accent and *-text color. */
3634
3645
  [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%);
3646
+ --dt-zebra: color-mix(in srgb, var(--surface), var(--bg) 30%);
3647
+ --dt-hover: color-mix(in srgb, var(--surface), var(--bg) 60%);
3637
3648
  }
3638
3649
  .ui-dt-caption {
3639
3650
  /* 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 +3974,7 @@ div.ui-toast[role='status'] {
3963
3974
  display: grid;
3964
3975
  align-items: center;
3965
3976
  min-height: 48px;
3966
- border-bottom: 1px solid var(--line);
3977
+ border-bottom: 1px solid var(--line-soft);
3967
3978
  background: var(--dt-row-bg);
3968
3979
  }
3969
3980
  .ui-dt-body .ui-dt-row.is-even {
@@ -3971,6 +3982,8 @@ div.ui-toast[role='status'] {
3971
3982
  }
3972
3983
  .ui-dt-body {
3973
3984
  position: relative;
3985
+ /* Table text 14 px; headings, toolbar and secondary lines keep their own sizes. */
3986
+ font-size: var(--text-compact);
3974
3987
  }
3975
3988
  .ui-dt-body .ui-dt-row {
3976
3989
  transition: background-color 0.12s ease;
@@ -4470,7 +4483,7 @@ div.ui-toast[role='status'] {
4470
4483
  }
4471
4484
  .ui-dt-detail {
4472
4485
  background: var(--surface);
4473
- border-bottom: 1px solid var(--line);
4486
+ border-bottom: 1px solid var(--line-soft);
4474
4487
  }
4475
4488
  .ui-dt-detail.is-even {
4476
4489
  background: var(--dt-zebra);
@@ -4513,8 +4526,9 @@ div.ui-toast[role='status'] {
4513
4526
  .ui-dt-scroller::after {
4514
4527
  display: none;
4515
4528
  }
4516
- /* In a Card the cards' box is the Card itself: no second shadow, a line between the toolbar and the first row. */
4517
- .ui-card .ui-dt-scroll {
4529
+ /* In a Card (or a SettingsSection, also a card) the cards' box is that card: no second shadow, a line between the
4530
+ toolbar and the first row. */
4531
+ :is(.ui-card, .ui-settings-section) .ui-dt-scroll {
4518
4532
  box-shadow: none;
4519
4533
  border-radius: 0;
4520
4534
  }
@@ -4755,6 +4769,13 @@ div.ui-toast[role='status'] {
4755
4769
  color: var(--ink);
4756
4770
  font-weight: 700;
4757
4771
  }
4772
+ /* Phones and touch screens: the tabs are 48 px tall themselves (their ::after is the underline, so the shared touch
4773
+ area in touch.css cannot be used). */
4774
+ @media (max-width: 599px), (pointer: coarse) {
4775
+ .ui-dt-view {
4776
+ height: var(--touch-target);
4777
+ }
4778
+ }
4758
4779
  .ui-dt-view.is-on::after {
4759
4780
  content: '';
4760
4781
  position: absolute;
@@ -6362,7 +6383,7 @@ div.ui-toast[role='status'] {
6362
6383
  flex: 1 1 8em;
6363
6384
  min-width: min(8em, 100%);
6364
6385
  margin: 0;
6365
- font-size: var(--text-title);
6386
+ font-size: var(--text-lead);
6366
6387
  font-weight: 700;
6367
6388
  white-space: nowrap;
6368
6389
  overflow: hidden;
@@ -8555,7 +8576,7 @@ div.ui-toast[role='status'] {
8555
8576
  .ui-sec-title {
8556
8577
  flex: none;
8557
8578
  max-width: 100%;
8558
- font-size: var(--text-h4);
8579
+ font-size: var(--text-lead);
8559
8580
  line-height: 28px;
8560
8581
  font-weight: 700;
8561
8582
  white-space: nowrap;
@@ -8730,8 +8751,8 @@ button.ui-md-link.is-row {
8730
8751
  .ui-md-table th,
8731
8752
  .ui-md-table td {
8732
8753
  padding: 10px 12px;
8733
- border-right: 1px solid var(--line);
8734
- border-bottom: 1px solid var(--line);
8754
+ border-right: 1px solid var(--line-soft);
8755
+ border-bottom: 1px solid var(--line-soft);
8735
8756
  vertical-align: top;
8736
8757
  }
8737
8758
  .ui-md-table th:last-child,
@@ -8857,7 +8878,7 @@ button.ui-md-link.is-row {
8857
8878
  }
8858
8879
  .ui-md-table tr {
8859
8880
  padding: var(--space-2) var(--space-3);
8860
- border-bottom: 1px solid var(--line);
8881
+ border-bottom: 1px solid var(--line-soft);
8861
8882
  }
8862
8883
  .ui-md-table tbody tr:last-child {
8863
8884
  border-bottom: 0;
@@ -10556,6 +10577,10 @@ button.ui-md-link.is-row {
10556
10577
  z-index: var(--z-popover);
10557
10578
  outline: none;
10558
10579
  }
10580
+ .ui-float.is-panel > * {
10581
+ max-height: var(--available-height);
10582
+ overflow-y: auto;
10583
+ }
10559
10584
  .ui-float.is-match > * {
10560
10585
  width: var(--anchor-width);
10561
10586
  box-sizing: border-box;
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,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,OAAO,OAAO,SAAS,CAAC,IAAK,IAAoB;AAC/D;AAEA,SAAS,aAAa,GAAmC;CACvD,IAAI,MAAM,QAAQ,OAAO;CACzB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B;CAChB,iBAAiB;CACjB,IAAI,aAAa,OAAO,OAAO,eAAe,YAAY;CAC1D,YAAY;CACZ,OAAO,WAAW,8BAA8B,CAAC,CAAC,iBAAiB,gBAAgB;EACjF,IAAI,YAAY,MAAM,QAAQ,SAAS,MAAM;CAC/C,CAAC;AACH;;;;;AAMA,SAAgB,OAAO,MAAc,IAAqC;CACxE,IAAI,IAAI,KAAK,KAAK;CAClB,IAAI,oBAAoB,KAAK,CAAC,KAAK,OAAO,aAAa,aAAa,IAAI,iBAAiB,MAAM,SAAS,eAAe,CAAC,CAAC,iBAAiB,OAAO,CAAC;CAClJ,MAAM,MAAM,MAAM,CAAC;CACnB,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO,SAAS,KAAK,SAAS,KAAK,SAAS,KAAK,SAAS,IAAI,YAAY;AAC5E;;AAGA,SAAgB,UAAU,OAAe,KAAa,KAAkD;CACtG,MAAM,IAAI,MAAM,OAAO,QAAQ,QAAQ,MAAM,OAAO;CAEpD,OAAO,QADM,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,CACxC;AACpB;;AAGA,SAAgB,aACd,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,OAAO,OAAO,SAAS,CAAC,IAAK,IAAoB;AAC/D;AAEA,SAAS,aAAa,GAAmC;CACvD,IAAI,MAAM,QAAQ,OAAO;CACzB,OAAO,OAAO,OAAO,eAAe,cAAc,OAAO,WAAW,8BAA8B,CAAC,CAAC,UAAU,SAAS;AACzH;AAEA,IAAI;;;AAIJ,SAAgB,SAAS,GAAuB;CAC9C,IAAI,CAAC,OAAO,GAAG;CACf,MAAM,OAAO,SAAS;CACtB,IAAI,CAAC,QAAQ,GAAG;EACd,KAAK,UAAU,IAAI,eAAe;EAClC,aAAa,SAAS;EACtB,YAAY,iBAAiB,KAAK,UAAU,OAAO,eAAe,GAAG,GAAG;CAC1E;CACA,KAAK,aAAa,cAAc,YAAY,KAAK,aAAa,CAAC,CAAC;CAChE,KAAK,aAAa,sBAAs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,MAAM,MAAM,MAAM,CAAC;CACnB,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO,SAAS,KAAK,SAAS,KAAK,SAAS,KAAK,SAAS,IAAI,YAAY;AAC5E;;AAGA,SAAgB,UAAU,OAAe,KAAa,KAAkD;CACtG,MAAM,IAAI,MAAM,OAAO,QAAQ,QAAQ,MAAM,OAAO;CAEpD,OAAO,QADM,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,CACxC;AACpB;;AAGA,SAAgB,aACd,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"}
package/dist/tokens.css CHANGED
@@ -13,6 +13,7 @@
13
13
  --ink-muted: #6d645a;
14
14
  --line: #e2dfdc;
15
15
  --line-strong: #8c8073;
16
+ --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 不算點選。
package/docs/Graph.md CHANGED
@@ -22,7 +22,7 @@ h('div', { className: 'ui-graph' },
22
22
 
23
23
  - 外層加 `ui-graph`,`<svg>` 裡第一個放 `h(UI.GraphDefs)`,提供箭頭 `url(#ui-arrow)` 和強調色的 `url(#ui-arrow-accent)`。
24
24
  - 線:`<path class="ui-graph-edge">`,1.5 px、`graph-edge` 灰色,直角轉彎(`M x y V … H … V …`)。推測的關係加 `is-inferred`,變成虛線;專案宣告的關係加 `is-declared`,變成長短交替的虛線。圖例 `GraphLegend` 的 `type` 也有 `declared`。
25
- - 方框:`<rect class="ui-graph-node" rx="10">`,名稱用 `<text class="ui-graph-name">`(Geist Mono 13 px)。外部的項目加 `is-external`(虛線外框、不填色),選取的加 `is-selected`。
25
+ - 方框:`<rect class="ui-graph-node" rx="10">`,名稱用 `<text class="ui-graph-name">`(Geist Mono 12 px)。外部的項目加 `is-external`(虛線外框、不填色),選取的加 `is-selected`。
26
26
  - 線上的標籤:`<text class="ui-graph-label">`(12 px 粗體,一般字體)。程式名稱、路徑和數字包在 `<tspan class="ui-graph-code">` 裡,用 Geist Mono,例如「`<tspan class="ui-graph-code">8</tspan> 次呼叫`」。外圍描一圈卡片底色,線從字後面穿過仍看得清楚。放在線的旁邊或轉角附近,不要蓋住箭頭。
27
27
  - 選取時:沒有關係的方框和線包在 `<g class="is-dim">` 裡(方框和線淡到 35%,文字改成 `ink-muted`,仍有 4.5:1,可以閱讀和點選),相關的線加 `is-related`(強調色,箭頭改用 `#ui-arrow-accent`),標籤也加 `is-related`。
28
28
  - 圖例:`<GraphLegend />` 放在圖的下方,預設三項:確定的關係、推測的關係、外部項目。用 `items` 換成專案自己的說法(例如「呼叫」「推測的呼叫」「外部函式」),給 `text` 會變成可以點開說明的 Term。
@@ -26,7 +26,7 @@
26
26
  給「說明」或「導覽」按鈕一個第一次使用的提示:按鈕右上角一個強調色圓點,按鈕左邊一個深色泡泡寫一句話,加上「開始」和 ×。
27
27
 
28
28
  - 圓點 10 px,`accent` 色,外圈 2 px 是按鈕所在的背景色(TopBar 裡是 `surface-chrome`,其他地方是 `bg`),在任何底色上都看得出邊界。
29
- - 泡泡在按鈕左邊、和按鈕同一列(垂直置中),箭頭向右指向按鈕,所以不會蓋到列下方的東西(例如 Workbench 的 `mainBar`);會蓋住同一列左邊的按鈕,直到使用者按「開始」或 ×。泡泡的寬度縮到按鈕左邊的空間,文字換行;左邊不到 180 px 時(很窄的手機,或按鈕在畫面左側)改放在按鈕下方,保持在畫面內。深色底(`ink`)淺色字(`bg`),13 px,寬度最多 320 px。
29
+ - 泡泡在按鈕左邊、和按鈕同一列(垂直置中),箭頭向右指向按鈕,所以不會蓋到列下方的東西(例如 Workbench 的 `mainBar`);會蓋住同一列左邊的按鈕,直到使用者按「開始」或 ×。泡泡的寬度縮到按鈕左邊的空間,文字換行;左邊不到 180 px 時(很窄的手機,或按鈕在畫面左側)改放在按鈕下方,保持在畫面內。深色底(`ink`)淺色字(`bg`),12 px,寬度最多 320 px。
30
30
  - 泡泡是 `role="status"`,按鈕用 `aria-describedby` 指向它:螢幕閱讀器到按鈕時會念出提示。
31
31
  - 圓點和泡泡一直留著,直到使用者按「開始」或 ×;之後傳 `undefined`,提示就消失。記住「已處理」是呼叫端的事:導覽用 `useTour` 的 `tour.hint()` 就會記住。
32
32
  - 取代頁面上「第一次使用」的橫幅。
@@ -28,7 +28,7 @@
28
28
  一段說明裡常常同時出現程式的名稱和它所在的檔案,例如「`VirtualRouter._sync_as` `harness/controller.py:540` 呼叫 …」。這兩種連結用 `look` 換成不同外觀,不再是兩個一樣的灰底底線塊:
29
29
 
30
30
  - `look="name"`:函式、類別、變數,點了跳到定義。強調文字色(`accent-text`)的 Geist Mono,周圍文字的 0.875 倍,沒有底色也沒有底線;滑過或鍵盤焦點時出現 1 px 底線(離文字 3 px),焦點另有和其他控制項一樣的 2 px `focus` 外框。
31
- - `look="location"`:檔案和行號。灰色(`ink-muted`)、13 px(次要文字的大小,比內文小一號),不斷行;滑過或焦點時變強調文字色加底線。空間不夠時(DataTable 的手機卡片,值的那一欄比路徑窄)不超出,改用「…」截斷:先截資料夾,留下檔名和行號(`codemap/…/tshelper.ts:42`),檔名本身也放不下時截在檔名尾端;截斷時滑過、點一下或鍵盤焦點會用 Tooltip 顯示完整路徑,點擊照樣前往連結,螢幕閱讀器念的名稱仍是完整路徑。桌面的表格和句子裡維持原樣。
31
+ - `look="location"`:檔案和行號。灰色(`ink-muted`)、12 px(次要文字的大小,比內文小一號),不斷行;滑過或焦點時變強調文字色加底線。空間不夠時(DataTable 的手機卡片,值的那一欄比路徑窄)不超出,改用「…」截斷:先截資料夾,留下檔名和行號(`codemap/…/tshelper.ts:42`),檔名本身也放不下時截在檔名尾端;截斷時滑過、點一下或鍵盤焦點會用 Tooltip 顯示完整路徑,點擊照樣前往連結,螢幕閱讀器念的名稱仍是完整路徑。桌面的表格和句子裡維持原樣。
32
32
  - 兩種都一定要給 `href` 或 `onClick`,沒有的話 TypeScript 不會編譯:不指向任何地方的文字維持灰底(預設的 `look="chip"`)。
33
33
  - 深色模式下在表格的灰色列(`surface-sub`)上,文字色混入 25% 的 `ink`,對比維持 4.5:1 以上。
34
34
 
@@ -58,7 +58,7 @@ h(UI.CodeText, {
58
58
  });
59
59
  ```
60
60
 
61
- - 看起來像「檔名:行號」或「檔名:起-迄」的片段(`trace.c:321-322`)會變成位置連結(`look="location"`:灰色 13 px,滑過或焦點時變強調色加底線);其他片段是一般的行內程式碼。用 `isRef` 可以改判斷方式。
61
+ - 看起來像「檔名:行號」或「檔名:起-迄」的片段(`trace.c:321-322`)會變成位置連結(`look="location"`:灰色 12 px,滑過或焦點時變強調色加底線);其他片段是一般的行內程式碼。用 `isRef` 可以改判斷方式。
62
62
  - 沒有給 `refHref` 或 `onRef` 時,全部都是一般的行內程式碼。
63
63
 
64
64
  引用連結:
package/docs/KpiCard.md CHANGED
@@ -29,7 +29,7 @@ KPI 卡片,放在 Dashboard 最上方,用 `Grid` 排成一列。本身就是
29
29
 
30
30
  ## 緊湊版(`size="compact"`)
31
31
 
32
- 放進監控畫面頂列的小卡:標籤、22 px 數字、一行 13 px 灰字目標(`target`,例如「目標 ≤ 0.5 °C(示意)」)。不畫迷你折線。在 ConsoleLayout 頂列裡一排小卡一樣寬(放得下時平分,每張至少和內容一樣寬);放在 `Grid` 時填滿格子。
32
+ 放進監控畫面頂列的小卡:標籤、22 px 數字、一行 12 px 灰字目標(`target`,例如「目標 ≤ 0.5 °C(示意)」)。不畫迷你折線。在 ConsoleLayout 頂列裡一排小卡一樣寬(放得下時平分,每張至少和內容一樣寬);放在 `Grid` 時填滿格子。
33
33
 
34
34
  - `verdict: { tone, text }`:判定。`success`(例如「預測準確」)時畫面上只有目標那一行,螢幕閱讀器仍會念判定;`warning`(「偏差變大」)或 `danger`(「需要校正」)時,目標那一行換成那個顏色的半粗字「偏差變大(目標 ≤ 0.5 °C(示意))」。不加符號、不加底色,用文字說出狀態。
35
35
 
@@ -29,7 +29,7 @@
29
29
 
30
30
  ## 細節
31
31
 
32
- - 標題 20 px(`text-h4`)、字重 700,不換行,太長用「…」;標題至少保留 8 個字,操作放不下時換到下一列靠右。
32
+ - 標題 24 px(`text-h3`)、字重 700,不換行,太長用「…」;標題至少保留 8 個字,操作放不下時換到下一列靠右。
33
33
  - 狀態和資訊 14 px(`text-compact`)、`ink-muted`,兩者間隔 16 px。
34
34
  - 頁首和下面的內容間隔照 `Page`(32 px)。
35
35
  - `labels.more` 換「⋯」按鈕的名稱(預設「更多操作」)。