@charcuterie/ui 3.31.0 → 3.32.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/README.md +14 -0
- package/dist/ActionTiles/ActionTiles.d.ts +115 -0
- package/dist/ActionTiles/ActionTiles.d.ts.map +1 -0
- package/dist/ActionTiles/ActionTiles.js +115 -0
- package/dist/ActionTiles/ActionTiles.js.map +1 -0
- package/dist/RadioGroup/RadioGroup.d.ts +10 -0
- package/dist/RadioGroup/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup/RadioGroup.js +12 -39
- package/dist/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/RadioGroup/RadioGroupOption.d.ts.map +1 -1
- package/dist/RadioGroup/RadioGroupOption.js +3 -33
- package/dist/RadioGroup/RadioGroupOption.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/tileStyles.d.ts +83 -0
- package/dist/tileStyles.d.ts.map +1 -0
- package/dist/tileStyles.js +98 -0
- package/dist/tileStyles.js.map +1 -0
- package/package.json +1 -1
- package/src/ActionTiles/ActionTiles.mdx +131 -0
- package/src/ActionTiles/ActionTiles.stories.tsx +311 -0
- package/src/ActionTiles/ActionTiles.test.tsx +292 -0
- package/src/ActionTiles/ActionTiles.tsx +292 -0
- package/src/RadioGroup/RadioGroup.mdx +7 -0
- package/src/RadioGroup/RadioGroup.tsx +16 -42
- package/src/RadioGroup/RadioGroupOption.tsx +8 -38
- package/src/index.ts +5 -0
- package/src/sourceRules.test.ts +9 -1
- package/src/tileStyles.ts +118 -0
|
@@ -3,6 +3,12 @@ import type { ReactNode } from "react"
|
|
|
3
3
|
import { useEffect } from "react"
|
|
4
4
|
|
|
5
5
|
import { FOCUS_RING_CLASS } from "../intentStyles.ts"
|
|
6
|
+
import {
|
|
7
|
+
TILE_BOX_CLASS,
|
|
8
|
+
TILE_HINT_TEXT_CLASS,
|
|
9
|
+
TILE_PADDING_CLASS,
|
|
10
|
+
TILE_TEXT_SIZE_CLASS,
|
|
11
|
+
} from "../tileStyles.ts"
|
|
6
12
|
import { toClassName } from "../toClassName.ts"
|
|
7
13
|
import type {
|
|
8
14
|
RadioItem,
|
|
@@ -42,42 +48,6 @@ const DOT_SIZE_CLASS: Record<ControlSize, string> = {
|
|
|
42
48
|
lg: "size-2.5",
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
const TEXT_SIZE_CLASS: Record<ControlSize, string> = {
|
|
46
|
-
sm: "text-sm",
|
|
47
|
-
md: "text-md",
|
|
48
|
-
lg: "text-lg",
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* One step down from the option's own text, and never below `xs`:
|
|
53
|
-
* a hint that keeps shrinking with the density axis is the 11px
|
|
54
|
-
* caption the 2026-08-10 ramp rebuild exists to have removed.
|
|
55
|
-
*/
|
|
56
|
-
const HINT_TEXT_CLASS: Record<ControlSize, string> = {
|
|
57
|
-
sm: "text-xs",
|
|
58
|
-
md: "text-xs",
|
|
59
|
-
lg: "text-sm",
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* A tile is a card, so its padding is a card's rather than a
|
|
64
|
-
* control's — enough that the border reads as a box around content
|
|
65
|
-
* and not as an outline on a line of text.
|
|
66
|
-
*/
|
|
67
|
-
const TILE_PADDING_CLASS: Record<ControlSize, string> = {
|
|
68
|
-
sm: "px-3 py-2.5",
|
|
69
|
-
md: "px-3.5 py-3",
|
|
70
|
-
lg: "px-4 py-3.5",
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* The box, and only the box. Every state below it is a **border and
|
|
75
|
-
* a surface**, never colour alone — the same reason `Stepper`
|
|
76
|
-
* refuses to say "done" with a hue.
|
|
77
|
-
*/
|
|
78
|
-
const TILE_BOX_CLASS =
|
|
79
|
-
"rounded-lg border border-border-subtle bg-surface-raised"
|
|
80
|
-
|
|
81
51
|
/**
|
|
82
52
|
* Its own file for the same reason `SegmentedOption` is: **both
|
|
83
53
|
* registrations are effects**, and an effect cannot run in a loop.
|
|
@@ -152,7 +122,7 @@ export const RadioGroupOption = ({
|
|
|
152
122
|
? "items-center"
|
|
153
123
|
: "items-start",
|
|
154
124
|
),
|
|
155
|
-
|
|
125
|
+
TILE_TEXT_SIZE_CLASS[size],
|
|
156
126
|
// Disabled turns the whole option down with `opacity-60`, the
|
|
157
127
|
// same family treatment as `Checkbox` and `Switch`, rather than
|
|
158
128
|
// fading the ring to a token that disappeared on a pale theme.
|
|
@@ -252,7 +222,7 @@ export const RadioGroupOption = ({
|
|
|
252
222
|
<span
|
|
253
223
|
className={toClassName(
|
|
254
224
|
"font-normal text-content-muted",
|
|
255
|
-
|
|
225
|
+
TILE_HINT_TEXT_CLASS[size],
|
|
256
226
|
)}
|
|
257
227
|
>
|
|
258
228
|
{hint}
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,11 @@ export type {
|
|
|
37
37
|
AccordionProps,
|
|
38
38
|
} from "./Accordion/Accordion.tsx"
|
|
39
39
|
export { Accordion } from "./Accordion/Accordion.tsx"
|
|
40
|
+
export type {
|
|
41
|
+
ActionTileItem,
|
|
42
|
+
ActionTilesProps,
|
|
43
|
+
} from "./ActionTiles/ActionTiles.tsx"
|
|
44
|
+
export { ActionTiles } from "./ActionTiles/ActionTiles.tsx"
|
|
40
45
|
export type { AdaptiveGridProps } from "./AdaptiveGrid/AdaptiveGrid.tsx"
|
|
41
46
|
export { AdaptiveGrid } from "./AdaptiveGrid/AdaptiveGrid.tsx"
|
|
42
47
|
export type { ColumnChoice } from "./AdaptiveGrid/chooseColumns.ts"
|
package/src/sourceRules.test.ts
CHANGED
|
@@ -537,7 +537,15 @@ test("the barrel is the only place components are re-exported", async () => {
|
|
|
537
537
|
// active-path rule an app's tests want to assert directly, and
|
|
538
538
|
// `useNavLayout.ts`, because the app has to read the width rule to
|
|
539
539
|
// know which corner to render into.
|
|
540
|
-
|
|
540
|
+
//
|
|
541
|
+
// `ActionTiles` is +1 -> 62. It is `RadioGroup itemShape="tile"`
|
|
542
|
+
// with the radio taken away: the box is shared through
|
|
543
|
+
// `tileStyles.ts`, and nothing else is. The 2026-08-25 record that
|
|
544
|
+
// made the choice tile a `RadioGroup` shape named this case under
|
|
545
|
+
// what it deliberately does not cover — a tile that navigates is
|
|
546
|
+
// not a radio, and giving one `aria-checked` would be worse than
|
|
547
|
+
// the paint it replaced.
|
|
548
|
+
expect(componentNames.length).toBe(62)
|
|
541
549
|
|
|
542
550
|
for (const name of componentNames) {
|
|
543
551
|
expect(barrel).toContain(`export { ${name} }`)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tile shape, shared by the two components that draw it.
|
|
3
|
+
*
|
|
4
|
+
* A tile is a bordered card carrying a name and a line of help, laid
|
|
5
|
+
* out in a grid that gains columns with its CONTAINER. `RadioGroup`
|
|
6
|
+
* draws one per option when `itemShape="tile"`; `ActionTiles` draws
|
|
7
|
+
* one per action. The two must be the **same box** — a page that puts
|
|
8
|
+
* "which activity" beside "what would you like to do" would otherwise
|
|
9
|
+
* show two cards with different padding, different corners and
|
|
10
|
+
* different gaps, which is the drift this file exists to make
|
|
11
|
+
* impossible.
|
|
12
|
+
*
|
|
13
|
+
* Same argument as `CONTROL_BASE_CLASS`, which `Button` and
|
|
14
|
+
* `ButtonLink` share for the same reason: "identical" spelled as two
|
|
15
|
+
* copies of one string is a promise that survives exactly one edit.
|
|
16
|
+
*
|
|
17
|
+
* These were `RadioGroup`'s private constants until `ActionTiles`
|
|
18
|
+
* shipped. Nothing about their values changed on the way out.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { ControlSize } from "@charcuterie/tokens"
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A tile is a card, so its padding is a card's rather than a
|
|
25
|
+
* control's — enough that the border reads as a box around content
|
|
26
|
+
* and not as an outline on a line of text.
|
|
27
|
+
*
|
|
28
|
+
* This is also the whole reason `ActionTiles` exists rather than a
|
|
29
|
+
* `Button` with a `className`: a `Button` is sized by
|
|
30
|
+
* `h-(--control-height-md)` and carries **no block padding at all**,
|
|
31
|
+
* so an app that reaches for `height: auto` to let one wrap gets a
|
|
32
|
+
* two-line card with `padding: 0` down its block axis and no error
|
|
33
|
+
* anywhere. QueuePilot's queue-type chooser shipped exactly that.
|
|
34
|
+
*/
|
|
35
|
+
export const TILE_PADDING_CLASS: Record<
|
|
36
|
+
ControlSize,
|
|
37
|
+
string
|
|
38
|
+
> = {
|
|
39
|
+
sm: "px-3 py-2.5",
|
|
40
|
+
md: "px-3.5 py-3",
|
|
41
|
+
lg: "px-4 py-3.5",
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The box, and only the box. Every state layered over it is a
|
|
46
|
+
* **border and a surface**, never colour alone — the same reason
|
|
47
|
+
* `Stepper` refuses to say "done" with a hue.
|
|
48
|
+
*/
|
|
49
|
+
export const TILE_BOX_CLASS =
|
|
50
|
+
"rounded-lg border border-border-subtle bg-surface-raised"
|
|
51
|
+
|
|
52
|
+
export const TILE_TEXT_SIZE_CLASS: Record<
|
|
53
|
+
ControlSize,
|
|
54
|
+
string
|
|
55
|
+
> = {
|
|
56
|
+
sm: "text-sm",
|
|
57
|
+
md: "text-md",
|
|
58
|
+
lg: "text-lg",
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* One step down from the tile's own text, and never below `xs`: a
|
|
63
|
+
* hint that keeps shrinking with the density axis is the 11px
|
|
64
|
+
* caption the 2026-08-10 ramp rebuild exists to have removed.
|
|
65
|
+
*/
|
|
66
|
+
export const TILE_HINT_TEXT_CLASS: Record<
|
|
67
|
+
ControlSize,
|
|
68
|
+
string
|
|
69
|
+
> = {
|
|
70
|
+
sm: "text-xs",
|
|
71
|
+
md: "text-xs",
|
|
72
|
+
lg: "text-sm",
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Wider than a list's row gaps: rows are separated by their leading,
|
|
77
|
+
* and tiles by nothing but the gap, so the same 6px that reads as a
|
|
78
|
+
* list reads as a seam between two cards.
|
|
79
|
+
*/
|
|
80
|
+
export const TILE_GAP_CLASS: Record<ControlSize, string> = {
|
|
81
|
+
sm: "gap-1.5",
|
|
82
|
+
md: "gap-2",
|
|
83
|
+
lg: "gap-3",
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `auto-fill`, and deliberately not `auto-fit`.
|
|
88
|
+
*
|
|
89
|
+
* `auto-fit` collapses the empty tracks and lets the ones that
|
|
90
|
+
* remain share the whole row, so six tiles in a 2560px container
|
|
91
|
+
* become six 420px slabs — the full-width-row shape in a new
|
|
92
|
+
* costume. `auto-fill` keeps the empty tracks, so a tile stays a
|
|
93
|
+
* tile and the grid simply has room to spare.
|
|
94
|
+
*
|
|
95
|
+
* `min(…, 100%)` is what stops the floor overflowing a container
|
|
96
|
+
* narrower than one tile, which is the Narrow View and is otherwise
|
|
97
|
+
* a horizontal scrollbar on a phone.
|
|
98
|
+
*
|
|
99
|
+
* The floor arrives as a custom property rather than an interpolated
|
|
100
|
+
* class because Tailwind scans source *text* for complete class
|
|
101
|
+
* strings: `` `grid-cols-[…${n}px…]` `` generates nothing, paints
|
|
102
|
+
* nothing and reports nothing. One written-out literal reading
|
|
103
|
+
* `var(--charcuterie-tile-min-inline-size)` covers every width an
|
|
104
|
+
* app can ask for — the same reason `Card`'s accent edge goes
|
|
105
|
+
* through one property.
|
|
106
|
+
*
|
|
107
|
+
* This is **not** `useAdaptiveColumns`, and the difference is the
|
|
108
|
+
* question being asked. That hook buys a column with height, for an
|
|
109
|
+
* unbounded gallery that will scroll; a tile set is a bounded group
|
|
110
|
+
* inside a form section or a first step, where the only question is
|
|
111
|
+
* how many fit across the box it was given.
|
|
112
|
+
*/
|
|
113
|
+
export const TILE_COLUMNS_CLASS =
|
|
114
|
+
"grid-cols-[repeat(auto-fill,minmax(min(var(--charcuterie-tile-min-inline-size),100%),1fr))]"
|
|
115
|
+
|
|
116
|
+
/** The property `TILE_COLUMNS_CLASS` reads its floor from. */
|
|
117
|
+
export const TILE_MIN_INLINE_SIZE_PROPERTY =
|
|
118
|
+
"--charcuterie-tile-min-inline-size"
|