@tristan2828/ui-foundation 4.156.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conventions/docs/cell-patterns.md +27 -24
- package/conventions/docs/design-language.md +69 -62
- package/dist/components/app/app-shell.js +2 -2
- package/dist/components/app/look-settings.js +2 -2
- package/dist/components/app/milkdown-editor.js +16 -3
- package/dist/components/app/notes-outline.d.ts +7 -2
- package/dist/components/app/notes-outline.js +14 -6
- package/dist/components/app/rich-text-fold.d.ts +4 -1
- package/dist/components/app/rich-text-fold.js +59 -21
- package/dist/hooks/fold-store.d.ts +19 -0
- package/dist/hooks/fold-store.js +41 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/lib/markdown-fold.d.ts +6 -2
- package/dist/lib/palettes.d.ts +9 -2
- package/dist/lib/palettes.js +14 -8
- package/package.json +1 -1
- package/styles/theme.css +124 -239
- package/vite/index.d.ts +1 -1
- package/vite/pwa.js +8 -2
|
@@ -26,26 +26,26 @@
|
|
|
26
26
|
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 636–715
|
|
27
27
|
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 717–758
|
|
28
28
|
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 760–832
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines 834–
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 834–1705
|
|
30
30
|
- [Presets: one line per field](#presets-one-line-per-field) · lines 1240–1312
|
|
31
31
|
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1314–1350
|
|
32
32
|
- [A link and its label](#a-link-and-its-label) · lines 1352–1376
|
|
33
33
|
- [A list of sub-items](#a-list-of-sub-items) · lines 1378–1511
|
|
34
|
-
- [On a page of the app's own: `EditInPlaceScope`](#on-a-page-of-the-apps-own-editinplacescope) · lines 1513–
|
|
35
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
36
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
37
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
38
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
39
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
40
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
41
|
-
- [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
42
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
43
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
44
|
-
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines
|
|
45
|
-
- [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines
|
|
46
|
-
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines
|
|
47
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
48
|
-
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines
|
|
34
|
+
- [On a page of the app's own: `EditInPlaceScope`](#on-a-page-of-the-apps-own-editinplacescope) · lines 1513–1622
|
|
35
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1624–1698
|
|
36
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1700–1705
|
|
37
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1707–1773
|
|
38
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1775–1829
|
|
39
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1831–1913
|
|
40
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1915–1940
|
|
41
|
+
- [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines 1942–1975
|
|
42
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1977–2028
|
|
43
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 2030–2104
|
|
44
|
+
- [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2050–2104
|
|
45
|
+
- [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2106–2318
|
|
46
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2267–2318
|
|
47
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2320–2354
|
|
48
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2356–2403
|
|
49
49
|
|
|
50
50
|
<!-- /index -->
|
|
51
51
|
|
|
@@ -1556,14 +1556,17 @@ const body = editInPlace<string>({
|
|
|
1556
1556
|
router's updates to `flushSync`. With the other, the hidden tab is
|
|
1557
1557
|
still in front for a moment, and a key typed right after the switch
|
|
1558
1558
|
goes into it.
|
|
1559
|
-
- **An outline beside a long note** is `NotesOutline`, given the
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1559
|
+
- **An outline beside a long note** is `NotesOutline`, given the
|
|
1560
|
+
editor's `foldKey`: its headings as a list to jump with (each opens
|
|
1561
|
+
its section and brings it into view), with Fold All and Open All. Put
|
|
1562
|
+
it beside the editor (in a rail, or above the note on a phone). It
|
|
1563
|
+
needs no `markdown`: it lists the headings of the mounted editor with
|
|
1564
|
+
that key, a frame after one is added, renamed or toggled, and parses
|
|
1565
|
+
nothing, so typing in a paragraph and saving never touch it. Beside
|
|
1566
|
+
`<Markdown>`, or for the moment before the editor is up, pass
|
|
1567
|
+
`markdown` and it reads that instead. An app that draws its own list
|
|
1568
|
+
reads the same headings with `useFoldHeadings(foldKey)` (`null` with
|
|
1569
|
+
no editor under the key).
|
|
1567
1570
|
- **An editor that is the page** (a note the app opens on) takes
|
|
1568
1571
|
`autoFocus="end"`, the caret after its last words, in view, and
|
|
1569
1572
|
`tabStaysInText`: Tab on a plain line stays in the text (Esc, then
|
|
@@ -3,51 +3,51 @@
|
|
|
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 60–
|
|
7
|
-
- [Glow](#glow) · lines
|
|
8
|
-
- [Semantic tones](#semantic-tones) · lines
|
|
9
|
-
- [The three badge styles](#the-three-badge-styles) · lines
|
|
10
|
-
- [Status marks](#status-marks) · lines
|
|
11
|
-
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines
|
|
12
|
-
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines
|
|
13
|
-
- [Logos and brand marks](#logos-and-brand-marks) · lines
|
|
14
|
-
- [Emoji](#emoji) · lines
|
|
15
|
-
- [Categorical colour](#categorical-colour) · lines
|
|
16
|
-
- [Heat scale](#heat-scale) · lines
|
|
17
|
-
- [Depth ramps](#depth-ramps) · lines
|
|
18
|
-
- [A stored colour](#a-stored-colour) · lines
|
|
19
|
-
- [Shapes and sizes](#shapes-and-sizes) · lines
|
|
20
|
-
- [Typography](#typography) · lines
|
|
21
|
-
- [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines
|
|
22
|
-
- [Written text (notes)](#written-text-notes) · lines
|
|
23
|
-
- [Density](#density) · lines
|
|
24
|
-
- [Rows on this device](#rows-on-this-device) · lines
|
|
25
|
-
- [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines
|
|
26
|
-
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines
|
|
27
|
-
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines
|
|
28
|
-
- [Notices](#notices) · lines
|
|
29
|
-
- [A value over time](#a-value-over-time) · lines
|
|
30
|
-
- [Several values over time](#several-values-over-time) · lines
|
|
31
|
-
- [Parts of a whole over time](#parts-of-a-whole-over-time) · lines
|
|
32
|
-
- [A list as a board](#a-list-as-a-board) · lines
|
|
33
|
-
- [Order, groups and the header](#order-groups-and-the-header) · lines
|
|
34
|
-
- [A list as cards](#a-list-as-cards) · lines
|
|
35
|
-
- [Images full screen](#images-full-screen) · lines
|
|
36
|
-
- [Key numbers on a record](#key-numbers-on-a-record) · lines
|
|
37
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines
|
|
38
|
-
- [A few equal things](#a-few-equal-things) · lines
|
|
39
|
-
- [An overview page](#an-overview-page) · lines
|
|
40
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines
|
|
41
|
-
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines
|
|
42
|
-
- [Picking at random](#picking-at-random) · lines
|
|
43
|
-
- [Filling in what's missing](#filling-in-whats-missing) · lines
|
|
44
|
-
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines
|
|
45
|
-
- [A quick add line](#a-quick-add-line) · lines
|
|
46
|
-
- [A date field's quick picks](#a-date-fields-quick-picks) · lines
|
|
47
|
-
- [A few choices, then the month](#a-few-choices-then-the-month) · lines
|
|
48
|
-
- [A month calendar](#a-month-calendar) · lines
|
|
49
|
-
- [A settings page](#a-settings-page) · lines
|
|
50
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines
|
|
6
|
+
- [Palettes](#palettes) · lines 60–150
|
|
7
|
+
- [Glow](#glow) · lines 152–171
|
|
8
|
+
- [Semantic tones](#semantic-tones) · lines 173–201
|
|
9
|
+
- [The three badge styles](#the-three-badge-styles) · lines 203–220
|
|
10
|
+
- [Status marks](#status-marks) · lines 222–265
|
|
11
|
+
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 267–296
|
|
12
|
+
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 298–309
|
|
13
|
+
- [Logos and brand marks](#logos-and-brand-marks) · lines 311–351
|
|
14
|
+
- [Emoji](#emoji) · lines 353–393
|
|
15
|
+
- [Categorical colour](#categorical-colour) · lines 395–460
|
|
16
|
+
- [Heat scale](#heat-scale) · lines 462–514
|
|
17
|
+
- [Depth ramps](#depth-ramps) · lines 516–583
|
|
18
|
+
- [A stored colour](#a-stored-colour) · lines 585–632
|
|
19
|
+
- [Shapes and sizes](#shapes-and-sizes) · lines 634–655
|
|
20
|
+
- [Typography](#typography) · lines 657–827
|
|
21
|
+
- [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 691–723
|
|
22
|
+
- [Written text (notes)](#written-text-notes) · lines 725–827
|
|
23
|
+
- [Density](#density) · lines 829–958
|
|
24
|
+
- [Rows on this device](#rows-on-this-device) · lines 902–930
|
|
25
|
+
- [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 932–958
|
|
26
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 960–1077
|
|
27
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1079–1151
|
|
28
|
+
- [Notices](#notices) · lines 1153–1180
|
|
29
|
+
- [A value over time](#a-value-over-time) · lines 1182–1312
|
|
30
|
+
- [Several values over time](#several-values-over-time) · lines 1231–1269
|
|
31
|
+
- [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1271–1312
|
|
32
|
+
- [A list as a board](#a-list-as-a-board) · lines 1314–1424
|
|
33
|
+
- [Order, groups and the header](#order-groups-and-the-header) · lines 1367–1424
|
|
34
|
+
- [A list as cards](#a-list-as-cards) · lines 1426–1473
|
|
35
|
+
- [Images full screen](#images-full-screen) · lines 1475–1521
|
|
36
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1523–1559
|
|
37
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1561–1597
|
|
38
|
+
- [A few equal things](#a-few-equal-things) · lines 1599–1714
|
|
39
|
+
- [An overview page](#an-overview-page) · lines 1716–1781
|
|
40
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1783–1846
|
|
41
|
+
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1848–1935
|
|
42
|
+
- [Picking at random](#picking-at-random) · lines 1937–1968
|
|
43
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1970–2037
|
|
44
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2039–2058
|
|
45
|
+
- [A quick add line](#a-quick-add-line) · lines 2060–2088
|
|
46
|
+
- [A date field's quick picks](#a-date-fields-quick-picks) · lines 2090–2114
|
|
47
|
+
- [A few choices, then the month](#a-few-choices-then-the-month) · lines 2116–2142
|
|
48
|
+
- [A month calendar](#a-month-calendar) · lines 2144–2176
|
|
49
|
+
- [A settings page](#a-settings-page) · lines 2178–2235
|
|
50
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2237–2296
|
|
51
51
|
|
|
52
52
|
<!-- /index -->
|
|
53
53
|
|
|
@@ -60,14 +60,20 @@ composites don't grow that way; they are built against a real app's screen.
|
|
|
60
60
|
## Palettes
|
|
61
61
|
|
|
62
62
|
A palette is an app's own look: its surfaces, text, accent and a
|
|
63
|
-
second colour. Four dark ones serve every app:
|
|
63
|
+
second colour. Four dark ones serve every app. They are all graphite:
|
|
64
|
+
the same neutral grey surfaces, text and borders, each with its own main
|
|
65
|
+
colour (the accent, its light and deep shades, the text on it, and a
|
|
66
|
+
second colour):
|
|
64
67
|
|
|
65
68
|
| Name | `palette` | Accent | Second colour |
|
|
66
69
|
|---|---|---|---|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
| Graphite and
|
|
70
|
-
|
|
|
70
|
+
| Graphite and Periwinkle | `graphite-periwinkle` | periwinkle | lilac |
|
|
71
|
+
| Graphite and Amber | `graphite-amber` | amber | orange |
|
|
72
|
+
| Graphite and Sky | `graphite-sky` | sky blue | periwinkle blue |
|
|
73
|
+
| Graphite and Green | `graphite-green` | green | olive |
|
|
74
|
+
|
|
75
|
+
Amber, Sky and Green have Periwinkle's lightness and strength, at their
|
|
76
|
+
own hue, so each reads as loud as the others.
|
|
71
77
|
|
|
72
78
|
And one light one, which an app opts into by name (`LIGHT_PALETTES`):
|
|
73
79
|
|
|
@@ -75,7 +81,7 @@ And one light one, which an app opts into by name (`LIGHT_PALETTES`):
|
|
|
75
81
|
|---|---|---|---|
|
|
76
82
|
| 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 |
|
|
77
83
|
|
|
78
|
-
**How an app picks one.** `<FoundationProviders palette="
|
|
84
|
+
**How an app picks one.** `<FoundationProviders palette="graphite-periwinkle">`
|
|
79
85
|
names the app's default. Add `palettePicker` and the app shell's header
|
|
80
86
|
offers the four dark ones (with swatches), or a page does, as tiles
|
|
81
87
|
(`PaletteSetting`, "A settings page"); the one picked is remembered
|
|
@@ -113,28 +119,29 @@ uses no raw colours:
|
|
|
113
119
|
in light ([Depth ramps](#depth-ramps)). Every heat and depth fill
|
|
114
120
|
takes white text.
|
|
115
121
|
|
|
116
|
-
**Where it lives.** `styles/theme.css`:
|
|
117
|
-
|
|
118
|
-
palette
|
|
119
|
-
`.dark[data-palette
|
|
120
|
-
|
|
122
|
+
**Where it lives.** `styles/theme.css`: the shared greys as primitives
|
|
123
|
+
(`--palette-graphite-*`), each palette's main colour as five more
|
|
124
|
+
(`--palette-<name>-*`), with ratios beside them. One block,
|
|
125
|
+
`.dark[data-palette^="graphite-"]`, maps them onto the tokens; each
|
|
126
|
+
palette's own block, `.dark[data-palette="<name>"]`, only names its main
|
|
127
|
+
colour. `[data-palette="palm-lcd"]`, on top of `:root`, is Palm LCD's. `data-palette` goes on `<html>`, so popups
|
|
121
128
|
portaled to `<body>` wear it too. An installed app's colours follow it with
|
|
122
129
|
`pwa({ palette })`. For Palm LCD that is the ink and the green.
|
|
123
130
|
|
|
124
131
|
**The accent is never small text.** It fails 4.5:1 as small text on
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
Links are accent light (`--link`,
|
|
132
|
+
every palette's cards (4.3 to 4.9): it is the ring, the primary fill and
|
|
133
|
+
the active item's tint.
|
|
134
|
+
Links are accent light (`--link`, 9.1:1 or more on cards; the `link` Button
|
|
128
135
|
variant is `text-link`), and so is the theme colour as text
|
|
129
136
|
(`--primary-text`: the open tab's name, a picked choice's word). The
|
|
130
137
|
status colours as text are `--success-text`, `--warning-text` and
|
|
131
138
|
`--destructive-text` (soft badges, icons, coloured words); solid fills
|
|
132
139
|
keep the deeper shades with white text. Field borders (`--input`)
|
|
133
|
-
measure 2.
|
|
140
|
+
measure 2.9 against the page, under 3:1; axe doesn't check
|
|
134
141
|
borders.
|
|
135
142
|
|
|
136
143
|
**An app's own axe specs** check its palettes instead of light and dark:
|
|
137
|
-
`defineA11ySuite({ …, palettes: ['
|
|
144
|
+
`defineA11ySuite({ …, palettes: ['graphite-periwinkle'] })` (and
|
|
138
145
|
`defineDataEnvironmentBannerSuite`'s `palettes`) saves each as the
|
|
139
146
|
device's choice before the page loads and checks it in the theme it
|
|
140
147
|
forces: dark, or light for `palettes: ['palm-lcd']`. Pass the app's
|
|
@@ -901,7 +908,7 @@ toggle in an app without a palette). `RowsSetting` offers the same choice
|
|
|
901
908
|
on a page ("A settings page").
|
|
902
909
|
|
|
903
910
|
```tsx
|
|
904
|
-
<FoundationProviders palette="
|
|
911
|
+
<FoundationProviders palette="graphite-periwinkle" palettePicker rowsPicker …>
|
|
905
912
|
```
|
|
906
913
|
|
|
907
914
|
| Rows | Table cell padding (vertical) | Header height |
|
|
@@ -17,7 +17,7 @@ import { useShellDocumentTitle } from '../../hooks/use-document-title.js';
|
|
|
17
17
|
import { usePalette } from '../../hooks/use-palette.js';
|
|
18
18
|
import { useRows } from '../../hooks/use-rows.js';
|
|
19
19
|
import { clearRecentRecords } from '../../lib/search-palette.js';
|
|
20
|
-
import { isPaletteName, PALETTE_LABELS, PALETTES } from '../../lib/palettes.js';
|
|
20
|
+
import { isPaletteName, PALETTE_LABELS, paletteColour, PALETTES } from '../../lib/palettes.js';
|
|
21
21
|
import { isRowsName, ROWS, ROWS_LABELS } from '../../lib/rows.js';
|
|
22
22
|
import { cn } from 'cn';
|
|
23
23
|
import { Button, buttonVariants } from '../ui/button.js';
|
|
@@ -63,7 +63,7 @@ function LookControl({ menu }) {
|
|
|
63
63
|
// colour on it, read from the palette primitives, so the menu shows all
|
|
64
64
|
// four whichever is on screen.
|
|
65
65
|
function PaletteSwatch({ name }) {
|
|
66
|
-
const colour = (part) =>
|
|
66
|
+
const colour = (part) => paletteColour(name, part);
|
|
67
67
|
return (_jsxs("span", { "aria-hidden": true, className: "flex h-4 w-7 shrink-0 items-center justify-center gap-0.5 rounded-sm border border-border", style: { background: colour('background') }, children: [_jsx("span", { className: "size-2 rounded-full", style: { background: colour('accent') } }), _jsx("span", { className: "size-2 rounded-full", style: { background: colour('second') } })] }));
|
|
68
68
|
}
|
|
69
69
|
// `palette` is null when only the rows are offered: the trigger is then
|
|
@@ -3,7 +3,7 @@ import { cn } from 'cn';
|
|
|
3
3
|
import { RadioGroup, RadioGroupItem } from '../ui/radio-group.js';
|
|
4
4
|
import { usePalette } from '../../hooks/use-palette.js';
|
|
5
5
|
import { useRows } from '../../hooks/use-rows.js';
|
|
6
|
-
import { isPaletteName, PALETTE_LABELS, PALETTES } from '../../lib/palettes.js';
|
|
6
|
+
import { isPaletteName, PALETTE_LABELS, paletteColour, PALETTES } from '../../lib/palettes.js';
|
|
7
7
|
import { ROWS, ROWS_LABELS } from '../../lib/rows.js';
|
|
8
8
|
import { ChoiceButtons } from './choice-buttons.js';
|
|
9
9
|
import { SettingsRow } from './settings-page.js';
|
|
@@ -16,7 +16,7 @@ const TILE = cn('relative cursor-pointer overflow-hidden rounded-lg border borde
|
|
|
16
16
|
// title, a line and a button. Read from the palette primitives, so every
|
|
17
17
|
// tile shows its own whichever palette is on screen.
|
|
18
18
|
function PalettePreview({ name }) {
|
|
19
|
-
const colour = (part) =>
|
|
19
|
+
const colour = (part) => paletteColour(name, part);
|
|
20
20
|
const bar = (part, className) => (_jsx("span", { className: cn('h-1.25 rounded-full', className), style: { background: colour(part) } }));
|
|
21
21
|
return (_jsxs("span", { "aria-hidden": true, className: "grid h-16 grid-cols-[--spacing(8.5)_minmax(0,1fr)] border-b border-border", style: { background: colour('background') }, children: [_jsxs("span", { className: "flex flex-col gap-1.25 px-1.5 py-2", style: { background: colour('panel') }, children: [bar('accent'), bar('dim'), bar('dim')] }), _jsxs("span", { className: "flex flex-col gap-1.5 p-2.25", children: [bar('dim', 'w-[70%]'), bar('second', 'w-[40%]'), bar('accent', 'h-2.5 w-[28%]')] })] }));
|
|
22
22
|
}
|
|
@@ -97,7 +97,7 @@ import { DEFAULT_HIGHLIGHT, highlightHandler, isHighlightColor, remarkHighlightN
|
|
|
97
97
|
import { textTopHeading } from '../../lib/markdown-top-heading.js';
|
|
98
98
|
import { MarkdownMergeError, markdownStyle, mergeMarkdown } from '../../lib/markdown-merge.js';
|
|
99
99
|
import { holdPendingEdit } from '../../lib/pending-edits.js';
|
|
100
|
-
import { foldStore, listenForOtherTabs } from '../../hooks/fold-store.js';
|
|
100
|
+
import { foldStore, headingStore, listenForOtherTabs } from '../../hooks/fold-store.js';
|
|
101
101
|
import { toggleFold } from '../../lib/markdown-fold.js';
|
|
102
102
|
import { DEFAULT_HEADING_LEVEL } from './prose-look.js';
|
|
103
103
|
import { foldPlugin, setFolds, shownEnd } from './rich-text-fold.js';
|
|
@@ -564,10 +564,21 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
564
564
|
};
|
|
565
565
|
openLinkRef.current = openLink;
|
|
566
566
|
// Folding by headings, with `foldKey` (read once, when it mounts):
|
|
567
|
-
// the fold store is the state, the plugin draws it
|
|
567
|
+
// the fold store is the state, the plugin draws it, and publishes the
|
|
568
|
+
// headings for NotesOutline under the same key.
|
|
569
|
+
const headingsOwner = {};
|
|
568
570
|
const folds = foldKey === undefined
|
|
569
571
|
? []
|
|
570
|
-
: [
|
|
572
|
+
: [
|
|
573
|
+
$prose(() => foldPlugin({
|
|
574
|
+
initial: foldStore.get(foldKey),
|
|
575
|
+
onChange: (folded) => foldStore.set(foldKey, folded),
|
|
576
|
+
onHeadings: (headings) => {
|
|
577
|
+
if (!cancelled)
|
|
578
|
+
headingStore.publish(foldKey, headingsOwner, headings);
|
|
579
|
+
},
|
|
580
|
+
})),
|
|
581
|
+
];
|
|
571
582
|
const onFold = foldKey === undefined ? undefined : (id) => foldStore.set(foldKey, toggleFold(foldStore.get(foldKey), id));
|
|
572
583
|
let stopFolds = () => { };
|
|
573
584
|
// Paste, copy, the editor's own keys and the placeholder.
|
|
@@ -993,6 +1004,8 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
993
1004
|
emit();
|
|
994
1005
|
cancelled = true;
|
|
995
1006
|
stopFolds();
|
|
1007
|
+
if (foldKey !== undefined)
|
|
1008
|
+
headingStore.withdraw(foldKey, headingsOwner);
|
|
996
1009
|
setEditorState(null);
|
|
997
1010
|
setEditorView(null);
|
|
998
1011
|
const editor = editorRef.current;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export type NotesOutlineProps = {
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The text whose headings are listed, beside <Markdown>. Beside a
|
|
4
|
+
* RichTextEditor with the same `foldKey` it isn't needed: the editor's
|
|
5
|
+
* headings are listed, current as it's edited, and this text is read
|
|
6
|
+
* only while no editor with the key is mounted.
|
|
7
|
+
*/
|
|
8
|
+
markdown?: string;
|
|
4
9
|
/** The `foldKey` of the <Markdown> or RichTextEditor showing the text. */
|
|
5
10
|
foldKey: string;
|
|
6
11
|
/**
|
|
@@ -8,13 +8,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
8
8
|
// (`depth`), so a long text's outline stays a list of its parts.
|
|
9
9
|
//
|
|
10
10
|
// The jump lands on the heading's fold button, so from the keyboard the
|
|
11
|
-
// next Enter folds what was just opened.
|
|
12
|
-
//
|
|
11
|
+
// next Enter folds what was just opened. Beside a RichTextEditor with
|
|
12
|
+
// the same `foldKey`, the outline lists the editor's own headings, as it
|
|
13
|
+
// edits (src/hooks/fold-store.ts's heading store), and parses nothing;
|
|
14
|
+
// otherwise it reads the Markdown it's given.
|
|
13
15
|
import { useMemo } from 'react';
|
|
14
16
|
import { ChevronRightIcon } from 'lucide-react';
|
|
15
17
|
import { cn } from 'cn';
|
|
16
18
|
import { Button } from '../ui/button.js';
|
|
17
|
-
import { useFolds } from '../../hooks/fold-store.js';
|
|
19
|
+
import { useFoldHeadings, useFolds } from '../../hooks/fold-store.js';
|
|
18
20
|
import { usePrefersReducedMotion } from '../../hooks/use-prefers-reduced-motion.js';
|
|
19
21
|
import { allFoldable, markdownFoldPlan, openTo } from '../../lib/markdown-fold.js';
|
|
20
22
|
const INDENT = ['pl-2', 'pl-6', 'pl-10', 'pl-14', 'pl-18', 'pl-22'];
|
|
@@ -32,9 +34,15 @@ function headingElement(foldKey, id) {
|
|
|
32
34
|
export function NotesOutline({ markdown, foldKey, depth = 2, minHeadings = 2, 'aria-label': ariaLabel = 'Outline', className, }) {
|
|
33
35
|
const [folded, setFolded] = useFolds(foldKey);
|
|
34
36
|
const reducedMotion = usePrefersReducedMotion();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
37
|
+
const live = useFoldHeadings(foldKey);
|
|
38
|
+
// Parsed only with no editor publishing under the key.
|
|
39
|
+
const parsed = useMemo(() => (live || markdown === undefined ? null : markdownFoldPlan(markdown).headings), [live, markdown]);
|
|
40
|
+
const headings = live ?? parsed;
|
|
41
|
+
if (!headings)
|
|
42
|
+
return null;
|
|
43
|
+
const plan = { headings };
|
|
44
|
+
const top = Math.min(...headings.map((heading) => heading.level));
|
|
45
|
+
const listed = headings.filter((heading) => heading.level < top + depth);
|
|
38
46
|
if (listed.length < minHeadings)
|
|
39
47
|
return null;
|
|
40
48
|
const foldable = allFoldable(plan);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Node as ProseNode } from '@milkdown/kit/prose/model';
|
|
2
2
|
import { Plugin, PluginKey, type EditorState } from '@milkdown/kit/prose/state';
|
|
3
3
|
import { Decoration, DecorationSet } from '@milkdown/kit/prose/view';
|
|
4
|
-
import { type FoldPlan } from '../../lib/markdown-fold.js';
|
|
4
|
+
import { type FoldHeading, type FoldPlan } from '../../lib/markdown-fold.js';
|
|
5
5
|
/** What a heading's node view hears of its fold, through its node decoration's spec. */
|
|
6
6
|
export type FoldSpec = {
|
|
7
7
|
id: string;
|
|
@@ -27,8 +27,11 @@ export declare function setFolds(state: EditorState, folded: ReadonlySet<string>
|
|
|
27
27
|
* (a caret put past it would open the section).
|
|
28
28
|
*/
|
|
29
29
|
export declare function shownEnd(state: EditorState): number;
|
|
30
|
+
/** The same headings: each with the same id, words, level, kind, place and parents. */
|
|
31
|
+
export declare function sameHeadings(a: readonly FoldHeading[], b: readonly FoldHeading[]): boolean;
|
|
30
32
|
export declare function foldPlugin(options: {
|
|
31
33
|
initial: ReadonlySet<string>;
|
|
32
34
|
onChange: (folded: ReadonlySet<string>) => void;
|
|
35
|
+
onHeadings?: (headings: readonly FoldHeading[]) => void;
|
|
33
36
|
}): Plugin<FoldState>;
|
|
34
37
|
export {};
|
|
@@ -84,6 +84,25 @@ export function shownEnd(state) {
|
|
|
84
84
|
});
|
|
85
85
|
return end;
|
|
86
86
|
}
|
|
87
|
+
/** The same headings: each with the same id, words, level, kind, place and parents. */
|
|
88
|
+
export function sameHeadings(a, b) {
|
|
89
|
+
if (a === b)
|
|
90
|
+
return true;
|
|
91
|
+
if (a.length !== b.length)
|
|
92
|
+
return false;
|
|
93
|
+
return a.every((one, at) => {
|
|
94
|
+
const other = b[at];
|
|
95
|
+
return (one.id === other.id &&
|
|
96
|
+
one.level === other.level &&
|
|
97
|
+
one.text === other.text &&
|
|
98
|
+
one.toggle === other.toggle &&
|
|
99
|
+
one.foldable === other.foldable &&
|
|
100
|
+
one.index === other.index &&
|
|
101
|
+
one.end === other.end &&
|
|
102
|
+
one.parents.length === other.parents.length &&
|
|
103
|
+
one.parents.every((id, i) => id === other.parents[i]));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
87
106
|
export function foldPlugin(options) {
|
|
88
107
|
return new Plugin({
|
|
89
108
|
key: foldPluginKey,
|
|
@@ -124,27 +143,46 @@ export function foldPlugin(options) {
|
|
|
124
143
|
return true;
|
|
125
144
|
},
|
|
126
145
|
},
|
|
127
|
-
view: () =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
view: (editorView) => {
|
|
147
|
+
// The headings last sent, and the frame that sends the next.
|
|
148
|
+
let sent = foldPluginKey.getState(editorView.state)?.plan.headings ?? [];
|
|
149
|
+
let frame = 0;
|
|
150
|
+
options.onHeadings?.(sent);
|
|
151
|
+
const sendHeadings = (view) => {
|
|
152
|
+
frame = 0;
|
|
153
|
+
const headings = foldPluginKey.getState(view.state)?.plan.headings;
|
|
154
|
+
if (!headings || sameHeadings(headings, sent))
|
|
134
155
|
return;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
sent = headings;
|
|
157
|
+
options.onHeadings?.(headings);
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
destroy: () => cancelAnimationFrame(frame),
|
|
161
|
+
update: (view, previous) => {
|
|
162
|
+
const fold = foldPluginKey.getState(view.state);
|
|
163
|
+
if (!fold)
|
|
164
|
+
return;
|
|
165
|
+
// A doc change rebuilds the plan: its headings go out a frame on, if they changed.
|
|
166
|
+
if (options.onHeadings && frame === 0 && fold.plan !== foldPluginKey.getState(previous)?.plan) {
|
|
167
|
+
frame = requestAnimationFrame(() => sendHeadings(view));
|
|
168
|
+
}
|
|
169
|
+
const index = view.state.selection.$from.index(0);
|
|
170
|
+
if (!fold.plan.hidden.has(index))
|
|
171
|
+
return;
|
|
172
|
+
// Folded around the caret (a fold button, the outline): the caret
|
|
173
|
+
// goes to the end of the heading that folded, which shows.
|
|
174
|
+
if (fold.folded !== foldPluginKey.getState(previous)?.folded && view.state.selection.eq(previous.selection)) {
|
|
175
|
+
const outer = fold.plan.headings.find((heading) => fold.folded.has(heading.id) && heading.foldable && heading.index < index && index < heading.end);
|
|
176
|
+
if (outer)
|
|
177
|
+
queueMicrotask(() => view.dispatch(caretToEnd(view.state, outer.index)));
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// The caret put in a folded section: open it (after this update,
|
|
181
|
+
// as the change comes back in a transaction of its own).
|
|
182
|
+
const opened = openAt(fold.plan, fold.folded, index);
|
|
183
|
+
queueMicrotask(() => options.onChange(opened));
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
},
|
|
149
187
|
});
|
|
150
188
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { FoldHeading } from '../lib/markdown-fold.js';
|
|
1
2
|
type StorageLike = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
2
3
|
export type FoldStore = {
|
|
3
4
|
/** The ids folded under `key`: the same set until it changes. */
|
|
@@ -16,4 +17,22 @@ export declare function listenForOtherTabs(): void;
|
|
|
16
17
|
* forgotten with the page.
|
|
17
18
|
*/
|
|
18
19
|
export declare function useFolds(foldKey: string | undefined): readonly [ReadonlySet<string>, (folded: ReadonlySet<string>) => void];
|
|
20
|
+
export type HeadingStore = {
|
|
21
|
+
/** The headings published under `key`: the same array until they change, `null` with no editor there. */
|
|
22
|
+
get: (key: string) => readonly FoldHeading[] | null;
|
|
23
|
+
/** `owner` (an editor) has these headings under `key`. */
|
|
24
|
+
publish: (key: string, owner: object, headings: readonly FoldHeading[]) => void;
|
|
25
|
+
/** `owner` is gone: its headings go, if they are the ones published. */
|
|
26
|
+
withdraw: (key: string, owner: object) => void;
|
|
27
|
+
subscribe: (key: string, listener: () => void) => () => void;
|
|
28
|
+
};
|
|
29
|
+
export declare function createHeadingStore(): HeadingStore;
|
|
30
|
+
export declare const headingStore: HeadingStore;
|
|
31
|
+
/**
|
|
32
|
+
* The headings of the RichTextEditor showing the text under `foldKey`,
|
|
33
|
+
* as folding sees them, kept current as it's edited (a frame after a
|
|
34
|
+
* heading changes; typing in a paragraph changes nothing). `null` while no
|
|
35
|
+
* editor with that key is mounted.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useFoldHeadings(foldKey: string): readonly FoldHeading[] | null;
|
|
19
38
|
export {};
|
package/dist/hooks/fold-store.js
CHANGED
|
@@ -91,3 +91,44 @@ export function useFolds(foldKey) {
|
|
|
91
91
|
const set = useCallback((folded) => (foldKey === undefined ? setLocal(folded) : foldStore.set(foldKey, folded)), [foldKey]);
|
|
92
92
|
return [foldKey === undefined ? local : stored, set];
|
|
93
93
|
}
|
|
94
|
+
export function createHeadingStore() {
|
|
95
|
+
const current = new Map();
|
|
96
|
+
const listeners = new Map();
|
|
97
|
+
const notify = (key) => {
|
|
98
|
+
for (const listener of listeners.get(key) ?? [])
|
|
99
|
+
listener();
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
get: (key) => current.get(key)?.headings ?? null,
|
|
103
|
+
publish(key, owner, headings) {
|
|
104
|
+
current.set(key, { owner, headings });
|
|
105
|
+
notify(key);
|
|
106
|
+
},
|
|
107
|
+
withdraw(key, owner) {
|
|
108
|
+
if (current.get(key)?.owner !== owner)
|
|
109
|
+
return;
|
|
110
|
+
current.delete(key);
|
|
111
|
+
notify(key);
|
|
112
|
+
},
|
|
113
|
+
subscribe(key, listener) {
|
|
114
|
+
let set = listeners.get(key);
|
|
115
|
+
if (!set)
|
|
116
|
+
listeners.set(key, (set = new Set()));
|
|
117
|
+
set.add(listener);
|
|
118
|
+
return () => set.delete(listener);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export const headingStore = createHeadingStore();
|
|
123
|
+
/**
|
|
124
|
+
* The headings of the RichTextEditor showing the text under `foldKey`,
|
|
125
|
+
* as folding sees them, kept current as it's edited (a frame after a
|
|
126
|
+
* heading changes; typing in a paragraph changes nothing). `null` while no
|
|
127
|
+
* editor with that key is mounted.
|
|
128
|
+
*/
|
|
129
|
+
export function useFoldHeadings(foldKey) {
|
|
130
|
+
const subscribe = useCallback((listener) => headingStore.subscribe(foldKey, listener), [foldKey]);
|
|
131
|
+
const get = () => headingStore.get(foldKey);
|
|
132
|
+
// No editor publishes before hydration, so the server's is the same.
|
|
133
|
+
return useSyncExternalStore(subscribe, get, get);
|
|
134
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export { useRecentRecord } from './hooks/use-recent-record.js';
|
|
|
64
64
|
export type { CreatePage, PageLinkInfo, PageLinkResolver } from './lib/page-link.js';
|
|
65
65
|
export { countTasks, toggleTaskAt, type TaskCount } from './lib/markdown-tasks.js';
|
|
66
66
|
export { NotesOutline, type NotesOutlineProps } from './components/app/notes-outline.js';
|
|
67
|
+
export { useFoldHeadings } from './hooks/fold-store.js';
|
|
68
|
+
export type { FoldHeading } from './lib/markdown-fold.js';
|
|
67
69
|
export type { HeadingFrom, HeadingLevel, TableLook } from './components/app/prose-look.js';
|
|
68
70
|
export { MockModeBanner } from './components/app/mock-mode-banner.js';
|
|
69
71
|
export { MultiChoice, type MultiChoiceOption, type MultiChoiceProps } from './components/app/multi-choice.js';
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,7 @@ export { usePageTrail } from './components/app/page-trail-context.js';
|
|
|
74
74
|
export { useRecentRecord } from './hooks/use-recent-record.js';
|
|
75
75
|
export { countTasks, toggleTaskAt } from './lib/markdown-tasks.js';
|
|
76
76
|
export { NotesOutline } from './components/app/notes-outline.js';
|
|
77
|
+
export { useFoldHeadings } from './hooks/fold-store.js';
|
|
77
78
|
export { MockModeBanner } from './components/app/mock-mode-banner.js';
|
|
78
79
|
export { MultiChoice } from './components/app/multi-choice.js';
|
|
79
80
|
export { MultiPick } from './components/app/multi-pick.js';
|
|
@@ -43,9 +43,13 @@ export declare function mdBlocks(root: MdFoldNode): (FoldHeadingInput | null)[];
|
|
|
43
43
|
/** The fold plan for a Markdown text, parsed as <Markdown> and the editor parse it. */
|
|
44
44
|
export declare function markdownFoldPlan(markdown: string, folded?: ReadonlySet<string>): FoldPlan;
|
|
45
45
|
/** Every heading with something to fold: Fold all. */
|
|
46
|
-
export declare function allFoldable(plan:
|
|
46
|
+
export declare function allFoldable(plan: {
|
|
47
|
+
headings: readonly FoldHeading[];
|
|
48
|
+
}): Set<string>;
|
|
47
49
|
/** `folded` with the heading `id` and every heading it sits under opened: a jump to it. */
|
|
48
|
-
export declare function openTo(plan:
|
|
50
|
+
export declare function openTo(plan: {
|
|
51
|
+
headings: readonly FoldHeading[];
|
|
52
|
+
}, folded: ReadonlySet<string>, id: string): Set<string>;
|
|
49
53
|
/** `folded` with every heading whose section holds the top-level block at `index` opened: the caret moved into it. */
|
|
50
54
|
export declare function openAt(plan: FoldPlan, folded: ReadonlySet<string>, index: number): Set<string>;
|
|
51
55
|
/** `folded` with `id` turned the other way. */
|
package/dist/lib/palettes.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { type DeviceChoiceStore, type StorageLike } from './device-choice.js';
|
|
2
|
-
export declare const PALETTES: readonly ["
|
|
2
|
+
export declare const PALETTES: readonly ["graphite-periwinkle", "graphite-amber", "graphite-sky", "graphite-green"];
|
|
3
3
|
export type PaletteName = (typeof PALETTES)[number];
|
|
4
|
-
/** Each palette's name as a person reads it, in the
|
|
4
|
+
/** Each palette's name as a person reads it, in the picker's order. */
|
|
5
5
|
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
|
+
/** The parts of a dark palette every one shares (its greys) and the parts that are its main colour. */
|
|
9
|
+
declare const GREY_PARTS: readonly ["background", "panel", "raised", "border", "strong-border", "text", "dim"];
|
|
10
|
+
type MainPart = 'accent' | 'accent-light' | 'accent-deep' | 'on-accent' | 'second';
|
|
11
|
+
export type PalettePart = (typeof GREY_PARTS)[number] | MainPart;
|
|
12
|
+
/** The theme.css primitive holding one part of a dark palette, for a swatch that shows it whichever palette is on screen. */
|
|
13
|
+
export declare function paletteColour(name: PaletteName, part: PalettePart): string;
|
|
8
14
|
export declare function isPaletteName(value: unknown): value is PaletteName;
|
|
9
15
|
/** The light palettes, which an app opts into by name: never in the picker (design-language.md "Palettes"). */
|
|
10
16
|
export declare const LIGHT_PALETTES: readonly ["palm-lcd"];
|
|
@@ -21,3 +27,4 @@ export type PaletteStore = DeviceChoiceStore<PaletteName>;
|
|
|
21
27
|
export declare function createPaletteStore(getStorage: () => StorageLike | undefined): PaletteStore;
|
|
22
28
|
export declare const browserPaletteStore: PaletteStore;
|
|
23
29
|
export declare const subscribeToBrowserPaletteStore: (listener: () => void) => () => void;
|
|
30
|
+
export {};
|
package/dist/lib/palettes.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// The four palettes (design-language.md "Palettes"): an app's own
|
|
2
|
-
// look,
|
|
1
|
+
// The four dark palettes (design-language.md "Palettes"): an app's own
|
|
2
|
+
// look, graphite greys with one main colour each. FoundationProviders'
|
|
3
3
|
// `palette` names the app's default; with `palettePicker` the app shell's
|
|
4
4
|
// look menu or a settings page (PaletteSetting) offers all four and the
|
|
5
5
|
// choice is remembered on this device (localStorage, this store). A new device starts on the default. The
|
|
6
6
|
// palette rides on <html> as data-palette, so popups portaled to <body>
|
|
7
|
-
// wear it too, and styles/theme.css's `.dark[data-palette]` blocks do the
|
|
7
|
+
// wear it too, and styles/theme.css's `.dark[data-palette^="graphite-"]` blocks do the
|
|
8
8
|
// rest (components/app/palette-provider.tsx, hooks/use-palette.ts).
|
|
9
9
|
//
|
|
10
10
|
// The light palettes (LIGHT_PALETTES, so far one: Palm LCD) are opt-in: an
|
|
@@ -12,16 +12,22 @@
|
|
|
12
12
|
// it is never in the picker, and it has no glow. Its block is
|
|
13
13
|
// `[data-palette="<name>"]` on top of :root.
|
|
14
14
|
import { browserStorage, createDeviceChoiceStore, otherTabsSubscriber } from './device-choice.js';
|
|
15
|
-
export const PALETTES = ['
|
|
16
|
-
/** Each palette's name as a person reads it, in the
|
|
15
|
+
export const PALETTES = ['graphite-periwinkle', 'graphite-amber', 'graphite-sky', 'graphite-green'];
|
|
16
|
+
/** Each palette's name as a person reads it, in the picker's order. */
|
|
17
17
|
export const PALETTE_LABELS = {
|
|
18
|
-
'indigo-cyan': 'Indigo and Cyan',
|
|
19
|
-
'indigo-rose': 'Indigo and Rose',
|
|
20
18
|
'graphite-periwinkle': 'Graphite and Periwinkle',
|
|
21
|
-
|
|
19
|
+
'graphite-amber': 'Graphite and Amber',
|
|
20
|
+
'graphite-sky': 'Graphite and Sky',
|
|
21
|
+
'graphite-green': 'Graphite and Green',
|
|
22
22
|
};
|
|
23
23
|
/** Where a device's chosen palette is kept. */
|
|
24
24
|
export const PALETTE_STORAGE_KEY = 'ui-foundation:palette';
|
|
25
|
+
/** The parts of a dark palette every one shares (its greys) and the parts that are its main colour. */
|
|
26
|
+
const GREY_PARTS = ['background', 'panel', 'raised', 'border', 'strong-border', 'text', 'dim'];
|
|
27
|
+
/** The theme.css primitive holding one part of a dark palette, for a swatch that shows it whichever palette is on screen. */
|
|
28
|
+
export function paletteColour(name, part) {
|
|
29
|
+
return GREY_PARTS.includes(part) ? `var(--palette-graphite-${part})` : `var(--palette-${name}-${part})`;
|
|
30
|
+
}
|
|
25
31
|
export function isPaletteName(value) {
|
|
26
32
|
return typeof value === 'string' && PALETTES.includes(value);
|
|
27
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.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/theme.css
CHANGED
|
@@ -304,77 +304,61 @@
|
|
|
304
304
|
|
|
305
305
|
/*
|
|
306
306
|
* Palette primitives (design-language.md "Palettes"). A palette is an
|
|
307
|
-
* app's own look
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* palette's own background (bg), card and raised surfaces (WCAG 2.x,
|
|
314
|
-
* sRGB), listed 1 Indigo and Cyan / 2 Indigo and Rose / 3 Graphite and
|
|
315
|
-
* Periwinkle / 4 Violet:
|
|
307
|
+
* app's own look. The four dark ones are graphite: they share one set
|
|
308
|
+
* of neutral greys (--palette-graphite-*) and each has its own main
|
|
309
|
+
* colour, five values (--palette-graphite-<hue>-*). The semantic block
|
|
310
|
+
* under `.dark[data-palette^="graphite-"]`, at the end of this file,
|
|
311
|
+
* maps them onto the tokens components use. Ratios are against the
|
|
312
|
+
* greys' background (bg), card and raised surfaces (WCAG 2.x, sRGB).
|
|
316
313
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
314
|
+
* The greys, every graphite palette:
|
|
315
|
+
* text on bg 15.0, on card 13.4
|
|
316
|
+
* dim on bg 7.54, on raised 5.79
|
|
317
|
+
* strong-border on bg 2.89: under 3:1, kept as designed (axe does
|
|
318
|
+
* not check borders)
|
|
319
|
+
*
|
|
320
|
+
* Each main colour, listed Periwinkle / Amber / Sky / Green:
|
|
321
|
+
* accent on bg 4.87 / 4.99 / 5.25 / 5.54, on card 4.32 / 4.43 /
|
|
322
|
+
* 4.66 / 4.92: never small text; the ring and fills only
|
|
323
|
+
* on-accent on accent 5.28 / 5.43 / 5.68 / 5.97
|
|
324
|
+
* accent-light on bg 10.4 / 10.4 / 10.6 / 10.9, on card 9.19 / 9.23 /
|
|
325
|
+
* 9.44 / 9.65, on raised 7.95 at the least: links
|
|
326
|
+
* accent-deep a chart's third series, never text
|
|
327
|
+
* second on card 5.08 / 5.07 / 5.24 / 5.50
|
|
328
|
+
* Amber, Sky and Green are Periwinkle's lightness and strength in
|
|
329
|
+
* OKLCH, at their own hue.
|
|
326
330
|
*/
|
|
327
|
-
--palette-
|
|
328
|
-
--palette-
|
|
329
|
-
--palette-
|
|
330
|
-
--palette-
|
|
331
|
-
--palette-
|
|
332
|
-
--palette-
|
|
333
|
-
--palette-
|
|
334
|
-
--palette-indigo-cyan-accent: #6682f5;
|
|
335
|
-
--palette-indigo-cyan-accent-light: #b2c1fa;
|
|
336
|
-
--palette-indigo-cyan-accent-deep: #224cf1;
|
|
337
|
-
--palette-indigo-cyan-on-accent: #090f25;
|
|
338
|
-
--palette-indigo-cyan-second: #6dd4ee;
|
|
339
|
-
|
|
340
|
-
--palette-indigo-rose-background: #101219;
|
|
341
|
-
--palette-indigo-rose-panel: #181c28;
|
|
342
|
-
--palette-indigo-rose-raised: #202534;
|
|
343
|
-
--palette-indigo-rose-border: #32394e;
|
|
344
|
-
--palette-indigo-rose-strong-border: #4c5570;
|
|
345
|
-
--palette-indigo-rose-text: #e6e8ef;
|
|
346
|
-
--palette-indigo-rose-dim: #9da3b4;
|
|
347
|
-
--palette-indigo-rose-accent: #6868f3;
|
|
348
|
-
--palette-indigo-rose-accent-light: #b4b4f9;
|
|
349
|
-
--palette-indigo-rose-accent-deep: #2626ed;
|
|
350
|
-
--palette-indigo-rose-on-accent: #090925;
|
|
351
|
-
--palette-indigo-rose-second: #ec6f8e;
|
|
331
|
+
--palette-graphite-background: #171717;
|
|
332
|
+
--palette-graphite-panel: #222222;
|
|
333
|
+
--palette-graphite-raised: #2d2d2d;
|
|
334
|
+
--palette-graphite-border: #424242;
|
|
335
|
+
--palette-graphite-strong-border: #616161;
|
|
336
|
+
--palette-graphite-text: #ebebeb;
|
|
337
|
+
--palette-graphite-dim: #a8a8a8;
|
|
352
338
|
|
|
353
|
-
--palette-graphite-periwinkle-background: #171717;
|
|
354
|
-
--palette-graphite-periwinkle-panel: #222222;
|
|
355
|
-
--palette-graphite-periwinkle-raised: #2d2d2d;
|
|
356
|
-
--palette-graphite-periwinkle-border: #424242;
|
|
357
|
-
--palette-graphite-periwinkle-strong-border: #616161;
|
|
358
|
-
--palette-graphite-periwinkle-text: #ebebeb;
|
|
359
|
-
--palette-graphite-periwinkle-dim: #a8a8a8;
|
|
360
339
|
--palette-graphite-periwinkle-accent: #7f75f0;
|
|
361
340
|
--palette-graphite-periwinkle-accent-light: #c3bff8;
|
|
362
341
|
--palette-graphite-periwinkle-accent-deep: #4435e9;
|
|
363
342
|
--palette-graphite-periwinkle-on-accent: #0b0925;
|
|
364
343
|
--palette-graphite-periwinkle-second: #a97bea;
|
|
365
344
|
|
|
366
|
-
--palette-
|
|
367
|
-
--palette-
|
|
368
|
-
--palette-
|
|
369
|
-
--palette-
|
|
370
|
-
--palette-
|
|
371
|
-
|
|
372
|
-
--palette-
|
|
373
|
-
--palette-
|
|
374
|
-
--palette-
|
|
375
|
-
--palette-
|
|
376
|
-
--palette-
|
|
377
|
-
|
|
345
|
+
--palette-graphite-amber-accent: #bd7801;
|
|
346
|
+
--palette-graphite-amber-accent-light: #e8be8e;
|
|
347
|
+
--palette-graphite-amber-accent-deep: #845200;
|
|
348
|
+
--palette-graphite-amber-on-accent: #160a00;
|
|
349
|
+
--palette-graphite-amber-second: #e86d40;
|
|
350
|
+
|
|
351
|
+
--palette-graphite-sky-accent: #0093d7;
|
|
352
|
+
--palette-graphite-sky-accent-light: #97cef5;
|
|
353
|
+
--palette-graphite-sky-accent-deep: #006697;
|
|
354
|
+
--palette-graphite-sky-on-accent: #000f1b;
|
|
355
|
+
--palette-graphite-sky-second: #7b8bfa;
|
|
356
|
+
|
|
357
|
+
--palette-graphite-green-accent: #06a54c;
|
|
358
|
+
--palette-graphite-green-accent-light: #a2d6ab;
|
|
359
|
+
--palette-graphite-green-accent-deep: #017332;
|
|
360
|
+
--palette-graphite-green-on-accent: #001204;
|
|
361
|
+
--palette-graphite-green-second: #9d9d09;
|
|
378
362
|
|
|
379
363
|
/*
|
|
380
364
|
* The status colours every palette shares, as TEXT shades (--*-text):
|
|
@@ -1213,202 +1197,103 @@
|
|
|
1213
1197
|
* Palettes (design-language.md "Palettes"): an app's own dark look.
|
|
1214
1198
|
* FoundationProviders' `palette` puts data-palette on <html> and forces
|
|
1215
1199
|
* the dark theme (Palm LCD, the light one, is at the end of this file),
|
|
1216
|
-
* so
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
*
|
|
1200
|
+
* so the block below always sits on top of .dark and sets only what
|
|
1201
|
+
* differs from it. Every dark palette is graphite: one block maps the
|
|
1202
|
+
* shared greys and the palette's main colour, read through five
|
|
1203
|
+
* --palette-main-* names that each palette's own small block sets. The
|
|
1204
|
+
* solid fills (--destructive, --success, --warning, --info, each with
|
|
1205
|
+
* white -foreground), --info-text, the highlight washes, the categorical
|
|
1206
|
+
* slots, the heat scale and the depth ramps stay .dark's.
|
|
1221
1207
|
*
|
|
1222
|
-
* --ring is the accent (4.
|
|
1223
|
-
*
|
|
1224
|
-
* --link is accent light: the accent fails 4.5 as small text on
|
|
1208
|
+
* --ring is the accent (4.87 to 5.54 on the page), not accent deep
|
|
1209
|
+
* (2.50 to 2.99, under the 3:1 a focus ring needs).
|
|
1210
|
+
* --link is accent light: the accent fails 4.5 as small text on cards.
|
|
1225
1211
|
* --*-text are the shared status shades; the fills are unchanged.
|
|
1226
1212
|
* --sidebar-accent, the active and hovered item, is a soft accent tint
|
|
1227
|
-
* on the panel (16%): text on it 10.8
|
|
1228
|
-
* at the least.
|
|
1213
|
+
* on the panel (16%): text on it 10.8 at the least, dim 5.41.
|
|
1229
1214
|
* Derived in .dark and resolved with these values, since both blocks
|
|
1230
|
-
* apply to <html>: --table-stripe
|
|
1231
|
-
*
|
|
1232
|
-
* --rule is the strong border (2.53 to 2.89; .dark's was 2.54).
|
|
1215
|
+
* apply to <html>: --table-stripe, --table-highlight, --heading-band.
|
|
1216
|
+
* --rule is the strong border (2.89; .dark's was 2.54).
|
|
1233
1217
|
*
|
|
1234
1218
|
* Printed notes still print light: index.css's print override is more
|
|
1235
|
-
* specific than
|
|
1219
|
+
* specific than this block (tests: entity-view-print.spec.ts).
|
|
1236
1220
|
*/
|
|
1237
1221
|
|
|
1238
|
-
.dark[data-palette
|
|
1239
|
-
--background: var(--palette-
|
|
1240
|
-
--foreground: var(--palette-
|
|
1241
|
-
--card: var(--palette-
|
|
1242
|
-
--card-foreground: var(--palette-
|
|
1243
|
-
--popover: var(--palette-
|
|
1244
|
-
--popover-foreground: var(--palette-
|
|
1245
|
-
--primary: var(--palette-
|
|
1246
|
-
--primary-foreground: var(--palette-
|
|
1247
|
-
--secondary: var(--palette-
|
|
1248
|
-
--secondary-foreground: var(--palette-
|
|
1249
|
-
--muted: var(--palette-
|
|
1250
|
-
--muted-foreground: var(--palette-
|
|
1251
|
-
--accent: var(--palette-
|
|
1252
|
-
--accent-foreground: var(--palette-
|
|
1253
|
-
--accent-second: var(--palette-
|
|
1222
|
+
.dark[data-palette^="graphite-"] {
|
|
1223
|
+
--background: var(--palette-graphite-background);
|
|
1224
|
+
--foreground: var(--palette-graphite-text);
|
|
1225
|
+
--card: var(--palette-graphite-panel);
|
|
1226
|
+
--card-foreground: var(--palette-graphite-text);
|
|
1227
|
+
--popover: var(--palette-graphite-panel);
|
|
1228
|
+
--popover-foreground: var(--palette-graphite-text);
|
|
1229
|
+
--primary: var(--palette-main-accent);
|
|
1230
|
+
--primary-foreground: var(--palette-main-on-accent);
|
|
1231
|
+
--secondary: var(--palette-graphite-raised);
|
|
1232
|
+
--secondary-foreground: var(--palette-graphite-text);
|
|
1233
|
+
--muted: var(--palette-graphite-raised);
|
|
1234
|
+
--muted-foreground: var(--palette-graphite-dim);
|
|
1235
|
+
--accent: var(--palette-graphite-raised);
|
|
1236
|
+
--accent-foreground: var(--palette-graphite-text);
|
|
1237
|
+
--accent-second: var(--palette-main-second);
|
|
1254
1238
|
--destructive-text: var(--palette-danger);
|
|
1255
1239
|
--success-text: var(--palette-success);
|
|
1256
1240
|
--warning-text: var(--palette-warning);
|
|
1257
1241
|
--status-done-text: var(--palette-done);
|
|
1258
1242
|
--status-ended-text: var(--palette-ended);
|
|
1259
|
-
--link: var(--palette-
|
|
1260
|
-
--primary-text: var(--palette-
|
|
1261
|
-
--heading-bar: var(--palette-
|
|
1262
|
-
--rule: var(--palette-
|
|
1263
|
-
--table-highlight-muted-foreground: var(--palette-
|
|
1264
|
-
--border: var(--palette-
|
|
1265
|
-
--input: var(--palette-
|
|
1266
|
-
--ring: var(--palette-
|
|
1267
|
-
--chart-1: var(--palette-
|
|
1268
|
-
--chart-2: var(--palette-
|
|
1269
|
-
--chart-3: var(--palette-
|
|
1270
|
-
--chart-4: var(--palette-
|
|
1271
|
-
--chart-5: var(--palette-
|
|
1272
|
-
--sidebar: var(--palette-
|
|
1273
|
-
--sidebar-foreground: var(--palette-
|
|
1274
|
-
--sidebar-primary: var(--palette-
|
|
1275
|
-
--sidebar-primary-foreground: var(--palette-
|
|
1276
|
-
--sidebar-accent: color-mix(in srgb, var(--palette-
|
|
1277
|
-
--sidebar-accent-foreground: var(--palette-
|
|
1278
|
-
--sidebar-border: var(--palette-
|
|
1279
|
-
--sidebar-ring: var(--palette-
|
|
1243
|
+
--link: var(--palette-main-accent-light);
|
|
1244
|
+
--primary-text: var(--palette-main-accent-light);
|
|
1245
|
+
--heading-bar: var(--palette-main-accent-light);
|
|
1246
|
+
--rule: var(--palette-graphite-strong-border);
|
|
1247
|
+
--table-highlight-muted-foreground: var(--palette-graphite-dim);
|
|
1248
|
+
--border: var(--palette-graphite-border);
|
|
1249
|
+
--input: var(--palette-graphite-strong-border);
|
|
1250
|
+
--ring: var(--palette-main-accent);
|
|
1251
|
+
--chart-1: var(--palette-main-accent-light);
|
|
1252
|
+
--chart-2: var(--palette-main-accent);
|
|
1253
|
+
--chart-3: var(--palette-main-accent-deep);
|
|
1254
|
+
--chart-4: var(--palette-main-second);
|
|
1255
|
+
--chart-5: var(--palette-graphite-border);
|
|
1256
|
+
--sidebar: var(--palette-graphite-panel);
|
|
1257
|
+
--sidebar-foreground: var(--palette-graphite-text);
|
|
1258
|
+
--sidebar-primary: var(--palette-main-accent);
|
|
1259
|
+
--sidebar-primary-foreground: var(--palette-main-on-accent);
|
|
1260
|
+
--sidebar-accent: color-mix(in srgb, var(--palette-main-accent) 16%, var(--palette-graphite-panel));
|
|
1261
|
+
--sidebar-accent-foreground: var(--palette-graphite-text);
|
|
1262
|
+
--sidebar-border: var(--palette-graphite-border);
|
|
1263
|
+
--sidebar-ring: var(--palette-main-accent);
|
|
1280
1264
|
}
|
|
1281
1265
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
--
|
|
1285
|
-
--
|
|
1286
|
-
--
|
|
1287
|
-
--
|
|
1288
|
-
--
|
|
1289
|
-
--primary: var(--palette-indigo-rose-accent);
|
|
1290
|
-
--primary-foreground: var(--palette-indigo-rose-on-accent);
|
|
1291
|
-
--secondary: var(--palette-indigo-rose-raised);
|
|
1292
|
-
--secondary-foreground: var(--palette-indigo-rose-text);
|
|
1293
|
-
--muted: var(--palette-indigo-rose-raised);
|
|
1294
|
-
--muted-foreground: var(--palette-indigo-rose-dim);
|
|
1295
|
-
--accent: var(--palette-indigo-rose-raised);
|
|
1296
|
-
--accent-foreground: var(--palette-indigo-rose-text);
|
|
1297
|
-
--accent-second: var(--palette-indigo-rose-second);
|
|
1298
|
-
--destructive-text: var(--palette-danger);
|
|
1299
|
-
--success-text: var(--palette-success);
|
|
1300
|
-
--warning-text: var(--palette-warning);
|
|
1301
|
-
--status-done-text: var(--palette-done);
|
|
1302
|
-
--status-ended-text: var(--palette-ended);
|
|
1303
|
-
--link: var(--palette-indigo-rose-accent-light);
|
|
1304
|
-
--primary-text: var(--palette-indigo-rose-accent-light);
|
|
1305
|
-
--heading-bar: var(--palette-indigo-rose-accent-light);
|
|
1306
|
-
--rule: var(--palette-indigo-rose-strong-border);
|
|
1307
|
-
--table-highlight-muted-foreground: var(--palette-indigo-rose-dim);
|
|
1308
|
-
--border: var(--palette-indigo-rose-border);
|
|
1309
|
-
--input: var(--palette-indigo-rose-strong-border);
|
|
1310
|
-
--ring: var(--palette-indigo-rose-accent);
|
|
1311
|
-
--chart-1: var(--palette-indigo-rose-accent-light);
|
|
1312
|
-
--chart-2: var(--palette-indigo-rose-accent);
|
|
1313
|
-
--chart-3: var(--palette-indigo-rose-accent-deep);
|
|
1314
|
-
--chart-4: var(--palette-indigo-rose-second);
|
|
1315
|
-
--chart-5: var(--palette-indigo-rose-border);
|
|
1316
|
-
--sidebar: var(--palette-indigo-rose-panel);
|
|
1317
|
-
--sidebar-foreground: var(--palette-indigo-rose-text);
|
|
1318
|
-
--sidebar-primary: var(--palette-indigo-rose-accent);
|
|
1319
|
-
--sidebar-primary-foreground: var(--palette-indigo-rose-on-accent);
|
|
1320
|
-
--sidebar-accent: color-mix(in srgb, var(--palette-indigo-rose-accent) 16%, var(--palette-indigo-rose-panel));
|
|
1321
|
-
--sidebar-accent-foreground: var(--palette-indigo-rose-text);
|
|
1322
|
-
--sidebar-border: var(--palette-indigo-rose-border);
|
|
1323
|
-
--sidebar-ring: var(--palette-indigo-rose-accent);
|
|
1266
|
+
/* Each graphite palette's main colour (design-language.md "Palettes"). */
|
|
1267
|
+
.dark[data-palette="graphite-periwinkle"] {
|
|
1268
|
+
--palette-main-accent: var(--palette-graphite-periwinkle-accent);
|
|
1269
|
+
--palette-main-accent-light: var(--palette-graphite-periwinkle-accent-light);
|
|
1270
|
+
--palette-main-accent-deep: var(--palette-graphite-periwinkle-accent-deep);
|
|
1271
|
+
--palette-main-on-accent: var(--palette-graphite-periwinkle-on-accent);
|
|
1272
|
+
--palette-main-second: var(--palette-graphite-periwinkle-second);
|
|
1324
1273
|
}
|
|
1325
1274
|
|
|
1326
|
-
.dark[data-palette="graphite-
|
|
1327
|
-
--
|
|
1328
|
-
--
|
|
1329
|
-
--
|
|
1330
|
-
--
|
|
1331
|
-
--
|
|
1332
|
-
--popover-foreground: var(--palette-graphite-periwinkle-text);
|
|
1333
|
-
--primary: var(--palette-graphite-periwinkle-accent);
|
|
1334
|
-
--primary-foreground: var(--palette-graphite-periwinkle-on-accent);
|
|
1335
|
-
--secondary: var(--palette-graphite-periwinkle-raised);
|
|
1336
|
-
--secondary-foreground: var(--palette-graphite-periwinkle-text);
|
|
1337
|
-
--muted: var(--palette-graphite-periwinkle-raised);
|
|
1338
|
-
--muted-foreground: var(--palette-graphite-periwinkle-dim);
|
|
1339
|
-
--accent: var(--palette-graphite-periwinkle-raised);
|
|
1340
|
-
--accent-foreground: var(--palette-graphite-periwinkle-text);
|
|
1341
|
-
--accent-second: var(--palette-graphite-periwinkle-second);
|
|
1342
|
-
--destructive-text: var(--palette-danger);
|
|
1343
|
-
--success-text: var(--palette-success);
|
|
1344
|
-
--warning-text: var(--palette-warning);
|
|
1345
|
-
--status-done-text: var(--palette-done);
|
|
1346
|
-
--status-ended-text: var(--palette-ended);
|
|
1347
|
-
--link: var(--palette-graphite-periwinkle-accent-light);
|
|
1348
|
-
--primary-text: var(--palette-graphite-periwinkle-accent-light);
|
|
1349
|
-
--heading-bar: var(--palette-graphite-periwinkle-accent-light);
|
|
1350
|
-
--rule: var(--palette-graphite-periwinkle-strong-border);
|
|
1351
|
-
--table-highlight-muted-foreground: var(--palette-graphite-periwinkle-dim);
|
|
1352
|
-
--border: var(--palette-graphite-periwinkle-border);
|
|
1353
|
-
--input: var(--palette-graphite-periwinkle-strong-border);
|
|
1354
|
-
--ring: var(--palette-graphite-periwinkle-accent);
|
|
1355
|
-
--chart-1: var(--palette-graphite-periwinkle-accent-light);
|
|
1356
|
-
--chart-2: var(--palette-graphite-periwinkle-accent);
|
|
1357
|
-
--chart-3: var(--palette-graphite-periwinkle-accent-deep);
|
|
1358
|
-
--chart-4: var(--palette-graphite-periwinkle-second);
|
|
1359
|
-
--chart-5: var(--palette-graphite-periwinkle-border);
|
|
1360
|
-
--sidebar: var(--palette-graphite-periwinkle-panel);
|
|
1361
|
-
--sidebar-foreground: var(--palette-graphite-periwinkle-text);
|
|
1362
|
-
--sidebar-primary: var(--palette-graphite-periwinkle-accent);
|
|
1363
|
-
--sidebar-primary-foreground: var(--palette-graphite-periwinkle-on-accent);
|
|
1364
|
-
--sidebar-accent: color-mix(in srgb, var(--palette-graphite-periwinkle-accent) 16%, var(--palette-graphite-periwinkle-panel));
|
|
1365
|
-
--sidebar-accent-foreground: var(--palette-graphite-periwinkle-text);
|
|
1366
|
-
--sidebar-border: var(--palette-graphite-periwinkle-border);
|
|
1367
|
-
--sidebar-ring: var(--palette-graphite-periwinkle-accent);
|
|
1275
|
+
.dark[data-palette="graphite-amber"] {
|
|
1276
|
+
--palette-main-accent: var(--palette-graphite-amber-accent);
|
|
1277
|
+
--palette-main-accent-light: var(--palette-graphite-amber-accent-light);
|
|
1278
|
+
--palette-main-accent-deep: var(--palette-graphite-amber-accent-deep);
|
|
1279
|
+
--palette-main-on-accent: var(--palette-graphite-amber-on-accent);
|
|
1280
|
+
--palette-main-second: var(--palette-graphite-amber-second);
|
|
1368
1281
|
}
|
|
1369
1282
|
|
|
1370
|
-
.dark[data-palette="
|
|
1371
|
-
--
|
|
1372
|
-
--
|
|
1373
|
-
--
|
|
1374
|
-
--
|
|
1375
|
-
--
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
--
|
|
1380
|
-
--
|
|
1381
|
-
--
|
|
1382
|
-
--
|
|
1383
|
-
--
|
|
1384
|
-
--accent-foreground: var(--palette-violet-text);
|
|
1385
|
-
--accent-second: var(--palette-violet-second);
|
|
1386
|
-
--destructive-text: var(--palette-danger);
|
|
1387
|
-
--success-text: var(--palette-success);
|
|
1388
|
-
--warning-text: var(--palette-warning);
|
|
1389
|
-
--status-done-text: var(--palette-done);
|
|
1390
|
-
--status-ended-text: var(--palette-ended);
|
|
1391
|
-
--link: var(--palette-violet-accent-light);
|
|
1392
|
-
--primary-text: var(--palette-violet-accent-light);
|
|
1393
|
-
--heading-bar: var(--palette-violet-accent-light);
|
|
1394
|
-
--rule: var(--palette-violet-strong-border);
|
|
1395
|
-
--table-highlight-muted-foreground: var(--palette-violet-dim);
|
|
1396
|
-
--border: var(--palette-violet-border);
|
|
1397
|
-
--input: var(--palette-violet-strong-border);
|
|
1398
|
-
--ring: var(--palette-violet-accent);
|
|
1399
|
-
--chart-1: var(--palette-violet-accent-light);
|
|
1400
|
-
--chart-2: var(--palette-violet-accent);
|
|
1401
|
-
--chart-3: var(--palette-violet-accent-deep);
|
|
1402
|
-
--chart-4: var(--palette-violet-second);
|
|
1403
|
-
--chart-5: var(--palette-violet-border);
|
|
1404
|
-
--sidebar: var(--palette-violet-panel);
|
|
1405
|
-
--sidebar-foreground: var(--palette-violet-text);
|
|
1406
|
-
--sidebar-primary: var(--palette-violet-accent);
|
|
1407
|
-
--sidebar-primary-foreground: var(--palette-violet-on-accent);
|
|
1408
|
-
--sidebar-accent: color-mix(in srgb, var(--palette-violet-accent) 16%, var(--palette-violet-panel));
|
|
1409
|
-
--sidebar-accent-foreground: var(--palette-violet-text);
|
|
1410
|
-
--sidebar-border: var(--palette-violet-border);
|
|
1411
|
-
--sidebar-ring: var(--palette-violet-accent);
|
|
1283
|
+
.dark[data-palette="graphite-sky"] {
|
|
1284
|
+
--palette-main-accent: var(--palette-graphite-sky-accent);
|
|
1285
|
+
--palette-main-accent-light: var(--palette-graphite-sky-accent-light);
|
|
1286
|
+
--palette-main-accent-deep: var(--palette-graphite-sky-accent-deep);
|
|
1287
|
+
--palette-main-on-accent: var(--palette-graphite-sky-on-accent);
|
|
1288
|
+
--palette-main-second: var(--palette-graphite-sky-second);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
.dark[data-palette="graphite-green"] {
|
|
1292
|
+
--palette-main-accent: var(--palette-graphite-green-accent);
|
|
1293
|
+
--palette-main-accent-light: var(--palette-graphite-green-accent-light);
|
|
1294
|
+
--palette-main-accent-deep: var(--palette-graphite-green-accent-deep);
|
|
1295
|
+
--palette-main-on-accent: var(--palette-graphite-green-on-accent);
|
|
1296
|
+
--palette-main-second: var(--palette-graphite-green-second);
|
|
1412
1297
|
}
|
|
1413
1298
|
|
|
1414
1299
|
/*
|
package/vite/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type PwaOptions = {
|
|
|
36
36
|
* below default to its accent, its text on the accent and its background
|
|
37
37
|
* instead of the light theme's.
|
|
38
38
|
*/
|
|
39
|
-
palette?: '
|
|
39
|
+
palette?: 'graphite-periwinkle' | 'graphite-amber' | 'graphite-sky' | 'graphite-green' | 'palm-lcd'
|
|
40
40
|
/** `#rrggbb`. Defaults to the package's `--primary` token (or the palette's accent). */
|
|
41
41
|
themeColor?: string
|
|
42
42
|
/** The letter's colour on the SVG icon, `#rrggbb`. Defaults to `--primary-foreground`. */
|
package/vite/pwa.js
CHANGED
|
@@ -79,8 +79,14 @@ export function oklchToHex(value) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// A palette's own colours for each token pwa() reads (styles/theme.css's
|
|
82
|
-
// --palette-<name>-* primitives, already #rrggbb).
|
|
82
|
+
// --palette-<name>-* primitives, already #rrggbb). A graphite palette's
|
|
83
|
+
// greys are shared, as --palette-graphite-*.
|
|
83
84
|
const PALETTE_PARTS = { primary: 'accent', 'primary-foreground': 'on-accent', background: 'background' }
|
|
85
|
+
const GRAPHITE_GREYS = new Set(['background'])
|
|
86
|
+
|
|
87
|
+
function palettePrimitive(palette, part) {
|
|
88
|
+
return palette.startsWith('graphite-') && GRAPHITE_GREYS.has(part) ? `palette-graphite-${part}` : `palette-${palette}-${part}`
|
|
89
|
+
}
|
|
84
90
|
|
|
85
91
|
function colour(value, token, palette) {
|
|
86
92
|
if (value !== undefined) {
|
|
@@ -89,7 +95,7 @@ function colour(value, token, palette) {
|
|
|
89
95
|
}
|
|
90
96
|
const css = fs.readFileSync(THEME_CSS, 'utf8')
|
|
91
97
|
if (palette !== undefined) {
|
|
92
|
-
const hex = themeToken(css,
|
|
98
|
+
const hex = themeToken(css, palettePrimitive(palette, PALETTE_PARTS[token]))
|
|
93
99
|
if (!HEX.test(hex)) throw new Error(`pwa: no palette "${palette}" in the theme.`)
|
|
94
100
|
return hex.toLowerCase()
|
|
95
101
|
}
|