@tristan2828/ui-foundation 4.73.0 → 4.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,31 +3,32 @@
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 40–106
7
- - [Glow](#glow) · lines 108–126
8
- - [Semantic tones](#semantic-tones) · lines 128–156
9
- - [The three badge styles](#the-three-badge-styles) · lines 158–175
10
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 177–206
11
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 208–221
12
- - [Logos and brand marks](#logos-and-brand-marks) · lines 223–267
13
- - [Categorical colour](#categorical-colour) · lines 269–339
14
- - [A stored colour](#a-stored-colour) · lines 341–389
15
- - [Shapes and sizes](#shapes-and-sizes) · lines 391–412
16
- - [Typography](#typography) · lines 414–520
17
- - [Written text (notes)](#written-text-notes) · lines 448–520
18
- - [Density](#density) · lines 522–608
19
- - [Rows on this device](#rows-on-this-device) · lines 581–608
20
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 610–724
21
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 726–795
22
- - [Notices](#notices) · lines 797–825
23
- - [A value over time](#a-value-over-time) · lines 827–913
24
- - [Several values over time](#several-values-over-time) · lines 876–913
25
- - [A list as a board](#a-list-as-a-board) · lines 915–966
26
- - [A list as cards](#a-list-as-cards) · lines 968–1014
27
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1016–1038
28
- - [Picking at random](#picking-at-random) · lines 1040–1071
29
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1073–1140
30
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1142–1167
6
+ - [Palettes](#palettes) · lines 41–108
7
+ - [Glow](#glow) · lines 110–128
8
+ - [Semantic tones](#semantic-tones) · lines 130–158
9
+ - [The three badge styles](#the-three-badge-styles) · lines 160–177
10
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 179–208
11
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 210–223
12
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 225–269
13
+ - [Categorical colour](#categorical-colour) · lines 271–341
14
+ - [Heat scale](#heat-scale) · lines 343–404
15
+ - [A stored colour](#a-stored-colour) · lines 406–454
16
+ - [Shapes and sizes](#shapes-and-sizes) · lines 456–477
17
+ - [Typography](#typography) · lines 479–585
18
+ - [Written text (notes)](#written-text-notes) · lines 513–585
19
+ - [Density](#density) · lines 587–673
20
+ - [Rows on this device](#rows-on-this-device) · lines 646–673
21
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 675–789
22
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 791–860
23
+ - [Notices](#notices) · lines 862–890
24
+ - [A value over time](#a-value-over-time) · lines 892–978
25
+ - [Several values over time](#several-values-over-time) · lines 941–978
26
+ - [A list as a board](#a-list-as-a-board) · lines 980–1031
27
+ - [A list as cards](#a-list-as-cards) · lines 1033–1079
28
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1081–1103
29
+ - [Picking at random](#picking-at-random) · lines 1105–1136
30
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1138–1205
31
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1207–1232
31
32
 
32
33
  <!-- /index -->
33
34
 
@@ -95,7 +96,8 @@ wear it too. An installed app's colours follow it with
95
96
 
96
97
  The package's `e2e/fixtures-visual.spec.ts` runs every primitive,
97
98
  composite and tone story through axe in each palette, and measures every
98
- glyph and categorical slot against each palette's page and card.
99
+ glyph, categorical slot and heat step against each palette's page and
100
+ card.
99
101
 
100
102
  **An app's own axe specs** check its palettes instead of light and dark:
101
103
  `defineA11ySuite({ …, palettes: ['indigo-cyan'] })` (and
@@ -338,6 +340,69 @@ If you find yourself wanting a thirteenth, that is a sign the column should
338
340
  be showing a shape or a label rather than more colours: there is no more
339
341
  room that stays readable.
340
342
 
343
+ ## Heat scale
344
+
345
+ For values that have an **order**: how much, how often, how hot. A heat
346
+ map, a calendar shaded by activity, a grid of counts. Five steps from
347
+ cold to hot, `--heat-1` through `--heat-5`. Tailwind gives each one as
348
+ `fill-heat-1` (a shape), `bg-heat-1` (a cell) and `text-heat-1-foreground`
349
+ (text on that cell).
350
+
351
+ **Use it only for ordered values.** A value that's good or bad is a tone
352
+ (hot is not "bad" here, and red here says nothing about danger). A value
353
+ that's only different from its neighbours is a categorical slot: the scale
354
+ would claim one category is more than another. Beside tone badges, keep
355
+ heat out of the same column.
356
+
357
+ An app sorts its values into the five steps itself, on rules it writes
358
+ down (thresholds, or an even split of the range), and maps each to whole
359
+ class names:
360
+
361
+ ```tsx
362
+ const HEAT = [
363
+ { fill: 'fill-heat-1', cell: 'bg-heat-1 text-heat-1-foreground' },
364
+ { fill: 'fill-heat-2', cell: 'bg-heat-2 text-heat-2-foreground' },
365
+ { fill: 'fill-heat-3', cell: 'bg-heat-3 text-heat-3-foreground' },
366
+ { fill: 'fill-heat-4', cell: 'bg-heat-4 text-heat-4-foreground' },
367
+ { fill: 'fill-heat-5', cell: 'bg-heat-5 text-heat-5-foreground' },
368
+ ] as const
369
+
370
+ <path className={`${HEAT[step - 1].fill} stroke-card`} d={shape} />
371
+ <td className={HEAT[step - 1].cell}>{count}</td>
372
+ ```
373
+
374
+ - **Opaque, at full strength.** Each step clears 3:1 against the card and
375
+ the page in light, dark and every palette, so a shape stands out with
376
+ no outline. An opacity modifier (`bg-heat-3/50`) gives that up.
377
+ - **Text on a fill takes its own foreground.** Pair the two as above: the
378
+ right text colour depends on the step and the theme. `text-foreground`
379
+ or muted text on a fill fails. It measures 4.71:1 at the least.
380
+ - **Neighbours can touch.** Neighbouring steps are at least ΔE 17.8 apart
381
+ (the perceived difference) and 12.6 under simulated deuteranopia and
382
+ protanopia, the common red-green deficiencies. A thin `stroke-card`
383
+ between shapes still helps, since a boundary is easier to see than a
384
+ shade.
385
+ - **The order holds without hue.** Each step is darker than the one before
386
+ it in both themes, so the scale also reads in greyscale. Hot is always
387
+ the red end, which in the dark themes means it is the darker end too.
388
+ - **Never colour alone.** Show the value too, in the cell, a tooltip or
389
+ a legend of the steps. A shape holding a value needs a name for screen
390
+ readers.
391
+ - **Nothing to show is not step 1.** Step 1 is the coldest *value*. No data
392
+ stays `fill-muted` or an empty state, so "none" and "cold" don't look
393
+ alike.
394
+ - **Five steps, not more.** Past five, neighbours stop being readable as
395
+ different. Bin the values rather than interpolating between steps.
396
+
397
+ The package's fixtures render it (`patterns/HeatScale`). Its Default story
398
+ runs through axe and the token check in light and dark, axe in every
399
+ palette too, and a check that measures every step, as a fill and as a
400
+ cell, against the page and a card in each. `tests/heat-scale.test.ts`
401
+ holds the distance between neighbours, the order of lightness and every
402
+ step against every palette's card and raised surface. `SideBySide` shows
403
+ both themes at once, under normal vision and simulated deuteranopia and
404
+ protanopia.
405
+
341
406
  ## A stored colour
342
407
 
343
408
  A colour the user stored as data (a paint's hex, a label's colour, a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.73.0",
3
+ "version": "4.74.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/styles/index.css CHANGED
@@ -79,6 +79,16 @@
79
79
  --color-category-10: var(--category-10);
80
80
  --color-category-11: var(--category-11);
81
81
  --color-category-12: var(--category-12);
82
+ --color-heat-1: var(--heat-1);
83
+ --color-heat-1-foreground: var(--heat-1-foreground);
84
+ --color-heat-2: var(--heat-2);
85
+ --color-heat-2-foreground: var(--heat-2-foreground);
86
+ --color-heat-3: var(--heat-3);
87
+ --color-heat-3-foreground: var(--heat-3-foreground);
88
+ --color-heat-4: var(--heat-4);
89
+ --color-heat-4-foreground: var(--heat-4-foreground);
90
+ --color-heat-5: var(--heat-5);
91
+ --color-heat-5-foreground: var(--heat-5-foreground);
82
92
  --color-accent-foreground: var(--accent-foreground);
83
93
  --color-accent: var(--accent);
84
94
  --color-muted-foreground: var(--muted-foreground);
package/styles/theme.css CHANGED
@@ -110,6 +110,38 @@
110
110
  --category-11-400: oklch(0.823 0.163 119);
111
111
  --category-12-700: oklch(0.423 0.181 337); /* magenta */
112
112
  --category-12-400: oklch(0.648 0.232 337);
113
+ /*
114
+ * The heat scale (design-language.md "Heat scale"). Five steps from cold
115
+ * to hot, for values that have an order: a heat map, a calendar of how
116
+ * much. Not status (tones) and not categories (the slots above).
117
+ *
118
+ * Opaque fills, unlike the slots: each step has its own --heat-N-foreground
119
+ * for text on it. Lightness falls at every step in both themes, so the
120
+ * order survives in greyscale and for colour-blind readers, and hue runs
121
+ * blue, teal, gold, orange, red, so the cold half and the hot half never
122
+ * meet (blue against yellow survives red-green colour blindness).
123
+ *
124
+ * Measured from these values (tests/heat-scale.test.ts holds neighbours to
125
+ * ΔE 15, 10 under simulated deuteranopia and protanopia, and every step to
126
+ * 3:1 on every card):
127
+ * neighbours light ΔE 20.9 to 34.2, deuteranopia/protanopia 13.1 or more
128
+ * dark ΔE 17.8 to 34.6, deuteranopia/protanopia 12.6 or more
129
+ * on white 3.33 / 3.55 / 4.20 / 6.34 / 10.47 (3.06 at the least on --muted)
130
+ * on dark's card 11.5 / 8.60 / 7.39 / 5.52 / 4.46
131
+ * on palette cards 3.96 at the least (step 5, Graphite); 3.43 on its raised surface
132
+ * text on the fill 4.71 at the least: black on steps 1-3 in light, white
133
+ * on 4 and 5, black on every step in dark
134
+ */
135
+ --heat-1-700: oklch(0.645 0.13 262); /* blue */
136
+ --heat-1-400: oklch(0.85 0.08 240);
137
+ --heat-2-700: oklch(0.614 0.104 188); /* teal */
138
+ --heat-2-400: oklch(0.758 0.085 185);
139
+ --heat-3-700: oklch(0.584 0.114 97); /* gold */
140
+ --heat-3-400: oklch(0.725 0.148 98);
141
+ --heat-4-700: oklch(0.5 0.133 47); /* orange */
142
+ --heat-4-400: oklch(0.661 0.13 47);
143
+ --heat-5-700: oklch(0.388 0.15 20); /* red */
144
+ --heat-5-400: oklch(0.615 0.16 20); /* a purer red goes nearly black under protanopia */
113
145
  --blue-500: oklch(0.488 0.243 264.376);
114
146
 
115
147
  /*
@@ -349,6 +381,17 @@
349
381
  --category-10: var(--category-10-700);
350
382
  --category-11: var(--category-11-700);
351
383
  --category-12: var(--category-12-700);
384
+ /* The heat scale: an opaque fill, with its own text colour. */
385
+ --heat-1: var(--heat-1-700);
386
+ --heat-1-foreground: var(--black);
387
+ --heat-2: var(--heat-2-700);
388
+ --heat-2-foreground: var(--black);
389
+ --heat-3: var(--heat-3-700);
390
+ --heat-3-foreground: var(--black);
391
+ --heat-4: var(--heat-4-700);
392
+ --heat-4-foreground: var(--white);
393
+ --heat-5: var(--heat-5-700);
394
+ --heat-5-foreground: var(--white);
352
395
  /* The zebra stripe (table.tsx: bg-muted/40 on even rows) mixed onto the
353
396
  page, opaque: what a pinned table cell paints on an even row, so it
354
397
  matches the row without letting scrolled columns show through. Mixed
@@ -517,6 +560,17 @@
517
560
  --category-10: var(--category-10-400);
518
561
  --category-11: var(--category-11-400);
519
562
  --category-12: var(--category-12-400);
563
+ /* The heat scale: lighter steps to clear the dark surfaces, black text on all. */
564
+ --heat-1: var(--heat-1-400);
565
+ --heat-1-foreground: var(--black);
566
+ --heat-2: var(--heat-2-400);
567
+ --heat-2-foreground: var(--black);
568
+ --heat-3: var(--heat-3-400);
569
+ --heat-3-foreground: var(--black);
570
+ --heat-4: var(--heat-4-400);
571
+ --heat-4-foreground: var(--black);
572
+ --heat-5: var(--heat-5-400);
573
+ --heat-5-foreground: var(--black);
520
574
  --table-stripe: color-mix(in srgb, var(--muted) 40%, var(--background));
521
575
  --table-highlight: color-mix(in srgb, var(--info) 20%, var(--background));
522
576
  --table-highlight-muted-foreground: var(--gray-400); /* the usual muted: not var(--muted-foreground), which the row redefines from this */
@@ -547,7 +601,7 @@
547
601
  * the dark theme, so a block below always sits on top of .dark and sets
548
602
  * only what differs from it. The solid fills (--destructive, --success,
549
603
  * --warning, --info, each with white -foreground), --info-text, the
550
- * highlight washes and the categorical slots stay .dark's.
604
+ * highlight washes, the categorical slots and the heat scale stay .dark's.
551
605
  *
552
606
  * --ring is the accent (4.24 to 5.25 on the page), not the guide's
553
607
  * accent deep (2.30 to 2.91, under the 3:1 a focus ring needs).