@unpunnyfuns/swatchbook-switcher 0.19.7 → 0.19.9
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 +22 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# swatchbook-switcher
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The framework-agnostic theme-switcher UI for [swatchbook](https://github.com/unpunnyfuns/swatchbook).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A React component: axis dropdowns, preset pills, color-format selector. The Storybook addon's toolbar uses it; so does the docs-site navbar. Reach for this package directly when you want the switcher on a non-Storybook site — a docs navbar, a standalone React app consuming swatchbook tokens.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Most consumers pick it up transitively via [`@unpunnyfuns/swatchbook-addon`](../addon); `import { ThemeSwitcher } from '@unpunnyfuns/swatchbook-addon'` works out of the box.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Install
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npm install @unpunnyfuns/swatchbook-switcher
|
|
@@ -17,44 +17,29 @@ npm install @unpunnyfuns/swatchbook-switcher
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { ThemeSwitcher } from '@unpunnyfuns/swatchbook-switcher';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
20
|
+
<ThemeSwitcher
|
|
21
|
+
axes={axes}
|
|
22
|
+
presets={presets}
|
|
23
|
+
themes={themes}
|
|
24
|
+
activeAxes={{ mode: 'Dark' }}
|
|
25
|
+
colorFormat="oklch"
|
|
26
|
+
onAxisChange={(axis, context) => {
|
|
27
|
+
document.documentElement.setAttribute(`data-sb-${axis}`, context);
|
|
28
|
+
}}
|
|
29
|
+
onColorFormatChange={(format) => {
|
|
30
|
+
document.documentElement.setAttribute('data-sb-color-format', format);
|
|
31
|
+
}}
|
|
32
|
+
/>;
|
|
37
33
|
```
|
|
38
34
|
|
|
39
35
|
The component is pure — it doesn't read or write to storage, and it doesn't bake in any particular way of applying the active tuple. The caller decides how to translate `onAxisChange` into DOM updates, routing changes, or global state.
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
| Name | Shape |
|
|
44
|
-
| --- | --- |
|
|
45
|
-
| `ThemeSwitcher` | The popover component. |
|
|
46
|
-
| `ThemeSwitcherProps` | Prop types — axes, presets, themes, active axis tuple, color format, change callbacks, optional `className`. |
|
|
47
|
-
| `SwitcherAxis` / `SwitcherPreset` / `SwitcherTheme` | JSON-friendly shapes the component accepts. Cross-compatible with `@unpunnyfuns/swatchbook-core`'s `Project.axes` / `.presets` / `.themes` — pass them through directly. |
|
|
48
|
-
|
|
49
|
-
## Where it's used inside this repo
|
|
37
|
+
`SwitcherAxis` / `SwitcherPreset` / `SwitcherTheme` are the accepted shapes and are cross-compatible with `Project.axes` / `.presets` / `.themes` from `@unpunnyfuns/swatchbook-core` — pass them through directly.
|
|
50
38
|
|
|
51
|
-
|
|
52
|
-
- The docs site's navbar (`apps/docs/src/theme/Navbar/SwatchbookSwitcher/index.tsx`).
|
|
39
|
+
## Credits
|
|
53
40
|
|
|
54
|
-
|
|
41
|
+
Token parsing and resolver evaluation come from [Terrazzo](https://terrazzo.app/) by the [Terrazzo team](https://github.com/terrazzoapp) via `@unpunnyfuns/swatchbook-core`.
|
|
55
42
|
|
|
56
|
-
##
|
|
43
|
+
## Documentation
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
- [`@unpunnyfuns/swatchbook-blocks`](../blocks) — MDX doc blocks that the switcher-driven axis changes propagate to.
|
|
60
|
-
- [`@unpunnyfuns/swatchbook-core`](../core) — the DTCG loader whose output feeds this component.
|
|
45
|
+
[unpunnyfuns.github.io/swatchbook](https://unpunnyfuns.github.io/swatchbook/) — concepts, guides, and full API reference.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpunnyfuns/swatchbook-switcher",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.9",
|
|
4
4
|
"description": "Framework-agnostic theme-switcher UI for swatchbook — axis pills, preset pills, color-format selector. Consumed by the Storybook addon toolbar and any React host that knows how to set data-attributes on the document.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "unpunnyfuns <unpunnyfuns@gmail.com>",
|