@tristan2828/ui-foundation 4.90.0 → 4.92.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.
@@ -3,38 +3,38 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [Palettes](#palettes) · lines 47–114
7
- - [Glow](#glow) · lines 116–134
8
- - [Semantic tones](#semantic-tones) · lines 136–164
9
- - [The three badge styles](#the-three-badge-styles) · lines 166–183
10
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 185–214
11
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 216–229
12
- - [Logos and brand marks](#logos-and-brand-marks) · lines 231–275
13
- - [Categorical colour](#categorical-colour) · lines 277–347
14
- - [Heat scale](#heat-scale) · lines 349–410
15
- - [Depth ramps](#depth-ramps) · lines 412–490
16
- - [A stored colour](#a-stored-colour) · lines 492–540
17
- - [Shapes and sizes](#shapes-and-sizes) · lines 542–563
18
- - [Typography](#typography) · lines 565–685
19
- - [Written text (notes)](#written-text-notes) · lines 599–685
20
- - [Density](#density) · lines 687–780
21
- - [Rows on this device](#rows-on-this-device) · lines 753–780
22
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 782–896
23
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 898–975
24
- - [Notices](#notices) · lines 977–1005
25
- - [A value over time](#a-value-over-time) · lines 1007–1093
26
- - [Several values over time](#several-values-over-time) · lines 1056–1093
27
- - [A list as a board](#a-list-as-a-board) · lines 1095–1146
28
- - [A list as cards](#a-list-as-cards) · lines 1148–1194
29
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1196–1225
30
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1227–1270
31
- - [An overview page](#an-overview-page) · lines 1272–1335
32
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1336–1374
33
- - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1376–1421
34
- - [Picking at random](#picking-at-random) · lines 1423–1454
35
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1456–1523
36
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1525–1550
37
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1552–1625
6
+ - [Palettes](#palettes) · lines 47–154
7
+ - [Glow](#glow) · lines 156–175
8
+ - [Semantic tones](#semantic-tones) · lines 177–205
9
+ - [The three badge styles](#the-three-badge-styles) · lines 207–224
10
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 226–255
11
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 257–270
12
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 272–316
13
+ - [Categorical colour](#categorical-colour) · lines 318–388
14
+ - [Heat scale](#heat-scale) · lines 390–451
15
+ - [Depth ramps](#depth-ramps) · lines 453–538
16
+ - [A stored colour](#a-stored-colour) · lines 540–588
17
+ - [Shapes and sizes](#shapes-and-sizes) · lines 590–611
18
+ - [Typography](#typography) · lines 613–733
19
+ - [Written text (notes)](#written-text-notes) · lines 647–733
20
+ - [Density](#density) · lines 735–828
21
+ - [Rows on this device](#rows-on-this-device) · lines 801–828
22
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 830–944
23
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 946–1023
24
+ - [Notices](#notices) · lines 1025–1053
25
+ - [A value over time](#a-value-over-time) · lines 1055–1141
26
+ - [Several values over time](#several-values-over-time) · lines 1104–1141
27
+ - [A list as a board](#a-list-as-a-board) · lines 1143–1194
28
+ - [A list as cards](#a-list-as-cards) · lines 1196–1242
29
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1244–1273
30
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1275–1318
31
+ - [An overview page](#an-overview-page) · lines 1320–1383
32
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1384–1422
33
+ - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1424–1469
34
+ - [Picking at random](#picking-at-random) · lines 1471–1502
35
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1504–1571
36
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1573–1598
37
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1600–1673
38
38
 
39
39
  <!-- /index -->
40
40
 
@@ -46,9 +46,9 @@ composites don't grow that way; they are built against a real app's screen.
46
46
 
47
47
  ## Palettes
48
48
 
49
- A palette is an app's own dark look: its surfaces, text, accent and a
50
- second colour, chosen once for every app the foundation serves. There
51
- are four, in the order they were ranked:
49
+ A palette is an app's own look: its surfaces, text, accent and a
50
+ second colour. Four dark ones were chosen once for every app the
51
+ foundation serves, in the order they were ranked:
52
52
 
53
53
  | Name | `palette` | Accent | Second colour |
54
54
  |---|---|---|---|
@@ -57,24 +57,60 @@ are four, in the order they were ranked:
57
57
  | Graphite and Periwinkle | `graphite-periwinkle` | periwinkle on neutral grey | lilac |
58
58
  | Violet | `violet` | violet | magenta |
59
59
 
60
+ And one light one, which an app opts into by name (`LIGHT_PALETTES`):
61
+
62
+ | Name | `palette` | Surface | Text and accent |
63
+ |---|---|---|---|
64
+ | Palm LCD | `palm-lcd` | a Palm OS LCD's green, flat (cards are the same green) | dark ink; ink is also the primary fill and the field border |
65
+
60
66
  **How an app picks one.** `<FoundationProviders palette="indigo-cyan">`
61
67
  names the app's default. Add `palettePicker` and the app shell's header
62
- offers all four (with swatches); the one picked is remembered on that
63
- device, and a new device starts on the default. `usePalette()` reads the
64
- palette on screen. Without `palette`, nothing changes: light and dark
65
- follow the system, with the toggle in the header.
66
-
67
- **A palette is dark only.** With one, the theme is forced dark and the
68
- shell has no light/dark toggle. The light theme stays for apps without a
69
- palette. Printed notes still print light: the print override beats a
70
- palette's block.
68
+ offers the four dark ones (with swatches); the one picked is remembered
69
+ on that device, and a new device starts on the default. `usePalette()`
70
+ reads the palette on screen. Without `palette`, nothing changes: light and
71
+ dark follow the system, with the toggle in the header.
72
+
73
+ **A palette forces its theme.** A dark palette forces the dark theme and
74
+ the shell has no light/dark toggle. The light theme stays for apps
75
+ without a palette, and for Palm LCD. Printed notes still print light:
76
+ the print override beats a palette's block.
77
+
78
+ **Palm LCD is opt-in.** An app gets it only by naming it:
79
+ `<FoundationProviders palette="palm-lcd">`. It forces the light theme, so
80
+ the shell has no toggle. It is never in the picker: `palettePicker` is
81
+ ignored beside it, and so is a palette a device saved before. It has no
82
+ [glow](#glow). Everything is still a semantic token, so the app's code
83
+ uses no raw colours:
84
+
85
+ - **Surfaces.** `--background`, `--card` and `--popover` are the LCD green
86
+ (`#c9d1b2`). `--muted`, `--secondary` and `--accent` are a step darker.
87
+ - **Ink.** `--foreground` is the mockup's ink (`#1d2416`, 10.1:1).
88
+ `--primary` and `--ring` are ink too, with the green on the primary fill,
89
+ as a pressed button looks on the device.
90
+ - **Dimmed text.** `--muted-foreground` is `#464e39`, 5.50:1. The mockup's
91
+ `#5c6650` measured 3.82, under 4.5.
92
+ - **The dotted rules between rows.** The colour is a token: `--rule` and
93
+ `--border` are the LCD's line colour (`#a3ad8f`). The style is the
94
+ app's, a Tailwind border utility: `border-b border-dotted border-rule`.
95
+ A table's own rows wear the colour, solid.
96
+ - **Status text and links.** Status text is a quarter darker than the
97
+ mockup's green, rust and blue, so it still reads on its own tinted wash
98
+ (7.0:1 or more on the green). `--link` is the mockup's blue.
99
+ - **Glyphs and fills.** The light theme's categorical slots, heat steps
100
+ and depth steps were tuned for white, and measure 1.5 to 3 on the
101
+ green. Palm LCD has its own set, each darker than about oklch 0.57, so
102
+ it clears 3:1 on both greens. It keeps the light theme's floors for how
103
+ far apart they must look. Each depth ramp holds its Palm LCD slot's
104
+ hue and gets darker at every step, as in light ([Depth ramps](#depth-ramps)).
105
+ Every heat and depth fill takes white text.
71
106
 
72
107
  **Where it lives.** `styles/theme.css`: each palette's colours as
73
108
  primitives (`--palette-<name>-*`, ratios beside them), and one block per
74
- palette, `.dark[data-palette="<name>"]`, that sets only what differs from
75
- `.dark`. `data-palette` goes on `<html>`, so popups portaled to `<body>`
76
- wear it too. An installed app's colours follow it with
77
- `pwa({ palette })`.
109
+ palette that sets only what differs from its theme:
110
+ `.dark[data-palette="<name>"]` for the four, and `[data-palette="palm-lcd"]`,
111
+ on top of `:root`, for Palm LCD. `data-palette` goes on `<html>`, so popups
112
+ portaled to `<body>` wear it too. An installed app's colours follow it with
113
+ `pwa({ palette })`. For Palm LCD that is the ink and the green.
78
114
 
79
115
  **Why some tokens aren't the guide's colour as written.**
80
116
 
@@ -101,23 +137,28 @@ wear it too. An installed app's colours follow it with
101
137
  palette has, so it is kept as designed; axe doesn't check borders.
102
138
 
103
139
  The package's `e2e/fixtures-visual.spec.ts` runs every primitive,
104
- composite and tone story through axe in each palette, and measures every
105
- glyph, categorical slot and heat step against each palette's page and
106
- card.
140
+ composite and tone story through axe in each palette (Palm LCD in light,
141
+ the others in dark), and measures every glyph, categorical slot, heat
142
+ step and depth step against each palette's page and card.
143
+ `tests/category-slots.test.ts`, `heat-scale.test.ts` and
144
+ `depth-ramps.test.ts` hold Palm LCD's own shades to the light theme's
145
+ floors.
107
146
 
108
147
  **An app's own axe specs** check its palettes instead of light and dark:
109
148
  `defineA11ySuite({ …, palettes: ['indigo-cyan'] })` (and
110
149
  `defineDataEnvironmentBannerSuite`'s `palettes`) saves each as the
111
- device's choice before the page loads and checks it dark. Pass the app's
112
- default on every spec and `PALETTES` on the one that covers the shell.
113
- Without `palettes`, a palette app's light run fails: there is no light
114
- theme to find.
150
+ device's choice before the page loads and checks it in the theme it
151
+ forces: dark, or light for `palettes: ['palm-lcd']`. Pass the app's
152
+ default on every spec and, with the picker, `PALETTES` on the one that
153
+ covers the shell. Without `palettes`, a dark palette app's light run
154
+ fails: there is no light theme to find.
115
155
 
116
156
  ## Glow
117
157
 
118
- Under a palette only, from `--primary` so each palette glows in its own
119
- accent; an app without a palette never gets it. Everything else stays
120
- flat: no glow at the top of the page.
158
+ Under a dark palette only, from `--primary` so each palette glows in its
159
+ own accent. An app without a palette never gets it, and nor does Palm
160
+ LCD, the light one. Everything else stays flat: no glow at the top of the
161
+ page.
121
162
 
122
163
  - **The primary button** (Button's default variant) on hover, keyboard
123
164
  focus and press: one soft layer of the accent (`--primary-glow`: 38px
@@ -432,10 +473,10 @@ and `text-category-N-depth-M-foreground` (text on that cell).
432
473
  - **One ramp per category, its slot's.** A record whose category is slot 3
433
474
  draws its levels from slot 3's ramp, so the depth reads as "more of the
434
475
  same thing". Two categories side by side each keep their own ramp. A
435
- ramp's hue stays within about 20° of its slot's, so a step never reads
436
- as another slot, but steps of two neighbouring slots' ramps can come
437
- close (orange and brown, blue and navy): tell categories apart by their
438
- slot's own glyph and name, not by a ramp step alone.
476
+ ramp has one hue, its slot's, in all five steps and in both themes: only
477
+ lightness and chroma change. Steps of two neighbouring slots' ramps can
478
+ still come close (orange and brown, blue and navy): tell categories apart
479
+ by their slot's own glyph and name, not by a ramp step alone.
439
480
  - **Depth, not amount.** A ramp says "a level of this", never "more of
440
481
  this is worse". A count or a total over many categories is the heat
441
482
  scale; a status is a tone.
@@ -447,16 +488,18 @@ and `text-category-N-depth-M-foreground` (text on that cell).
447
488
  depends on the step and the theme: pair the two as below. It measures
448
489
  4.55:1 at the least.
449
490
  - **Neighbours are closer than the heat scale's, so keep a boundary.**
450
- Neighbouring steps are at least ΔE 17.7 apart in light and 13.9 in
451
- dark (blue's; every slot but blue and navy 17.4 or more), and 10.3
452
- under simulated deuteranopia and protanopia. Five steps of one hue that
453
- each clear 3:1 on the card only have so much lightness to share, dark's
454
- band most of all. A `stroke-card` or a 1px gap between shapes, as a
455
- stacked bar's segments have, makes each boundary easy to see.
456
- - **The order holds without hue.** Each step is darker than the one before
457
- it in both themes, so a ramp also reads in greyscale. In the dark
458
- themes step 1 is near white and step 5 the slot's deepest, still 3:1
459
- on the card.
491
+ Neighbouring steps are at least ΔE 9.6 apart in light and 8.7 in dark,
492
+ and 6.9 under simulated deuteranopia and protanopia. Five steps of one
493
+ hue that each clear 3:1 on the card only have so much lightness to
494
+ share. A `stroke-card` or a 1px gap between shapes, as a stacked bar's
495
+ segments have, makes each boundary easy to see.
496
+ - **Deeper is more contrast with the page.** In light each step is darker
497
+ than the one before it, in the dark themes brighter, so a ramp also
498
+ reads in greyscale. Step 1 is the shallowest, a tint of the hue (lightest
499
+ step still 3:1 on the card), and step 5 the deepest: nearly black in
500
+ light, nearly white in dark, never a grey. No step comes within ΔE 6 of
501
+ the neutral greys (`--muted`, `--muted-foreground`, `--rule`, `--border`,
502
+ `--input`, the charts' greys), so a step never reads as "no value".
460
503
  - **Never colour alone.** Name the level too, in the cell, a tooltip or
461
504
  a legend, and give a shape holding one a name for screen readers.
462
505
  - **Five steps, not more.** Deeper nesting than five shares step 5, or
@@ -483,11 +526,16 @@ The package's fixtures render every ramp (`patterns/DepthRamps`). Its
483
526
  Default story runs through axe and the token check in light and dark, axe
484
527
  in every palette too, and a check that measures every step of every
485
528
  slot, as a fill and as a cell, against the page and a card in each.
486
- `tests/depth-ramps.test.ts` holds the distance between neighbours (17 in
487
- light, 13.5 in dark, 10 with deuteranopia and protanopia), the order of
488
- lightness, text on every fill and every step against every palette's card
489
- and raised surface. `SideBySide` shows both themes at once, under normal
490
- vision and simulated deuteranopia and protanopia.
529
+ `tests/depth-ramps.test.ts` computes from the token values one hue per
530
+ slot, the order of lightness, the distance between neighbours (ΔE 8, and
531
+ 6 with deuteranopia and protanopia), the distance from the neutral greys
532
+ (6), text on every fill and every step against every palette's card and
533
+ raised surface, and fails if a change to `theme.css` breaks one. Palm LCD,
534
+ the light palette, has its own ramps on the same rules (its slot's hue,
535
+ darker at every step, ΔE 6 from its own greys).
536
+ `SideBySide` shows both themes at once, each ramp beside its theme's
537
+ muted greys, under normal vision and simulated deuteranopia and
538
+ protanopia.
491
539
 
492
540
  ## A stored colour
493
541
 
@@ -46,15 +46,15 @@ function CloseMobileSidebarOnNavigate() {
46
46
  }, [key, setOpenMobile]);
47
47
  return null;
48
48
  }
49
- // The header's look control: an app with a palette is always dark, so it
50
- // has no light/dark toggle, and with the picker on it gets the look menu
49
+ // The header's look control: an app with a palette is always dark (or,
50
+ // with a light palette, always light), so it has no light/dark toggle, and with the picker on it gets the look menu
51
51
  // in its place (design-language.md "Palettes"). With the rows picker the
52
52
  // same menu offers the table rows (design-language.md "Density"); an app
53
53
  // without a palette keeps its toggle beside it.
54
54
  function LookControl() {
55
55
  const { palette, picker } = usePalette();
56
56
  const rows = useRows();
57
- const pickPalette = palette && picker ? palette : null;
57
+ const pickPalette = picker && isPaletteName(palette) ? palette : null;
58
58
  return (_jsxs(_Fragment, { children: [!palette && _jsx(ThemeToggle, {}), (pickPalette || rows.picker) && _jsx(LookMenu, { palette: pickPalette })] }));
59
59
  }
60
60
  // Each palette's swatch is its own background with its accent and second
@@ -1,6 +1,6 @@
1
1
  import { type QueryClient } from '@tanstack/react-query';
2
2
  import { type ReactNode } from 'react';
3
- import type { PaletteName } from '../../lib/palettes.js';
3
+ import { type AppPaletteName } from '../../lib/palettes.js';
4
4
  import { type ErrorReportingOptions } from '../../error-reporting/reporter.js';
5
5
  export declare function FoundationProviders({ mockMode, queryClient, errorReporting, palette, palettePicker, rowsPicker, children, }: {
6
6
  /** Whether the API is served by MSW — the app's own IS_MOCK_MODE. */
@@ -17,13 +17,15 @@ export declare function FoundationProviders({ mockMode, queryClient, errorReport
17
17
  /**
18
18
  * The app's palette (design-language.md "Palettes"). With one, the app
19
19
  * is always dark in that palette and the shell has no light/dark
20
- * toggle; printed notes still print light. Without, light and dark
21
- * follow the system, as before.
20
+ * toggle; printed notes still print light. A light palette
21
+ * (`'palm-lcd'`), which an app opts into only here, forces light
22
+ * instead. Without, light and dark follow the system, as before.
22
23
  */
23
- palette?: PaletteName;
24
+ palette?: AppPaletteName;
24
25
  /**
25
26
  * With `palette`: the shell offers all four palettes, and the one picked
26
27
  * is remembered on this device. A new device starts on `palette`.
28
+ * Ignored with a light palette, which is never in the picker.
27
29
  */
28
30
  palettePicker?: boolean;
29
31
  /**
@@ -7,11 +7,12 @@ import { MockModeBanner } from './mock-mode-banner.js';
7
7
  import { ThemeProvider } from '../theme-provider.js';
8
8
  import { PaletteProvider } from './palette-provider.js';
9
9
  import { RowsProvider } from './rows-provider.js';
10
+ import { paletteColorScheme } from '../../lib/palettes.js';
10
11
  import { ErrorReportingProvider } from '../../error-reporting/error-reporting-provider.js';
11
12
  import { resolveErrorReporting } from '../../error-reporting/reporter.js';
12
13
  import { browserStaleChunkReload } from '../../lib/stale-chunk-reload.js';
13
14
  // Everything an app's root needs around its router, in the order that
14
- // works: the theme outermost (and the palette, which forces it dark), the mock-mode banner above the router so it
15
+ // works: the theme outermost (and the palette, which forces it dark, or light for a light one), the mock-mode banner above the router so it
15
16
  // shows on every route (/login included), and AuthProvider inside
16
17
  // QueryClientProvider because it queries /auth/me through TanStack Query.
17
18
  // An app's DataEnvironmentBanner goes first among the children, before its
@@ -22,5 +23,5 @@ export function FoundationProviders({ mockMode, queryClient, errorReporting, pal
22
23
  const [client] = useState(() => queryClient ?? createQueryClient());
23
24
  const reporting = resolveErrorReporting(errorReporting);
24
25
  useEffect(() => browserStaleChunkReload().install(window), []);
25
- return (_jsx(ThemeProvider, { attribute: "class", defaultTheme: "system", enableSystem: true, forcedTheme: palette ? 'dark' : undefined, children: _jsx(PaletteProvider, { palette: palette, picker: palettePicker, children: _jsxs(RowsProvider, { picker: rowsPicker, children: [_jsx(MockModeBanner, { active: mockMode }), _jsx(QueryClientProvider, { client: client, children: _jsx(AuthProvider, { children: reporting ? _jsx(ErrorReportingProvider, { options: reporting, children: children }) : children }) })] }) }) }));
26
+ return (_jsx(ThemeProvider, { attribute: "class", defaultTheme: "system", enableSystem: true, forcedTheme: palette ? paletteColorScheme(palette) : undefined, children: _jsx(PaletteProvider, { palette: palette, picker: palettePicker, children: _jsxs(RowsProvider, { picker: rowsPicker, children: [_jsx(MockModeBanner, { active: mockMode }), _jsx(QueryClientProvider, { client: client, children: _jsx(AuthProvider, { children: reporting ? _jsx(ErrorReportingProvider, { options: reporting, children: children }) : children }) })] }) }) }));
26
27
  }
@@ -1,12 +1,13 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type PaletteName, type PaletteStore } from '../../lib/palettes.js';
2
+ import { type AppPaletteName, type PaletteStore } from '../../lib/palettes.js';
3
3
  /**
4
4
  * Puts the palette on <html>. FoundationProviders renders it; an app
5
5
  * doesn't. Without `palette` it does nothing, and the app keeps light and
6
- * dark.
6
+ * dark. A light palette (`palm-lcd`) takes no picker: the picker's four
7
+ * are dark, so with one `picker` is ignored and the saved choice is too.
7
8
  */
8
- export declare function PaletteProvider({ palette: defaultPalette, picker, store, children, }: {
9
- palette?: PaletteName;
9
+ export declare function PaletteProvider({ palette: defaultPalette, picker: pickerAsked, store, children, }: {
10
+ palette?: AppPaletteName;
10
11
  picker?: boolean;
11
12
  /** For tests; the browser's localStorage by default. */
12
13
  store?: PaletteStore;
@@ -1,14 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';
3
3
  import { PaletteContext } from '../../hooks/use-palette.js';
4
- import { browserPaletteStore, subscribeToBrowserPaletteStore } from '../../lib/palettes.js';
4
+ import { browserPaletteStore, isLightPaletteName, subscribeToBrowserPaletteStore } from '../../lib/palettes.js';
5
5
  /**
6
6
  * Puts the palette on <html>. FoundationProviders renders it; an app
7
7
  * doesn't. Without `palette` it does nothing, and the app keeps light and
8
- * dark.
8
+ * dark. A light palette (`palm-lcd`) takes no picker: the picker's four
9
+ * are dark, so with one `picker` is ignored and the saved choice is too.
9
10
  */
10
- export function PaletteProvider({ palette: defaultPalette, picker = false, store = browserPaletteStore, children, }) {
11
+ export function PaletteProvider({ palette: defaultPalette, picker: pickerAsked = false, store = browserPaletteStore, children, }) {
11
12
  const subscribe = useCallback((listener) => (store === browserPaletteStore ? subscribeToBrowserPaletteStore(listener) : store.subscribe(listener)), [store]);
13
+ const picker = pickerAsked && !isLightPaletteName(defaultPalette);
12
14
  const saved = useSyncExternalStore(subscribe, store.get, () => null);
13
15
  const palette = defaultPalette ? ((picker && saved) || defaultPalette) : null;
14
16
  // Before paint, so the first frame is already in the palette.
@@ -1,12 +1,12 @@
1
- import type { PaletteName } from '../lib/palettes.js';
1
+ import type { AppPaletteName, PaletteName } from '../lib/palettes.js';
2
2
  export type PaletteState = {
3
3
  /** The palette on screen, or null for an app without one (light and dark as the system says). */
4
- palette: PaletteName | null;
4
+ palette: AppPaletteName | null;
5
5
  /** The app's own default. */
6
- defaultPalette: PaletteName | null;
7
- /** Whether this app lets a device pick (FoundationProviders' `palettePicker`). */
6
+ defaultPalette: AppPaletteName | null;
7
+ /** Whether this app lets a device pick (FoundationProviders' `palettePicker`). Never under a light palette. */
8
8
  picker: boolean;
9
- /** Saves `palette` as this device's choice. Does nothing without the picker. */
9
+ /** Saves `palette`, one of the four dark ones, as this device's choice. Does nothing without the picker. */
10
10
  setPalette: (palette: PaletteName) => void;
11
11
  };
12
12
  export declare const PaletteContext: import("react").Context<PaletteState>;
package/dist/index.d.ts CHANGED
@@ -115,7 +115,7 @@ export { useSessionClock, type SessionClock, type SessionClockOptions, type Sess
115
115
  export { usePrefersReducedMotion } from './hooks/use-prefers-reduced-motion.js';
116
116
  export { useMuted } from './hooks/use-muted.js';
117
117
  export { usePalette, type PaletteState } from './hooks/use-palette.js';
118
- export { PALETTE_LABELS, PALETTE_STORAGE_KEY, PALETTES, isPaletteName, type PaletteName } from './lib/palettes.js';
118
+ export { LIGHT_PALETTE_LABELS, LIGHT_PALETTES, PALETTE_LABELS, PALETTE_STORAGE_KEY, PALETTES, isLightPaletteName, isPaletteName, paletteColorScheme, type AppPaletteName, type LightPaletteName, type PaletteName, } from './lib/palettes.js';
119
119
  export { useRows, type RowsState } from './hooks/use-rows.js';
120
120
  export { ROWS, ROWS_LABELS, ROWS_STORAGE_KEY, isRowsName, type RowsName } from './lib/rows.js';
121
121
  export { createPushController, usePushPermission, type PushController, type PushControllerOptions, type PushEnvironment, type PushPermission, type PushStatus, } from './hooks/use-push-permission.js';
package/dist/index.js CHANGED
@@ -119,7 +119,7 @@ export { useSessionClock, } from './hooks/use-session-clock.js';
119
119
  export { usePrefersReducedMotion } from './hooks/use-prefers-reduced-motion.js';
120
120
  export { useMuted } from './hooks/use-muted.js';
121
121
  export { usePalette } from './hooks/use-palette.js';
122
- export { PALETTE_LABELS, PALETTE_STORAGE_KEY, PALETTES, isPaletteName } from './lib/palettes.js';
122
+ export { LIGHT_PALETTE_LABELS, LIGHT_PALETTES, PALETTE_LABELS, PALETTE_STORAGE_KEY, PALETTES, isLightPaletteName, isPaletteName, paletteColorScheme, } from './lib/palettes.js';
123
123
  export { useRows } from './hooks/use-rows.js';
124
124
  export { ROWS, ROWS_LABELS, ROWS_STORAGE_KEY, isRowsName } from './lib/rows.js';
125
125
  export { createPushController, usePushPermission, } from './hooks/use-push-permission.js';
@@ -6,6 +6,16 @@ export declare const PALETTE_LABELS: Record<PaletteName, string>;
6
6
  /** Where a device's chosen palette is kept. */
7
7
  export declare const PALETTE_STORAGE_KEY = "ui-foundation:palette";
8
8
  export declare function isPaletteName(value: unknown): value is PaletteName;
9
+ /** The light palettes, which an app opts into by name: never in the picker (design-language.md "Palettes"). */
10
+ export declare const LIGHT_PALETTES: readonly ["palm-lcd"];
11
+ export type LightPaletteName = (typeof LIGHT_PALETTES)[number];
12
+ /** Each light palette's name as a person reads it. */
13
+ export declare const LIGHT_PALETTE_LABELS: Record<LightPaletteName, string>;
14
+ /** Any palette an app can name: one of the four dark ones, or a light one. */
15
+ export type AppPaletteName = PaletteName | LightPaletteName;
16
+ export declare function isLightPaletteName(value: unknown): value is LightPaletteName;
17
+ /** The theme a palette forces: light for a light palette, dark for the four. */
18
+ export declare function paletteColorScheme(palette: AppPaletteName): 'light' | 'dark';
9
19
  export type PaletteStore = DeviceChoiceStore<PaletteName>;
10
20
  /** The store under usePalette, taking the storage so its rules are unit tested (tests/palettes.test.ts). */
11
21
  export declare function createPaletteStore(getStorage: () => StorageLike | undefined): PaletteStore;
@@ -6,6 +6,11 @@
6
6
  // palette rides on <html> as data-palette, so popups portaled to <body>
7
7
  // wear it too, and styles/theme.css's `.dark[data-palette]` blocks do the
8
8
  // rest (components/app/palette-provider.tsx, hooks/use-palette.ts).
9
+ //
10
+ // The light palettes (LIGHT_PALETTES, so far one: Palm LCD) are opt-in: an
11
+ // app gets one only by naming it as `palette`. It forces the light theme,
12
+ // it is never in the picker, and it has no glow. Its block is
13
+ // `[data-palette="<name>"]` on top of :root.
9
14
  import { browserStorage, createDeviceChoiceStore, otherTabsSubscriber } from './device-choice.js';
10
15
  export const PALETTES = ['indigo-cyan', 'indigo-rose', 'graphite-periwinkle', 'violet'];
11
16
  /** Each palette's name as a person reads it, in the guide's ranked order. */
@@ -20,6 +25,19 @@ export const PALETTE_STORAGE_KEY = 'ui-foundation:palette';
20
25
  export function isPaletteName(value) {
21
26
  return typeof value === 'string' && PALETTES.includes(value);
22
27
  }
28
+ /** The light palettes, which an app opts into by name: never in the picker (design-language.md "Palettes"). */
29
+ export const LIGHT_PALETTES = ['palm-lcd'];
30
+ /** Each light palette's name as a person reads it. */
31
+ export const LIGHT_PALETTE_LABELS = {
32
+ 'palm-lcd': 'Palm LCD',
33
+ };
34
+ export function isLightPaletteName(value) {
35
+ return typeof value === 'string' && LIGHT_PALETTES.includes(value);
36
+ }
37
+ /** The theme a palette forces: light for a light palette, dark for the four. */
38
+ export function paletteColorScheme(palette) {
39
+ return isLightPaletteName(palette) ? 'light' : 'dark';
40
+ }
23
41
  /** The store under usePalette, taking the storage so its rules are unit tested (tests/palettes.test.ts). */
24
42
  export function createPaletteStore(getStorage) {
25
43
  return createDeviceChoiceStore(PALETTE_STORAGE_KEY, isPaletteName, getStorage);
@@ -1,6 +1,6 @@
1
1
  import { expect, type Page } from '@playwright/test';
2
2
  import { type NavEntry } from '../components/app/app-shell-nav.js';
3
- import { type PaletteName } from '../lib/palettes.js';
3
+ import { type AppPaletteName } from '../lib/palettes.js';
4
4
  import type { MswOverride } from '../mocks/override.js';
5
5
  export type { MswHandle, MswOverride } from '../mocks/override.js';
6
6
  export { expect };
@@ -83,12 +83,14 @@ export type A11ySuiteOptions = {
83
83
  */
84
84
  checkSidebar?: boolean;
85
85
  /**
86
- * For an app with a palette (`<FoundationProviders palette>`), which is
87
- * dark only: the palettes to check instead of light and dark, each saved
88
- * as the device's choice before the page loads. Pass the app's default on
89
- * every spec and all of `PALETTES` on one (the shell's).
86
+ * For an app with a palette (`<FoundationProviders palette>`), which
87
+ * forces its theme: the palettes to check instead of light and dark, each
88
+ * saved as the device's choice before the page loads and checked in the
89
+ * theme it forces (dark, or light for `'palm-lcd'`). Pass the app's
90
+ * default on every spec and, with the picker, all of `PALETTES` on one
91
+ * (the shell's).
90
92
  */
91
- palettes?: readonly PaletteName[];
93
+ palettes?: readonly AppPaletteName[];
92
94
  };
93
95
  /**
94
96
  * Every data view on the page has loaded: at least one shows its data (or,
@@ -119,7 +121,7 @@ export declare function expectDataViewsLoaded(page: Page, { success }?: {
119
121
  * color-contrast rule against the rendered dark DOM is also what keeps the
120
122
  * dark-mode tokens readable. The theme follows the OS setting, so
121
123
  * emulateMedia switches it. An app with a palette passes `palettes`, and
122
- * each is checked (dark) in place of light and dark.
124
+ * each is checked (in the theme it forces) in place of light and dark.
123
125
  */
124
126
  export declare function defineA11ySuite({ formRoutes, viewRoutes, loggedOutRoutes, nav, checkSidebar, palettes, }: A11ySuiteOptions): void;
125
127
  export type MockModeBannerSuiteOptions = {
@@ -154,7 +156,7 @@ export type DataEnvironmentBannerSuiteOptions = {
154
156
  */
155
157
  dataLabel?: string | null;
156
158
  /** For an app with a palette: the palettes to check the banner in, in place of light and dark (as for `defineA11ySuite`). */
157
- palettes?: readonly PaletteName[];
159
+ palettes?: readonly AppPaletteName[];
158
160
  };
159
161
  /**
160
162
  * DataEnvironmentBanner: shown on every route, logged-out ones included,
@@ -14,7 +14,7 @@
14
14
  import AxeBuilder from '@axe-core/playwright';
15
15
  import { expect, test as base } from '@playwright/test';
16
16
  import { navPathname, navTargets } from '../components/app/app-shell-nav.js';
17
- import { PALETTE_STORAGE_KEY } from '../lib/palettes.js';
17
+ import { PALETTE_STORAGE_KEY, paletteColorScheme } from '../lib/palettes.js';
18
18
  export { expect };
19
19
  // A page load returns at the load event, but the app isn't up yet: React
20
20
  // renders only after MSW's worker.start(), which took up to 2.4 s past
@@ -177,7 +177,7 @@ async function navRoutes(page, isMobile) {
177
177
  const pagePaths = (routes) => [...new Set(routes.map(navPathname))].sort();
178
178
  function a11yThemes(palettes) {
179
179
  if (palettes?.length)
180
- return palettes.map((palette) => ({ label: palette, colorScheme: 'dark', palette }));
180
+ return palettes.map((palette) => ({ label: palette, colorScheme: paletteColorScheme(palette), palette }));
181
181
  return [
182
182
  { label: 'light', colorScheme: 'light' },
183
183
  { label: 'dark', colorScheme: 'dark' },
@@ -249,7 +249,7 @@ async function expectNavPageAccessible(page, route, theme) {
249
249
  * color-contrast rule against the rendered dark DOM is also what keeps the
250
250
  * dark-mode tokens readable. The theme follows the OS setting, so
251
251
  * emulateMedia switches it. An app with a palette passes `palettes`, and
252
- * each is checked (dark) in place of light and dark.
252
+ * each is checked (in the theme it forces) in place of light and dark.
253
253
  */
254
254
  export function defineA11ySuite({ formRoutes, viewRoutes = [], loggedOutRoutes = [], nav, checkSidebar = true, palettes, }) {
255
255
  // Each `to` as given, query string and all, so a page that opens on a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.90.0",
3
+ "version": "4.92.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/styles/index.css CHANGED
@@ -20,10 +20,11 @@
20
20
  composite's own rows and padding tighten under data-density="compact"
21
21
  on any ancestor, the way the table's tokens do. `density-compact:py-1`.
22
22
  Text never shrinks under it. */
23
- /* Under a palette only (FoundationProviders' `palette`, data-palette on
24
- <html>): the shared style guide's glow, which an app without one never
25
- gets. `palette:hover:shadow-(--primary-glow)`. */
26
- @custom-variant palette (&:where([data-palette] *));
23
+ /* Under a dark palette only (FoundationProviders' `palette`, data-palette
24
+ on <html>, with the dark theme it forces): the shared style guide's
25
+ glow, which an app without one never gets, and nor does Palm LCD, the
26
+ light palette. `palette:hover:shadow-(--primary-glow)`. */
27
+ @custom-variant palette (&:where(.dark[data-palette] *));
27
28
 
28
29
  @custom-variant density-compact (&:where([data-density="compact"], [data-density="compact"] *));
29
30
 
@@ -291,7 +292,7 @@
291
292
  font-weight: var(--type-heading-3-weight);
292
293
  }
293
294
 
294
- /* A hovered hub tile, widget or card, under a palette: its edge turns the
295
+ /* A hovered hub tile, widget or card, under a dark palette: its edge turns the
295
296
  accent and a soft halo of it shows (--edge-glow). On an element that
296
297
  draws its edge with ring-1 and its shadow with shadow-* (Card does), it
297
298
  recolours the ring and adds the halo to the shadow it already has.
@@ -302,21 +303,21 @@
302
303
  transition-property: box-shadow;
303
304
  transition-duration: var(--default-transition-duration);
304
305
  transition-timing-function: var(--default-transition-timing-function);
305
- &:where([data-palette] *):hover {
306
+ &:where(.dark[data-palette] *):hover {
306
307
  --tw-ring-color: color-mix(in srgb, var(--primary) 75%, var(--border));
307
308
  --tw-shadow: var(--card-shadow, 0 0 #0000), var(--edge-glow);
308
309
  }
309
310
  }
310
311
 
311
- /* A primary button's shine under a palette: a light band sweeping across
312
+ /* A primary button's shine under a dark palette: a light band sweeping across
312
313
  on hover (650ms), once. Not under reduced motion, and never on another
313
314
  variant. In components, so a button's own position utility still wins. */
314
315
  @layer components {
315
- [data-palette] [data-slot="button"][data-variant="default"] {
316
+ .dark[data-palette] [data-slot="button"][data-variant="default"] {
316
317
  position: relative;
317
318
  overflow: hidden;
318
319
  }
319
- [data-palette] [data-slot="button"][data-variant="default"]::after {
320
+ .dark[data-palette] [data-slot="button"][data-variant="default"]::after {
320
321
  content: "";
321
322
  position: absolute;
322
323
  inset: 0;
@@ -325,7 +326,7 @@
325
326
  transform: translateX(-130%);
326
327
  }
327
328
  @media (prefers-reduced-motion: no-preference) {
328
- [data-palette] [data-slot="button"][data-variant="default"]:hover::after {
329
+ .dark[data-palette] [data-slot="button"][data-variant="default"]:hover::after {
329
330
  animation: button-shine 650ms ease-out;
330
331
  }
331
332
  }