@tristan2828/ui-foundation 4.75.0 → 4.77.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/add-an-entity.md +20 -9
- package/conventions/docs/cell-patterns.md +81 -35
- package/conventions/docs/design-language.md +158 -26
- package/dist/components/app/data-table.d.ts +11 -1
- package/dist/components/app/data-table.js +16 -6
- package/dist/components/app/entity-view.d.ts +31 -1
- package/dist/components/app/entity-view.js +77 -10
- package/dist/components/app/markdown.d.ts +13 -1
- package/dist/components/app/markdown.js +44 -2
- package/dist/components/ui/table.d.ts +2 -1
- package/dist/components/ui/table.js +3 -3
- package/dist/components/ui/tabs.d.ts +10 -0
- package/dist/components/ui/tabs.js +28 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/lib/entity-view-tab.d.ts +2 -0
- package/dist/lib/entity-view-tab.js +11 -0
- package/dist/lib/markdown-inline.d.ts +10 -0
- package/dist/lib/markdown-inline.js +204 -0
- package/package.json +1 -1
- package/styles/index.css +120 -0
- package/styles/theme.css +391 -1
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
- Step 8: Add Playwright specs for all three screens · lines 686–764
|
|
16
16
|
- Step 9: Register the nav entry and route names · lines 765–779
|
|
17
17
|
- Step 10: `npm run verify`. · lines 780–782
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines 784–
|
|
19
|
-
- [The record view](#the-record-view) · lines 897–
|
|
20
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
21
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
22
|
-
- [Deleting](#deleting) · lines
|
|
23
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
24
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
25
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
18
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 784–933
|
|
19
|
+
- [The record view](#the-record-view) · lines 897–933
|
|
20
|
+
- [What not to copy](#what-not-to-copy) · lines 935–961
|
|
21
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 963–980
|
|
22
|
+
- [Deleting](#deleting) · lines 982–1011
|
|
23
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1013–1034
|
|
24
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1036–1045
|
|
25
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1048–1087
|
|
26
26
|
|
|
27
27
|
<!-- /index -->
|
|
28
28
|
|
|
@@ -903,7 +903,9 @@ view reaches them all. A record uses the parts it has, in this order:
|
|
|
903
903
|
- **Header**: the title, edited in place (`titleEdit`); under it a
|
|
904
904
|
one-line summary field, edited in place (`subtitle`: a goal, a
|
|
905
905
|
description); beside it the status as a quick action (a picker saved
|
|
906
|
-
at once) and other status-like fields as badges, edited in place.
|
|
906
|
+
at once) and other status-like fields as badges, edited in place. A
|
|
907
|
+
record with a face or a mark of its own (a person's avatar, a
|
|
908
|
+
service's logo, a cover) puts it left of all that (`leading`, 4.76).
|
|
907
909
|
`actions` holds Delete (soft, with Undo) and the record's own commands
|
|
908
910
|
(Run, Print), never Edit.
|
|
909
911
|
- **Strip**: the record's key numbers and ratings (`strip`, a
|
|
@@ -915,6 +917,15 @@ view reaches them all. A record uses the parts it has, in this order:
|
|
|
915
917
|
Outline for a long one and Print notes (`print`). Without long text,
|
|
916
918
|
one column. Every value edited in place (`edit`), a sub-item list
|
|
917
919
|
included (`editInPlace({ kind: 'list' })`).
|
|
920
|
+
- **Tabs** (4.76), for a main column with **three or more groups of
|
|
921
|
+
long content** (the steps, where it's used, the reasoning): a `tab` on
|
|
922
|
+
each main section groups them under a tab list, the selected one in
|
|
923
|
+
`?tab=`. Fewer groups stay one scroll, folded by headings. A record's
|
|
924
|
+
Notes stay outside the tabs, above them, unless they are one tab's
|
|
925
|
+
content; the rail and the strip never go in a tab.
|
|
926
|
+
- **Rail fields beside their labels** (`railFields="beside"`, 4.76) for
|
|
927
|
+
a rail of many short facts, so it reads as a list of pairs rather than
|
|
928
|
+
a column of labels; keep labels to a word or two.
|
|
918
929
|
- **A big record's own parts** (a drawing, a player, a checklist of
|
|
919
930
|
documents) are sections in the view, not a screen of their own.
|
|
920
931
|
|
|
@@ -4,41 +4,41 @@
|
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
6
|
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 70–89
|
|
7
|
-
- [1. Plain text](#1-plain-text) · lines 91–
|
|
8
|
-
- [2. Icon + label](#2-icon--label) · lines
|
|
9
|
-
- [3. Icon in a badge](#3-icon-in-a-badge) · lines
|
|
10
|
-
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines
|
|
11
|
-
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines
|
|
12
|
-
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines
|
|
13
|
-
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines
|
|
14
|
-
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines
|
|
15
|
-
- [8. Date, relative](#8-date-relative) · lines
|
|
16
|
-
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines
|
|
17
|
-
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines
|
|
18
|
-
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines
|
|
19
|
-
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines
|
|
20
|
-
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines
|
|
21
|
-
- [12. Boolean](#12-boolean) · lines
|
|
22
|
-
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines
|
|
23
|
-
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines
|
|
24
|
-
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines
|
|
25
|
-
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines
|
|
26
|
-
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines
|
|
27
|
-
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines
|
|
28
|
-
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines
|
|
30
|
-
- [Presets: one line per field](#presets-one-line-per-field) · lines
|
|
31
|
-
- [Several fields edited as one](#several-fields-edited-as-one) · lines
|
|
32
|
-
- [A link and its label](#a-link-and-its-label) · lines
|
|
33
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
34
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
35
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
36
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
37
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
38
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
39
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
40
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
41
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
7
|
+
- [1. Plain text](#1-plain-text) · lines 91–127
|
|
8
|
+
- [2. Icon + label](#2-icon--label) · lines 129–152
|
|
9
|
+
- [3. Icon in a badge](#3-icon-in-a-badge) · lines 154–167
|
|
10
|
+
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 169–246
|
|
11
|
+
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 194–246
|
|
12
|
+
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 248–261
|
|
13
|
+
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 263–275
|
|
14
|
+
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 277–298
|
|
15
|
+
- [8. Date, relative](#8-date-relative) · lines 300–337
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 339–387
|
|
17
|
+
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 357–387
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 389–439
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 407–439
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 441–481
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 483–513
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 515–551
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 535–551
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 553–570
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 572–681
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 598–681
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 683–718
|
|
28
|
+
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 720–793
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 795–1430
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1080–1136
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1138–1170
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1172–1196
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1198–1331
|
|
34
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1333–1418
|
|
35
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1420–1430
|
|
36
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1432–1498
|
|
37
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1500–1564
|
|
38
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1566–1664
|
|
39
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1666–1694
|
|
40
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1696–1772
|
|
41
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1774–1797
|
|
42
42
|
|
|
43
43
|
<!-- /index -->
|
|
44
44
|
|
|
@@ -97,6 +97,35 @@ otherwise have to make themselves.
|
|
|
97
97
|
Always offer a plain-text option when exploring a column — in practice it
|
|
98
98
|
gets picked about as often as the visual ones.
|
|
99
99
|
|
|
100
|
+
**Markdown in a one-line value.** A short field the app lets people write
|
|
101
|
+
Markdown in (a summary, a status note, a title with a link) shows in a
|
|
102
|
+
cell, a card's line or a caption with `<Markdown inline>`, not the block
|
|
103
|
+
`<Markdown>`:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<span className="text-muted-foreground">
|
|
107
|
+
<Markdown inline>{row.original.summary}</Markdown>
|
|
108
|
+
</span>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Bold, italic, code and links keep their marks; every other mark shows
|
|
112
|
+
as its words (a strikethrough or a highlight as plain words).
|
|
113
|
+
- It's a `<span>` in the font and colour of where it sits, with no block
|
|
114
|
+
margins, so the row stays as tall as a plain-text one. Code is the mono
|
|
115
|
+
face alone, with no wash, so it can't add height or fail contrast on a
|
|
116
|
+
muted cell.
|
|
117
|
+
- Blocks written in it still read on one line: paragraphs joined with a
|
|
118
|
+
space; a list's items with " · " (numbered ones with their numbers, a
|
|
119
|
+
done task with ✓, one to do with ☐); a table's rows as `Header: value`
|
|
120
|
+
pairs (`Size: S, Price: $4 · Size: L, Price: $6`); a heading, quote or
|
|
121
|
+
rule as " · "; a callout led by its kind ("Warning: …"); an image as its
|
|
122
|
+
alt text.
|
|
123
|
+
- A link opens in a new tab, and its click and Enter stay its own: they
|
|
124
|
+
never reach the row or the card it sits in, even a card of the app's
|
|
125
|
+
own with an `onClick`.
|
|
126
|
+
- It's for one line. Long text is notes, the block `<Markdown>` on the
|
|
127
|
+
record's view.
|
|
128
|
+
|
|
100
129
|
## 2. Icon + label
|
|
101
130
|
|
|
102
131
|
A single-value enum where a glyph speeds up scanning but the word still
|
|
@@ -1596,6 +1625,23 @@ const { page, filters, setFilter, setPage } = useTableUrlState(['kind'])
|
|
|
1596
1625
|
it. An ancestor of your own with `overflow` set (a card with
|
|
1597
1626
|
`overflow-hidden`, say) takes the place of the page: leave it off such a
|
|
1598
1627
|
table's ancestors.
|
|
1628
|
+
- **`stickyTop`**, with `stickyGroupHeadings`, for a page that pins a bar
|
|
1629
|
+
of its own to the top (a page header, a filter bar): how far down the
|
|
1630
|
+
header and headings pin, so they sit under the bar and never behind it.
|
|
1631
|
+
Any CSS length, resolved at the table, so a variable the page sets per
|
|
1632
|
+
breakpoint gives a phone its own offset:
|
|
1633
|
+
|
|
1634
|
+
```tsx
|
|
1635
|
+
<main className="[--page-bar:3.5rem] md:[--page-bar:3rem]">
|
|
1636
|
+
<div className="sticky top-0 z-40 h-(--page-bar) bg-background">…</div>
|
|
1637
|
+
<DataTable stickyGroupHeadings stickyTop="var(--page-bar)" … />
|
|
1638
|
+
</main>
|
|
1639
|
+
```
|
|
1640
|
+
|
|
1641
|
+
When the columns are wider than their box, the box is that much shorter
|
|
1642
|
+
than the screen instead, so once the page is scrolled to it, it fits
|
|
1643
|
+
under the bar and its header pins at its own top. Focus moved to a row
|
|
1644
|
+
clears the bar too. Give the bar a `z-index` above the table's (`z-40`).
|
|
1599
1645
|
- **`header={false}`** for a list-like table whose columns explain
|
|
1600
1646
|
themselves (a thumbnail with a title block, then actions). The header
|
|
1601
1647
|
row takes no room but stays in the table, so the columns keep their
|
|
@@ -3,32 +3,34 @@
|
|
|
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
|
|
7
|
-
- [Glow](#glow) · lines
|
|
8
|
-
- [Semantic tones](#semantic-tones) · lines
|
|
9
|
-
- [The three badge styles](#the-three-badge-styles) · lines
|
|
10
|
-
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines
|
|
11
|
-
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines
|
|
12
|
-
- [Logos and brand marks](#logos-and-brand-marks) · lines
|
|
13
|
-
- [Categorical colour](#categorical-colour) · lines
|
|
14
|
-
- [Heat scale](#heat-scale) · lines
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
18
|
-
|
|
19
|
-
- [
|
|
20
|
-
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
|
|
26
|
-
- [
|
|
27
|
-
- [A list as
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
30
|
-
- [
|
|
31
|
-
- [
|
|
6
|
+
- [Palettes](#palettes) · lines 43–110
|
|
7
|
+
- [Glow](#glow) · lines 112–130
|
|
8
|
+
- [Semantic tones](#semantic-tones) · lines 132–160
|
|
9
|
+
- [The three badge styles](#the-three-badge-styles) · lines 162–179
|
|
10
|
+
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 181–210
|
|
11
|
+
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 212–225
|
|
12
|
+
- [Logos and brand marks](#logos-and-brand-marks) · lines 227–271
|
|
13
|
+
- [Categorical colour](#categorical-colour) · lines 273–343
|
|
14
|
+
- [Heat scale](#heat-scale) · lines 345–406
|
|
15
|
+
- [Depth ramps](#depth-ramps) · lines 408–486
|
|
16
|
+
- [A stored colour](#a-stored-colour) · lines 488–536
|
|
17
|
+
- [Shapes and sizes](#shapes-and-sizes) · lines 538–559
|
|
18
|
+
- [Typography](#typography) · lines 561–671
|
|
19
|
+
- [Written text (notes)](#written-text-notes) · lines 595–671
|
|
20
|
+
- [Density](#density) · lines 673–759
|
|
21
|
+
- [Rows on this device](#rows-on-this-device) · lines 732–759
|
|
22
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 761–875
|
|
23
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 877–954
|
|
24
|
+
- [Notices](#notices) · lines 956–984
|
|
25
|
+
- [A value over time](#a-value-over-time) · lines 986–1072
|
|
26
|
+
- [Several values over time](#several-values-over-time) · lines 1035–1072
|
|
27
|
+
- [A list as a board](#a-list-as-a-board) · lines 1074–1125
|
|
28
|
+
- [A list as cards](#a-list-as-cards) · lines 1127–1173
|
|
29
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1175–1197
|
|
30
|
+
- [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1199–1243
|
|
31
|
+
- [Picking at random](#picking-at-random) · lines 1245–1276
|
|
32
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1278–1345
|
|
33
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1347–1372
|
|
32
34
|
|
|
33
35
|
<!-- /index -->
|
|
34
36
|
|
|
@@ -403,6 +405,86 @@ step against every palette's card and raised surface. `SideBySide` shows
|
|
|
403
405
|
both themes at once, under normal vision and simulated deuteranopia and
|
|
404
406
|
protanopia.
|
|
405
407
|
|
|
408
|
+
## Depth ramps
|
|
409
|
+
|
|
410
|
+
For **depth within one category**: the levels of one kind of thing, where
|
|
411
|
+
the category stays the same and only how deep, how specific or how far
|
|
412
|
+
in changes. A category's subcategories in a chart (Food, then Groceries,
|
|
413
|
+
then Produce), nesting levels of one tree, a stacked bar of one
|
|
414
|
+
category's parts. Every categorical slot has five steps, shallow to deep,
|
|
415
|
+
`--category-N-depth-1` through `--category-N-depth-5`, given by Tailwind
|
|
416
|
+
as `fill-category-N-depth-M` (a shape), `bg-category-N-depth-M` (a cell)
|
|
417
|
+
and `text-category-N-depth-M-foreground` (text on that cell).
|
|
418
|
+
|
|
419
|
+
**Which to use:**
|
|
420
|
+
|
|
421
|
+
| The values are | Use |
|
|
422
|
+
|---|---|
|
|
423
|
+
| different from each other, in no order | the slot itself, `text-category-N` (a glyph's tint) |
|
|
424
|
+
| one category's levels, shallow to deep | its depth ramp, `bg-category-N-depth-M` |
|
|
425
|
+
| amounts in an order, with no category | the heat scale, `bg-heat-M` |
|
|
426
|
+
| good or bad | a tone |
|
|
427
|
+
|
|
428
|
+
- **One ramp per category, its slot's.** A record whose category is slot 3
|
|
429
|
+
draws its levels from slot 3's ramp, so the depth reads as "more of the
|
|
430
|
+
same thing". Two categories side by side each keep their own ramp. A
|
|
431
|
+
ramp's hue stays within about 20° of its slot's, so a step never reads
|
|
432
|
+
as another slot, but steps of two neighbouring slots' ramps can come
|
|
433
|
+
close (orange and brown, blue and navy): tell categories apart by their
|
|
434
|
+
slot's own glyph and name, not by a ramp step alone.
|
|
435
|
+
- **Depth, not amount.** A ramp says "a level of this", never "more of
|
|
436
|
+
this is worse". A count or a total over many categories is the heat
|
|
437
|
+
scale; a status is a tone.
|
|
438
|
+
- **Opaque, at full strength.** Each step clears 3:1 against the card and
|
|
439
|
+
the page in light, dark and every palette (3.03:1 at the least, light
|
|
440
|
+
on `--muted`), so a shape stands out with no outline. An opacity
|
|
441
|
+
modifier (`bg-category-3-depth-2/50`) gives that up.
|
|
442
|
+
- **Text on a fill takes its own foreground.** Which text colour is right
|
|
443
|
+
depends on the step and the theme: pair the two as below. It measures
|
|
444
|
+
4.55:1 at the least.
|
|
445
|
+
- **Neighbours are closer than the heat scale's, so keep a boundary.**
|
|
446
|
+
Neighbouring steps are at least ΔE 17.7 apart in light and 13.9 in
|
|
447
|
+
dark (blue's; every slot but blue and navy 17.4 or more), and 10.3
|
|
448
|
+
under simulated deuteranopia and protanopia. Five steps of one hue that
|
|
449
|
+
each clear 3:1 on the card only have so much lightness to share, dark's
|
|
450
|
+
band most of all. A `stroke-card` or a 1px gap between shapes, as a
|
|
451
|
+
stacked bar's segments have, makes each boundary easy to see.
|
|
452
|
+
- **The order holds without hue.** Each step is darker than the one before
|
|
453
|
+
it in both themes, so a ramp also reads in greyscale. In the dark
|
|
454
|
+
themes step 1 is near white and step 5 the slot's deepest, still 3:1
|
|
455
|
+
on the card.
|
|
456
|
+
- **Never colour alone.** Name the level too, in the cell, a tooltip or
|
|
457
|
+
a legend, and give a shape holding one a name for screen readers.
|
|
458
|
+
- **Five steps, not more.** Deeper nesting than five shares step 5, or
|
|
459
|
+
starts again with a label saying so; don't interpolate between steps.
|
|
460
|
+
|
|
461
|
+
An app maps a slot's levels to whole class names, as the heat scale's
|
|
462
|
+
steps are mapped: Tailwind only generates classes it finds written out.
|
|
463
|
+
|
|
464
|
+
```tsx
|
|
465
|
+
// Slot 3's ramp, shallow to deep.
|
|
466
|
+
const GREEN_DEPTH = [
|
|
467
|
+
{ fill: 'fill-category-3-depth-1', cell: 'bg-category-3-depth-1 text-category-3-depth-1-foreground' },
|
|
468
|
+
{ fill: 'fill-category-3-depth-2', cell: 'bg-category-3-depth-2 text-category-3-depth-2-foreground' },
|
|
469
|
+
{ fill: 'fill-category-3-depth-3', cell: 'bg-category-3-depth-3 text-category-3-depth-3-foreground' },
|
|
470
|
+
{ fill: 'fill-category-3-depth-4', cell: 'bg-category-3-depth-4 text-category-3-depth-4-foreground' },
|
|
471
|
+
{ fill: 'fill-category-3-depth-5', cell: 'bg-category-3-depth-5 text-category-3-depth-5-foreground' },
|
|
472
|
+
] as const
|
|
473
|
+
|
|
474
|
+
<rect className={`${GREEN_DEPTH[level - 1].fill} stroke-card`} />
|
|
475
|
+
<td className={GREEN_DEPTH[level - 1].cell}>{name}</td>
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
The package's fixtures render every ramp (`patterns/DepthRamps`). Its
|
|
479
|
+
Default story runs through axe and the token check in light and dark, axe
|
|
480
|
+
in every palette too, and a check that measures every step of every
|
|
481
|
+
slot, as a fill and as a cell, against the page and a card in each.
|
|
482
|
+
`tests/depth-ramps.test.ts` holds the distance between neighbours (17 in
|
|
483
|
+
light, 13.5 in dark, 10 with deuteranopia and protanopia), the order of
|
|
484
|
+
lightness, text on every fill and every step against every palette's card
|
|
485
|
+
and raised surface. `SideBySide` shows both themes at once, under normal
|
|
486
|
+
vision and simulated deuteranopia and protanopia.
|
|
487
|
+
|
|
406
488
|
## A stored colour
|
|
407
489
|
|
|
408
490
|
A colour the user stored as data (a paint's hex, a label's colour, a
|
|
@@ -512,6 +594,10 @@ height and weight together, from tokens in the package's `styles/theme.css`:
|
|
|
512
594
|
|
|
513
595
|
### Written text (notes)
|
|
514
596
|
|
|
597
|
+
A one-line value written as Markdown (a cell, a card's line) is
|
|
598
|
+
`<Markdown inline>` instead: no headings or blocks, the font and colour
|
|
599
|
+
of where it sits (cell-patterns.md, pattern 1).
|
|
600
|
+
|
|
515
601
|
Long text written as Markdown (`<Markdown>` and `RichTextEditor`) has its
|
|
516
602
|
own three heading roles, so `#`, `##` and `###` in a note never look
|
|
517
603
|
alike. They're for headings inside the text only, never a screen's own
|
|
@@ -1110,6 +1196,52 @@ row under the header, across the page at every width.
|
|
|
1110
1196
|
- **`subtitle`** is the line under the title: what the record is for,
|
|
1111
1197
|
in muted body type, editable in place like any value.
|
|
1112
1198
|
|
|
1199
|
+
## A record's tabs, mark and rail
|
|
1200
|
+
|
|
1201
|
+
Three opt-ins on `EntityView` (4.76), each for a record that needs it;
|
|
1202
|
+
a record without them is as it was.
|
|
1203
|
+
|
|
1204
|
+
```tsx
|
|
1205
|
+
<EntityView
|
|
1206
|
+
layout="rail"
|
|
1207
|
+
mobileOrder="main-first"
|
|
1208
|
+
leading={<img src={photo} alt="" className="size-12 rounded-full object-cover" />}
|
|
1209
|
+
railFields="beside"
|
|
1210
|
+
sections={[
|
|
1211
|
+
{ title: 'Summary', placement: 'rail', fields },
|
|
1212
|
+
{ title: 'Notes', content: <Markdown>{notes}</Markdown> },
|
|
1213
|
+
{ title: 'Steps', tab: 'Steps', content: steps },
|
|
1214
|
+
{ title: 'Where it applies', tab: 'Used in', content: uses },
|
|
1215
|
+
{ title: 'Why this order', tab: 'Reasoning', content: reasoning },
|
|
1216
|
+
]}
|
|
1217
|
+
… />
|
|
1218
|
+
```
|
|
1219
|
+
|
|
1220
|
+
- **Tabs** (`tab` on a main section): a line tab list at the top of
|
|
1221
|
+
the main column, under the strip and any sections with no tab, one
|
|
1222
|
+
tab per name in the order the sections first give it. The selected
|
|
1223
|
+
tab has foreground text and a 2px underline, the others muted text;
|
|
1224
|
+
the list's own bottom border runs the column's width. On a phone each
|
|
1225
|
+
tab is 44px tall, and a list wider than the column scrolls sideways on
|
|
1226
|
+
its own, never the page. Arrow keys move between tabs and select
|
|
1227
|
+
(Home, End), and Tab goes on into the panel. The address holds the
|
|
1228
|
+
selected tab (`?tab=used-in`, `entityViewTabSlug`), replaced rather
|
|
1229
|
+
than pushed, so Back leaves the record, not the tab. Every tab's
|
|
1230
|
+
sections stay mounted, so a value open in place survives a switch.
|
|
1231
|
+
Short tab names, one or two words; no counts or icons in them yet.
|
|
1232
|
+
- **A mark or avatar** (`leading`): left of the title, top-aligned,
|
|
1233
|
+
with the title, subtitle and badges beside it at every width. 40 to
|
|
1234
|
+
64px (`size-10` to `size-16`): an avatar round (`rounded-full`), a
|
|
1235
|
+
mark or cover in a rounded square (`rounded-lg`). Decorative, since
|
|
1236
|
+
the title names the record (`alt=""`, `aria-hidden`); initials in
|
|
1237
|
+
foreground on `bg-muted`, an icon in muted foreground on the card
|
|
1238
|
+
with its border. "Logos and brand marks" above holds for a logo here.
|
|
1239
|
+
- **Rail fields beside** (`railFields="beside"`): the label in a 6 to
|
|
1240
|
+
7rem column left of its value, baseline-aligned, rows a little tighter
|
|
1241
|
+
than stacked. Where the rail's list is under 18rem (a phone narrower
|
|
1242
|
+
than ~350px) it stacks as before, and once the rail stacks full width
|
|
1243
|
+
the label column widens to the page's.
|
|
1244
|
+
|
|
1113
1245
|
## Picking at random
|
|
1114
1246
|
|
|
1115
1247
|
`SpinWheel` (4.42) picks one of a few candidates by chance, for "what do
|
|
@@ -97,6 +97,16 @@ export type DataTableProps<TData extends Record<string, unknown>> = {
|
|
|
97
97
|
* Ungrouped, it changes nothing.
|
|
98
98
|
*/
|
|
99
99
|
stickyGroupHeadings?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* With `stickyGroupHeadings`: how far from the top of the screen the
|
|
102
|
+
* pinned header and headings sit, for a page with a bar of its own pinned
|
|
103
|
+
* to the top. Any CSS length (`'3.5rem'`, `'var(--page-bar-height)'`),
|
|
104
|
+
* resolved at the table, so a variable the page sets per breakpoint gives
|
|
105
|
+
* a phone and a desktop their own offset. When the columns are wider than
|
|
106
|
+
* their box, the box is that much shorter than the screen instead, so it
|
|
107
|
+
* fits below the bar. Without it, they sit at the very top (`0px`).
|
|
108
|
+
*/
|
|
109
|
+
stickyTop?: string;
|
|
100
110
|
/**
|
|
101
111
|
* The fields the rows can be grouped by, picked in a Group menu at the
|
|
102
112
|
* end of the toolbar: None (the default, the table as it is without
|
|
@@ -284,4 +294,4 @@ export type DataTableTotals = {
|
|
|
284
294
|
*/
|
|
285
295
|
cells?: Partial<Record<string, ReactNode>>;
|
|
286
296
|
};
|
|
287
|
-
export declare function DataTable<TData extends Record<string, unknown>>({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, groupBy, groupSummary, stickyGroupHeadings, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, }: DataTableProps<TData>): import("react").JSX.Element;
|
|
297
|
+
export declare function DataTable<TData extends Record<string, unknown>>({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, }: DataTableProps<TData>): import("react").JSX.Element;
|
|
@@ -188,18 +188,22 @@ const GROUP_HEADING_CLASS = 'h-auto bg-background pt-4 pb-1.5 align-bottom';
|
|
|
188
188
|
// scroll sideways, so it's bounded to the screen and scrolls down too.
|
|
189
189
|
// `isolate` keeps these z-indexes inside the table.
|
|
190
190
|
const STICKY_PAGE_SCROLL_CLASS = 'isolate overflow-x-clip';
|
|
191
|
-
const STICKY_OWN_SCROLL_CLASS = 'isolate max-h-
|
|
191
|
+
const STICKY_OWN_SCROLL_CLASS = 'isolate max-h-[calc(100dvh-var(--data-table-sticky-top))] overflow-auto';
|
|
192
192
|
// Collapsed borders stay where the row was, so a stuck cell draws its rule
|
|
193
193
|
// as an inset shadow and its row's border comes off. Above the pinned
|
|
194
194
|
// columns (z-10): the column header over the headings over the rows. A
|
|
195
195
|
// cell's sticky bounds are the whole table, not its group, so a heading isn't
|
|
196
196
|
// pushed off by the next: the next slides over it, later in the DOM and opaque.
|
|
197
197
|
const STICKY_RULE_CLASS = 'shadow-[inset_0_-1px_0_0_var(--border)]';
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
//
|
|
199
|
+
// `stickyTop` moves both down by --data-table-pin-top: the app's offset on the
|
|
200
|
+
// page's scroll, none in a box of the table's own (that box's top is its own,
|
|
201
|
+
// and the box is shortened by the offset instead).
|
|
202
|
+
const STICKY_HEAD_CELL_CLASS = `sticky top-(--data-table-pin-top) z-30 bg-background ${STICKY_RULE_CLASS}`;
|
|
203
|
+
const STICKY_GROUP_HEADING_CLASS = `sticky top-[calc(var(--data-table-pin-top)+var(--data-table-head-height))] z-20 pt-2 ${STICKY_RULE_CLASS}`;
|
|
200
204
|
// What focus scrolls to clears the stuck header and heading (3rem covers a
|
|
201
205
|
// heading's height, large density included).
|
|
202
|
-
const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-head-height)+--spacing(12))]';
|
|
206
|
+
const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-pin-top)+var(--data-table-head-height)+--spacing(12))]';
|
|
203
207
|
// A grouping's heading (`groupings`) is a button that folds its rows: the
|
|
204
208
|
// label, then the count, a chevron that turns when folded.
|
|
205
209
|
const GROUP_TOGGLE_CLASS = '-mx-1 inline-flex items-baseline gap-2 rounded-sm px-1 outline-none hover:underline ' +
|
|
@@ -316,7 +320,7 @@ function useStickyHeadings(containerRef, enabled) {
|
|
|
316
320
|
}, [containerRef, enabled]);
|
|
317
321
|
return { scrollsSideways, headHeight };
|
|
318
322
|
}
|
|
319
|
-
export function DataTable({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'full', groupBy, groupSummary, stickyGroupHeadings = false, header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
|
|
323
|
+
export function DataTable({ columns, data, total, page, pageSize, onPageChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'full', groupBy, groupSummary, stickyGroupHeadings = false, stickyTop = '0px', header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', }) {
|
|
320
324
|
// The switch's own state, for a table that doesn't pass `layout`.
|
|
321
325
|
const [ownLayout, setOwnLayout] = useState('table');
|
|
322
326
|
const requestedLayout = layoutProp ?? ownLayout;
|
|
@@ -593,7 +597,13 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
|
|
|
593
597
|
return;
|
|
594
598
|
event.preventDefault();
|
|
595
599
|
closeDetail();
|
|
596
|
-
}, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null, children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS),
|
|
600
|
+
}, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null, children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS), containerStyle: stickyGroups
|
|
601
|
+
? {
|
|
602
|
+
'--data-table-head-height': `${headHeight}px`,
|
|
603
|
+
'--data-table-sticky-top': stickyTop,
|
|
604
|
+
'--data-table-pin-top': scrollsSideways ? '0px' : stickyTop,
|
|
605
|
+
}
|
|
606
|
+
: undefined,
|
|
597
607
|
// With the sticky bar below as the visible scrollbar, hide the
|
|
598
608
|
// container's own. It stays overflow-x-auto and fully
|
|
599
609
|
// scrollable (wheel, trackpad, drag, and the sync effect); it
|
|
@@ -59,6 +59,14 @@ export type EntityViewSection = ({
|
|
|
59
59
|
print?: boolean | {
|
|
60
60
|
answerSpace?: boolean;
|
|
61
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* The tab the section goes under, by name ("Steps", "Used in"): main
|
|
64
|
+
* sections only (a `rail` one ignores it). Any main section with a tab
|
|
65
|
+
* adds a tab list to the main column, one tab per name in the order the
|
|
66
|
+
* sections first give it; sections without one stay above the list. The
|
|
67
|
+
* selected tab is in the address, `?tab=<slug of the name>`.
|
|
68
|
+
*/
|
|
69
|
+
tab?: string;
|
|
62
70
|
};
|
|
63
71
|
export type EntityViewPlacement = 'main' | 'rail';
|
|
64
72
|
/**
|
|
@@ -72,6 +80,12 @@ export type EntityViewLayout = 'column' | 'rail';
|
|
|
72
80
|
* or a narrow content area): `rail-first` (the default) or `main-first`.
|
|
73
81
|
*/
|
|
74
82
|
export type EntityViewMobileOrder = 'rail-first' | 'main-first';
|
|
83
|
+
/**
|
|
84
|
+
* How a rail section's fields lay out: `stacked` (the default), each label
|
|
85
|
+
* above its value; `beside`, the label to the left of its value, stacked
|
|
86
|
+
* where the rail's list is narrower than 18rem (a small phone).
|
|
87
|
+
*/
|
|
88
|
+
export type EntityViewRailFields = 'stacked' | 'beside';
|
|
75
89
|
export type EntityViewProps = {
|
|
76
90
|
/** The record's name or title, the page's <h1>, and the browser tab's once it loads (`documentTitle`). */
|
|
77
91
|
title?: string;
|
|
@@ -86,6 +100,14 @@ export type EntityViewProps = {
|
|
|
86
100
|
titleEdit?: EditInPlace & {
|
|
87
101
|
label: string;
|
|
88
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Left of the title, top-aligned with it: the record's mark or avatar
|
|
105
|
+
* (an image, an icon, initials), at a size of the screen's own choosing
|
|
106
|
+
* (`size-10` to `size-16`). The title, subtitle and badges sit beside it
|
|
107
|
+
* at every width. Decorative unless it says something the title doesn't:
|
|
108
|
+
* give an image `alt=""`.
|
|
109
|
+
*/
|
|
110
|
+
leading?: ReactNode;
|
|
89
111
|
/**
|
|
90
112
|
* A line under the title, in muted body type: what the record is for (a
|
|
91
113
|
* goal, a one-line summary). Any markup, an `<EditableValue>` included,
|
|
@@ -134,6 +156,14 @@ export type EntityViewProps = {
|
|
|
134
156
|
printLabel?: string;
|
|
135
157
|
/** The rail's landmark name (its `<aside>`). Defaults to the title + " details". */
|
|
136
158
|
railLabel?: string;
|
|
159
|
+
/**
|
|
160
|
+
* In the `rail` layout, a rail section's fields: each label above its
|
|
161
|
+
* value (`stacked`, the default), or to its left (`beside`), falling back
|
|
162
|
+
* to stacked where the rail is too narrow for both. Once the rail's
|
|
163
|
+
* sections stack full width on a narrower screen, labels sit beside
|
|
164
|
+
* values either way.
|
|
165
|
+
*/
|
|
166
|
+
railFields?: EntityViewRailFields;
|
|
137
167
|
isLoading: boolean;
|
|
138
168
|
/** A `notfound` error (including another user's record) shows "Not found" and a way back, never a retry. */
|
|
139
169
|
error?: AppError | null;
|
|
@@ -144,4 +174,4 @@ export type EntityViewProps = {
|
|
|
144
174
|
label: string;
|
|
145
175
|
};
|
|
146
176
|
};
|
|
147
|
-
export declare function EntityView({ title, documentTitle, titleEdit, subtitle, badges, actions, notice, strip, sections, footer, layout, mobileOrder, railLabel, printLabel, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|
|
177
|
+
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, mobileOrder, railLabel, railFields, printLabel, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|