@unpunnyfuns/swatchbook-blocks 0.4.0 → 0.5.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 +7 -7
- package/dist/index.d.mts +16 -16
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,15 +50,15 @@ import { TokenTable, ColorPalette, TokenDetail } from '@unpunnyfuns/swatchbook-b
|
|
|
50
50
|
|
|
51
51
|
# Color tokens
|
|
52
52
|
|
|
53
|
-
<ColorPalette filter="color
|
|
53
|
+
<ColorPalette filter="color.*" />
|
|
54
54
|
|
|
55
55
|
## Every color token
|
|
56
56
|
|
|
57
|
-
<TokenTable filter="color
|
|
57
|
+
<TokenTable filter="color.*" type="color" />
|
|
58
58
|
|
|
59
59
|
## Inspect one
|
|
60
60
|
|
|
61
|
-
<TokenDetail path="color.
|
|
61
|
+
<TokenDetail path="color.accent.bg" />
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### Outside Storybook
|
|
@@ -72,7 +72,7 @@ import snapshot from './tokens-snapshot.json';
|
|
|
72
72
|
export function TokenDocs() {
|
|
73
73
|
return (
|
|
74
74
|
<SwatchbookProvider value={snapshot}>
|
|
75
|
-
<TokenTable filter='color
|
|
75
|
+
<TokenTable filter='color.*' />
|
|
76
76
|
</SwatchbookProvider>
|
|
77
77
|
);
|
|
78
78
|
}
|
|
@@ -83,10 +83,10 @@ export function TokenDocs() {
|
|
|
83
83
|
## Props
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
<TokenTable filter="color
|
|
87
|
-
<ColorPalette filter="color
|
|
86
|
+
<TokenTable filter="color.*" type="color" />
|
|
87
|
+
<ColorPalette filter="color.*" />
|
|
88
88
|
<TypographyScale filter="typography" sample="The quick brown fox" />
|
|
89
|
-
<TokenDetail path="color.
|
|
89
|
+
<TokenDetail path="color.accent.bg" />
|
|
90
90
|
```
|
|
91
91
|
|
|
92
92
|
## Do / don't
|
package/dist/index.d.mts
CHANGED
|
@@ -155,7 +155,7 @@ type SortDir = 'asc' | 'desc';
|
|
|
155
155
|
interface BorderPreviewProps {
|
|
156
156
|
/**
|
|
157
157
|
* Token-path filter. Defaults to every `border` token. Use e.g.
|
|
158
|
-
* `"border
|
|
158
|
+
* `"border.*"` to scope to the semantic layer.
|
|
159
159
|
*/
|
|
160
160
|
filter?: string;
|
|
161
161
|
/** Override the caption. */
|
|
@@ -189,20 +189,20 @@ declare function BorderSample({
|
|
|
189
189
|
interface ColorPaletteProps {
|
|
190
190
|
/**
|
|
191
191
|
* Token-path filter. Defaults to every `color` token. Use e.g.
|
|
192
|
-
* `"color
|
|
192
|
+
* `"color.*"` to scope to the semantic layer, or `"color.palette.blue.*"`
|
|
193
193
|
* for a single ref ramp.
|
|
194
194
|
*/
|
|
195
195
|
filter?: string;
|
|
196
196
|
/**
|
|
197
197
|
* Grouping depth. Tokens are grouped by the first `groupBy` dot-segments
|
|
198
|
-
* of their path. `
|
|
199
|
-
*
|
|
198
|
+
* of their path. `1` yields a single `color` group; `2` yields
|
|
199
|
+
* `color.surface`, `color.text`, `color.blue`, etc.
|
|
200
200
|
*
|
|
201
201
|
* If omitted, groupBy is derived from the filter: one level below the
|
|
202
202
|
* filter's fixed prefix (segments before the first `*`), clamped so each
|
|
203
|
-
* swatch still carries a leaf label. `"color
|
|
204
|
-
* `color
|
|
205
|
-
* one `color.
|
|
203
|
+
* swatch still carries a leaf label. `"color.*"` → groups at
|
|
204
|
+
* `color.<family>`; `"color.palette.blue.*"` collapses all shades into
|
|
205
|
+
* one `color.blue` group because the tokens have no deeper level.
|
|
206
206
|
*/
|
|
207
207
|
groupBy?: number;
|
|
208
208
|
/** Override the section caption. */
|
|
@@ -267,7 +267,7 @@ declare function DimensionBar({
|
|
|
267
267
|
interface DimensionScaleProps {
|
|
268
268
|
/**
|
|
269
269
|
* Token-path filter. Defaults to every `dimension` token. Use e.g.
|
|
270
|
-
* `"space
|
|
270
|
+
* `"space.*"` to scope to the spacing scale.
|
|
271
271
|
*/
|
|
272
272
|
filter?: string;
|
|
273
273
|
/**
|
|
@@ -302,7 +302,7 @@ declare function DimensionScale({
|
|
|
302
302
|
interface FontFamilySampleProps {
|
|
303
303
|
/**
|
|
304
304
|
* Token-path filter. Defaults to every `fontFamily` token. Use e.g.
|
|
305
|
-
* `"font.
|
|
305
|
+
* `"font.family.*"` to scope to the ref layer.
|
|
306
306
|
*/
|
|
307
307
|
filter?: string;
|
|
308
308
|
/** Override the sample text rendered for each token. */
|
|
@@ -330,7 +330,7 @@ declare function FontFamilySample({
|
|
|
330
330
|
interface FontWeightScaleProps {
|
|
331
331
|
/**
|
|
332
332
|
* Token-path filter. Defaults to every `fontWeight` token. Use e.g.
|
|
333
|
-
* `"font.
|
|
333
|
+
* `"font.weight.*"` to scope to the ref layer.
|
|
334
334
|
*/
|
|
335
335
|
filter?: string;
|
|
336
336
|
/** Override the sample text rendered for each token. */
|
|
@@ -359,7 +359,7 @@ declare function FontWeightScale({
|
|
|
359
359
|
interface GradientPaletteProps {
|
|
360
360
|
/**
|
|
361
361
|
* Token-path filter. Defaults to every `gradient` token. Use e.g.
|
|
362
|
-
* `"gradient
|
|
362
|
+
* `"gradient.*"` or `"gradient.accent"` to scope.
|
|
363
363
|
*/
|
|
364
364
|
filter?: string;
|
|
365
365
|
/** Override the caption. */
|
|
@@ -404,7 +404,7 @@ declare function MotionSample({
|
|
|
404
404
|
interface MotionPreviewProps {
|
|
405
405
|
/**
|
|
406
406
|
* Token-path filter. Defaults to transition + duration + cubicBezier
|
|
407
|
-
* tokens. Use e.g. `"
|
|
407
|
+
* tokens. Use e.g. `"transition.*"` to scope to the semantic layer.
|
|
408
408
|
*/
|
|
409
409
|
filter?: string;
|
|
410
410
|
/** Override the caption. */
|
|
@@ -444,7 +444,7 @@ declare function useSwatchbookData(): ProjectSnapshot;
|
|
|
444
444
|
interface ShadowPreviewProps {
|
|
445
445
|
/**
|
|
446
446
|
* Token-path filter. Defaults to every `shadow` token. Use e.g.
|
|
447
|
-
* `"shadow
|
|
447
|
+
* `"shadow.*"` to scope to the semantic layer.
|
|
448
448
|
*/
|
|
449
449
|
filter?: string;
|
|
450
450
|
/** Override the caption. */
|
|
@@ -478,7 +478,7 @@ declare function ShadowSample({
|
|
|
478
478
|
interface StrokeStyleSampleProps {
|
|
479
479
|
/**
|
|
480
480
|
* Token-path filter. Defaults to every `strokeStyle` token. Use e.g.
|
|
481
|
-
* `"stroke.
|
|
481
|
+
* `"stroke.style.*"` to scope to the ref layer.
|
|
482
482
|
*/
|
|
483
483
|
filter?: string;
|
|
484
484
|
/** Override the caption. */
|
|
@@ -612,7 +612,7 @@ declare function TokenNavigator({
|
|
|
612
612
|
//#region src/TokenTable.d.ts
|
|
613
613
|
interface TokenTableProps {
|
|
614
614
|
/**
|
|
615
|
-
* Token-path filter. `"color
|
|
615
|
+
* Token-path filter. `"color.*"` matches every `color.…` token;
|
|
616
616
|
* omit to include everything. Combines with `type` (both must match).
|
|
617
617
|
*/
|
|
618
618
|
filter?: string;
|
|
@@ -652,7 +652,7 @@ declare function TokenTable({
|
|
|
652
652
|
interface TypographyScaleProps {
|
|
653
653
|
/**
|
|
654
654
|
* Token-path filter. Defaults to every `typography` token. Use e.g.
|
|
655
|
-
* `"typography
|
|
655
|
+
* `"typography.*"` to scope to the semantic layer.
|
|
656
656
|
*/
|
|
657
657
|
filter?: string;
|
|
658
658
|
/** Override the sample text rendered for each token. */
|
package/dist/index.mjs
CHANGED
|
@@ -408,7 +408,7 @@ function useVirtualModuleFallback(enabled) {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
function makeCssVar(path, prefix) {
|
|
411
|
-
const tail = path.
|
|
411
|
+
const tail = path.split(".").map((segment) => segment.replaceAll(/([a-z\d])([A-Z])/g, "$1-$2").toLowerCase()).join("-");
|
|
412
412
|
return prefix ? `var(--${prefix}-${tail})` : `var(--${tail})`;
|
|
413
413
|
}
|
|
414
414
|
/**
|
|
@@ -422,7 +422,7 @@ function makeCssVar(path, prefix) {
|
|
|
422
422
|
* | `undefined` / `''` | everything |
|
|
423
423
|
* | `*` or `**` | everything |
|
|
424
424
|
* | `color` | exact path `color`, or any descendant `color.*` |
|
|
425
|
-
* | `color
|
|
425
|
+
* | `color.*` | any path whose fixed prefix is `color.` |
|
|
426
426
|
* | `color**` | any path starting with `color` |
|
|
427
427
|
*
|
|
428
428
|
* Not supported (all pass through as literal segment matchers): brace
|
|
@@ -707,7 +707,7 @@ function BorderPreview({ filter, caption, sortBy = "path", sortDir = "asc" }) {
|
|
|
707
707
|
//#region src/ColorPalette.tsx
|
|
708
708
|
/**
|
|
709
709
|
* Count segments in the filter before the first glob (`*` / `**`).
|
|
710
|
-
* `color
|
|
710
|
+
* `color.*` → 2; `color.surface.*` → 3; `color` → 1; undefined → 0.
|
|
711
711
|
*/
|
|
712
712
|
function fixedPrefixLength(filter) {
|
|
713
713
|
if (!filter) return 0;
|