@unpunnyfuns/swatchbook-addon 0.1.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/LICENSE +21 -0
- package/README.md +121 -0
- package/dist/constants-1plfdgh7.mjs +21 -0
- package/dist/constants-1plfdgh7.mjs.map +1 -0
- package/dist/hooks/index.d.mts +37 -0
- package/dist/hooks/index.mjs +33 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +22 -0
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -0
- package/dist/manager.d.mts +1 -0
- package/dist/manager.mjs +903 -0
- package/dist/manager.mjs.map +1 -0
- package/dist/options-rvGQy0uV.d.mts +17 -0
- package/dist/preset.d.mts +20 -0
- package/dist/preset.mjs +163 -0
- package/dist/preset.mjs.map +1 -0
- package/dist/preview-DcMFt0cD.mjs +240 -0
- package/dist/preview-DcMFt0cD.mjs.map +1 -0
- package/dist/preview.d.mts +13 -0
- package/dist/preview.mjs +2 -0
- package/package.json +96 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Unpunny Funs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Addon
|
|
2
|
+
|
|
3
|
+
Published as `@unpunnyfuns/swatchbook-addon`. Storybook 10 addon for DTCG design tokens. Loads your tokens at config time (via `@unpunnyfuns/swatchbook-core`), exposes the resolved graph to the preview through a virtual module, renders one toolbar dropdown per modifier axis (`mode`, `brand`, and so on) plus a unified Design Tokens panel (hierarchical tree + diagnostics), and ships a `useToken()` hook with typed paths.
|
|
4
|
+
|
|
5
|
+
> **Documentation:** [unpunnyfuns.github.io/swatchbook](https://unpunnyfuns.github.io/swatchbook/). Token parsing powered by [Terrazzo](https://terrazzo.app/) by [Drew Powers](https://github.com/drwpow) via `@unpunnyfuns/swatchbook-core`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -D @unpunnyfuns/swatchbook-addon @unpunnyfuns/swatchbook-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This gives you the toolbar, Design Tokens panel (hierarchical tree view with diagnostics), preview decorator, and the `useToken()` hook. The MDX doc blocks (`TokenTable`, `ColorPalette`, `TokenDetail`, `SwatchbookProvider`, block-side hooks) live in the sibling package — add it alongside if you want them:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @unpunnyfuns/swatchbook-blocks
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Peer requirements: `storybook@^10.3`, `react` / `react-dom` 18+.
|
|
20
|
+
|
|
21
|
+
## Register
|
|
22
|
+
|
|
23
|
+
`.storybook/main.ts` — CSF Next. Inline config is the recommended path; the separate `swatchbook.config.ts` file is an escape hatch for sharing config with other tooling (see below).
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { defineMain } from '@storybook/react-vite/node';
|
|
27
|
+
|
|
28
|
+
export default defineMain({
|
|
29
|
+
stories: ['../src/**/*.stories.@(ts|tsx)', '../src/**/*.mdx'],
|
|
30
|
+
framework: '@storybook/react-vite',
|
|
31
|
+
addons: [
|
|
32
|
+
{
|
|
33
|
+
name: '@unpunnyfuns/swatchbook-addon',
|
|
34
|
+
options: {
|
|
35
|
+
config: {
|
|
36
|
+
resolver: 'tokens/resolver.json',
|
|
37
|
+
default: { mode: 'Light' },
|
|
38
|
+
cssVarPrefix: 'ds',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`.storybook/preview.ts` — opt the preview into the addon's annotations (decorator, globalTypes, initialGlobals):
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { definePreview } from '@storybook/react-vite';
|
|
50
|
+
import swatchbookAddon from '@unpunnyfuns/swatchbook-addon';
|
|
51
|
+
|
|
52
|
+
export default definePreview({
|
|
53
|
+
addons: [swatchbookAddon()],
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Options
|
|
58
|
+
|
|
59
|
+
| Option | Type | What |
|
|
60
|
+
| ------------ | -------- | ----------------------------------------------------------------- |
|
|
61
|
+
| `config` | `Config` | Inline swatchbook config. Recommended for most projects. Mutually exclusive with `configPath`. |
|
|
62
|
+
| `configPath` | `string` | Path to a config module relative to `.storybook/`. Loaded via jiti so `.ts` / `.mts` / `.js` / `.mjs` all work. Use when the same config is consumed by other tooling (a CLI, CI lint, external build script). |
|
|
63
|
+
|
|
64
|
+
## `useToken`
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { useToken } from '@unpunnyfuns/swatchbook-addon/hooks';
|
|
68
|
+
|
|
69
|
+
function Card() {
|
|
70
|
+
const bg = useToken('color.sys.surface.default');
|
|
71
|
+
const radius = useToken('radius.sys.lg');
|
|
72
|
+
return (
|
|
73
|
+
<div style={{ background: bg.cssVar, borderRadius: radius.cssVar }}>
|
|
74
|
+
{bg.description}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Returns `{ value, cssVar, type?, description? }`. `cssVar` is stable across themes; `value` flips with the active theme. Paths autocomplete from the generated `.swatchbook/tokens.d.ts` once the addon has run against your project.
|
|
81
|
+
|
|
82
|
+
## Toolbar pills (presets)
|
|
83
|
+
|
|
84
|
+
Add `presets` to your `swatchbook.config.ts` to surface quick-select pills next to the axis dropdowns:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
export default defineSwatchbookConfig({
|
|
88
|
+
tokens: ['tokens/**/*.json'],
|
|
89
|
+
resolver: 'tokens/resolver.json',
|
|
90
|
+
presets: [
|
|
91
|
+
{ name: 'Default Light', axes: { mode: 'Light', brand: 'Default' } },
|
|
92
|
+
{ name: 'Brand A Dark', axes: { mode: 'Dark', brand: 'Brand A' }, description: 'Dark + violet accent.' },
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Clicking a pill writes the full tuple — partial presets fill in omitted axes from each axis's default. The active pill is highlighted when the current tuple matches; if you tweak an axis dropdown after applying a preset, the pill shows a small "modified" dot so you can see that the current tuple has drifted from the named preset. Presets come from config only — there is no in-session "save as".
|
|
98
|
+
|
|
99
|
+
## Per-story overrides
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
export const DarkBrandA = meta.story({
|
|
103
|
+
parameters: { swatchbook: { axes: { mode: 'Dark', brand: 'Brand A' } } },
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`axes` is a tuple of `{ axisName: contextName }` entries. Any axis left out falls back to its default; unknown keys or contexts are silently ignored. The legacy `theme: 'Composed Name'` form is still accepted for single-axis overrides.
|
|
108
|
+
|
|
109
|
+
## Do / don't
|
|
110
|
+
|
|
111
|
+
- ✅ Use `useToken` for typed lookups when you need the resolved value at runtime (aria labels, conditional rendering, …).
|
|
112
|
+
- ✅ Prefer `var(--…)` in CSS; `useToken().cssVar` gives you the right string programmatically.
|
|
113
|
+
- ❌ Don't import from `virtual:swatchbook/tokens` directly in consumer code. Go through `useToken` / the panel / the doc blocks so the API stays stable if we change the virtual module's shape.
|
|
114
|
+
- ❌ Don't combine `parameters.swatchbook.theme` *and* the toolbar for the same story — the parameter wins and the toolbar change won't stick.
|
|
115
|
+
|
|
116
|
+
## See also
|
|
117
|
+
|
|
118
|
+
- [`@unpunnyfuns/swatchbook-core`](../core) — the loader this addon wraps. Consume directly if you need DTCG processing outside Storybook.
|
|
119
|
+
- [`@unpunnyfuns/swatchbook-blocks`](../blocks) — MDX doc blocks that build on this addon's virtual module.
|
|
120
|
+
- [Project README](../../README.md) — install and wiring flow for the whole toolchain.
|
|
121
|
+
- [Documentation](https://unpunnyfuns.github.io/swatchbook/) — concepts, guides, and full API reference.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
const ADDON_ID = "swatchbook";
|
|
3
|
+
const TOOL_ID = `${ADDON_ID}/theme-switcher`;
|
|
4
|
+
const PANEL_ID = `${ADDON_ID}/design-tokens`;
|
|
5
|
+
const PARAM_KEY = "swatchbook";
|
|
6
|
+
/** Canonical active-theme global: composed permutation ID (string). Read by toolbar, panel, blocks. */
|
|
7
|
+
const GLOBAL_KEY = "swatchbookTheme";
|
|
8
|
+
/** Tuple companion: `Record<axisName, contextName>`. Optional — when present, takes precedence over the string global. */
|
|
9
|
+
const AXES_GLOBAL_KEY = "swatchbookAxes";
|
|
10
|
+
/** Display-only color format for blocks (`hex` | `rgb` | `hsl` | `oklch` | `raw`). Emitted CSS is unaffected. */
|
|
11
|
+
const COLOR_FORMAT_GLOBAL_KEY = "swatchbookColorFormat";
|
|
12
|
+
const VIRTUAL_MODULE_ID = "virtual:swatchbook/tokens";
|
|
13
|
+
const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
14
|
+
const DATA_THEME_ATTR = "data-theme";
|
|
15
|
+
const STYLE_ELEMENT_ID = "swatchbook-tokens";
|
|
16
|
+
/** Channel event: preview → manager, carries theme list + mode. */
|
|
17
|
+
const INIT_EVENT = "swatchbook/init";
|
|
18
|
+
//#endregion
|
|
19
|
+
export { GLOBAL_KEY as a, PARAM_KEY as c, TOOL_ID as d, VIRTUAL_MODULE_ID as f, DATA_THEME_ATTR as i, RESOLVED_VIRTUAL_MODULE_ID as l, AXES_GLOBAL_KEY as n, INIT_EVENT as o, COLOR_FORMAT_GLOBAL_KEY as r, PANEL_ID as s, ADDON_ID as t, STYLE_ELEMENT_ID as u };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=constants-1plfdgh7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-1plfdgh7.mjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["export const ADDON_ID = 'swatchbook';\nexport const TOOL_ID = `${ADDON_ID}/theme-switcher`;\nexport const PANEL_ID = `${ADDON_ID}/design-tokens`;\nexport const PARAM_KEY = 'swatchbook';\n/** Canonical active-theme global: composed permutation ID (string). Read by toolbar, panel, blocks. */\nexport const GLOBAL_KEY = 'swatchbookTheme';\n/** Tuple companion: `Record<axisName, contextName>`. Optional — when present, takes precedence over the string global. */\nexport const AXES_GLOBAL_KEY = 'swatchbookAxes';\n/** Display-only color format for blocks (`hex` | `rgb` | `hsl` | `oklch` | `raw`). Emitted CSS is unaffected. */\nexport const COLOR_FORMAT_GLOBAL_KEY = 'swatchbookColorFormat';\n\nexport const VIRTUAL_MODULE_ID = 'virtual:swatchbook/tokens';\nexport const RESOLVED_VIRTUAL_MODULE_ID = `\\0${VIRTUAL_MODULE_ID}`;\n\nexport const DATA_THEME_ATTR = 'data-theme';\nexport const STYLE_ELEMENT_ID = 'swatchbook-tokens';\n\n/** Channel event: preview → manager, carries theme list + mode. */\nexport const INIT_EVENT = 'swatchbook/init';\n"],"mappings":";AAAA,MAAa,WAAW;AACxB,MAAa,UAAU,GAAG,SAAS;AACnC,MAAa,WAAW,GAAG,SAAS;AACpC,MAAa,YAAY;;AAEzB,MAAa,aAAa;;AAE1B,MAAa,kBAAkB;;AAE/B,MAAa,0BAA0B;AAEvC,MAAa,oBAAoB;AACjC,MAAa,6BAA6B,KAAK;AAE/C,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;;AAGhC,MAAa,aAAa"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/hooks/use-token.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Consumers augment this interface (via the addon's generated
|
|
4
|
+
* `.swatchbook/tokens.d.ts`) to narrow {@link useToken}'s first parameter
|
|
5
|
+
* to their project's actual token paths. Without augmentation it's empty
|
|
6
|
+
* and {@link TokenPath} falls back to `string`.
|
|
7
|
+
*/
|
|
8
|
+
interface SwatchbookTokenMap {}
|
|
9
|
+
type KnownPath = keyof SwatchbookTokenMap;
|
|
10
|
+
/** Union of known token paths, or `string` when the addon codegen hasn't run. */
|
|
11
|
+
type TokenPath = [KnownPath] extends [never] ? string : KnownPath;
|
|
12
|
+
interface TokenInfo {
|
|
13
|
+
/** The resolved DTCG `$value`. Shape varies by `$type`. */
|
|
14
|
+
value: unknown;
|
|
15
|
+
/** `var(--prefix-token-path)` reference, ready to drop into any CSS value. */
|
|
16
|
+
cssVar: string;
|
|
17
|
+
/** DTCG `$type` of the token, if known. */
|
|
18
|
+
type?: string;
|
|
19
|
+
/** Optional DTCG `$description`. */
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Read a DTCG token for the currently active theme. Re-reads on theme
|
|
24
|
+
* switch via the addon's `ThemeContext`. Returns `{ value, cssVar, type,
|
|
25
|
+
* description }`.
|
|
26
|
+
*
|
|
27
|
+
* Typed paths appear automatically once `.swatchbook/tokens.d.ts` is
|
|
28
|
+
* generated (happens on first storybook start/build). Until then
|
|
29
|
+
* `TokenPath` is `string`.
|
|
30
|
+
*
|
|
31
|
+
* Safe to call in autodocs / MDX renders — uses plain React context, not
|
|
32
|
+
* Storybook's preview-only hooks.
|
|
33
|
+
*/
|
|
34
|
+
declare function useToken(path: TokenPath): TokenInfo;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { type SwatchbookTokenMap, type TokenInfo, type TokenPath, useToken };
|
|
37
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cssVarPrefix, defaultTheme, themesResolved } from "virtual:swatchbook/tokens";
|
|
2
|
+
import { useActiveTheme } from "@unpunnyfuns/swatchbook-blocks";
|
|
3
|
+
//#region src/hooks/use-token.ts
|
|
4
|
+
function makeCssVar(path, prefix) {
|
|
5
|
+
const tail = path.replaceAll(".", "-");
|
|
6
|
+
return prefix ? `var(--${prefix}-${tail})` : `var(--${tail})`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Read a DTCG token for the currently active theme. Re-reads on theme
|
|
10
|
+
* switch via the addon's `ThemeContext`. Returns `{ value, cssVar, type,
|
|
11
|
+
* description }`.
|
|
12
|
+
*
|
|
13
|
+
* Typed paths appear automatically once `.swatchbook/tokens.d.ts` is
|
|
14
|
+
* generated (happens on first storybook start/build). Until then
|
|
15
|
+
* `TokenPath` is `string`.
|
|
16
|
+
*
|
|
17
|
+
* Safe to call in autodocs / MDX renders — uses plain React context, not
|
|
18
|
+
* Storybook's preview-only hooks.
|
|
19
|
+
*/
|
|
20
|
+
function useToken(path) {
|
|
21
|
+
const token = (themesResolved[useActiveTheme() || (defaultTheme ?? "")] ?? {})[path];
|
|
22
|
+
const info = {
|
|
23
|
+
value: token?.$value,
|
|
24
|
+
cssVar: makeCssVar(path, cssVarPrefix)
|
|
25
|
+
};
|
|
26
|
+
if (token?.$type) info.type = token.$type;
|
|
27
|
+
if (token?.$description) info.description = token.$description;
|
|
28
|
+
return info;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { useToken };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/hooks/use-token.ts"],"sourcesContent":["import { cssVarPrefix, defaultTheme, themesResolved } from 'virtual:swatchbook/tokens';\nimport { useActiveTheme } from '@unpunnyfuns/swatchbook-blocks';\n\n/**\n * Consumers augment this interface (via the addon's generated\n * `.swatchbook/tokens.d.ts`) to narrow {@link useToken}'s first parameter\n * to their project's actual token paths. Without augmentation it's empty\n * and {@link TokenPath} falls back to `string`.\n */\nexport interface SwatchbookTokenMap {}\n\ntype KnownPath = keyof SwatchbookTokenMap;\n\n/** Union of known token paths, or `string` when the addon codegen hasn't run. */\nexport type TokenPath = [KnownPath] extends [never] ? string : KnownPath;\n\nexport interface TokenInfo {\n /** The resolved DTCG `$value`. Shape varies by `$type`. */\n value: unknown;\n /** `var(--prefix-token-path)` reference, ready to drop into any CSS value. */\n cssVar: string;\n /** DTCG `$type` of the token, if known. */\n type?: string;\n /** Optional DTCG `$description`. */\n description?: string;\n}\n\nfunction makeCssVar(path: string, prefix: string): string {\n const tail = path.replaceAll('.', '-');\n return prefix ? `var(--${prefix}-${tail})` : `var(--${tail})`;\n}\n\n/**\n * Read a DTCG token for the currently active theme. Re-reads on theme\n * switch via the addon's `ThemeContext`. Returns `{ value, cssVar, type,\n * description }`.\n *\n * Typed paths appear automatically once `.swatchbook/tokens.d.ts` is\n * generated (happens on first storybook start/build). Until then\n * `TokenPath` is `string`.\n *\n * Safe to call in autodocs / MDX renders — uses plain React context, not\n * Storybook's preview-only hooks.\n */\nexport function useToken(path: TokenPath): TokenInfo {\n const contextTheme = useActiveTheme();\n const themeName = contextTheme || (defaultTheme ?? '');\n const tokens = themesResolved[themeName] ?? {};\n const token = tokens[path];\n const info: TokenInfo = {\n value: token?.$value,\n cssVar: makeCssVar(path, cssVarPrefix),\n };\n if (token?.$type) info.type = token.$type;\n if (token?.$description) info.description = token.$description;\n return info;\n}\n"],"mappings":";;;AA2BA,SAAS,WAAW,MAAc,QAAwB;CACxD,MAAM,OAAO,KAAK,WAAW,KAAK,IAAI;AACtC,QAAO,SAAS,SAAS,OAAO,GAAG,KAAK,KAAK,SAAS,KAAK;;;;;;;;;;;;;;AAe7D,SAAgB,SAAS,MAA4B;CAInD,MAAM,SADS,eAFM,gBAAgB,KACF,gBAAgB,QACP,EAAE,EACzB;CACrB,MAAM,OAAkB;EACtB,OAAO,OAAO;EACd,QAAQ,WAAW,MAAM,aAAa;EACvC;AACD,KAAI,OAAO,MAAO,MAAK,OAAO,MAAM;AACpC,KAAI,OAAO,aAAc,MAAK,cAAc,MAAM;AAClD,QAAO"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { t as AddonOptions } from "./options-rvGQy0uV.mjs";
|
|
2
|
+
import { definePreviewAddon } from "storybook/internal/csf";
|
|
3
|
+
|
|
4
|
+
//#region src/constants.d.ts
|
|
5
|
+
declare const ADDON_ID = "swatchbook";
|
|
6
|
+
declare const PARAM_KEY = "swatchbook";
|
|
7
|
+
/** Canonical active-theme global: composed permutation ID (string). Read by toolbar, panel, blocks. */
|
|
8
|
+
declare const GLOBAL_KEY = "swatchbookTheme";
|
|
9
|
+
/** Tuple companion: `Record<axisName, contextName>`. Optional — when present, takes precedence over the string global. */
|
|
10
|
+
declare const AXES_GLOBAL_KEY = "swatchbookAxes";
|
|
11
|
+
declare const VIRTUAL_MODULE_ID = "virtual:swatchbook/tokens";
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/index.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* CSF Next factory. Consumers call this inside
|
|
16
|
+
* `definePreview({ addons: [swatchbookAddon()] })` so the preview annotations
|
|
17
|
+
* (decorator, globalTypes, initialGlobals) are added to the preview bundle.
|
|
18
|
+
*/
|
|
19
|
+
declare function swatchbookAddon(): ReturnType<typeof definePreviewAddon>;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ADDON_ID, AXES_GLOBAL_KEY, type AddonOptions, GLOBAL_KEY, PARAM_KEY, VIRTUAL_MODULE_ID, swatchbookAddon as default };
|
|
22
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { i as preview_exports } from "./preview-DcMFt0cD.mjs";
|
|
2
|
+
import { a as GLOBAL_KEY, c as PARAM_KEY, f as VIRTUAL_MODULE_ID, n as AXES_GLOBAL_KEY, t as ADDON_ID } from "./constants-1plfdgh7.mjs";
|
|
3
|
+
import { definePreviewAddon } from "storybook/internal/csf";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* CSF Next factory. Consumers call this inside
|
|
7
|
+
* `definePreview({ addons: [swatchbookAddon()] })` so the preview annotations
|
|
8
|
+
* (decorator, globalTypes, initialGlobals) are added to the preview bundle.
|
|
9
|
+
*/
|
|
10
|
+
function swatchbookAddon() {
|
|
11
|
+
return definePreviewAddon(preview_exports);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ADDON_ID, AXES_GLOBAL_KEY, GLOBAL_KEY, PARAM_KEY, VIRTUAL_MODULE_ID, swatchbookAddon as default };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["previewExports"],"sources":["../src/index.ts"],"sourcesContent":["import { definePreviewAddon } from 'storybook/internal/csf';\nimport * as previewExports from './preview.tsx';\n\nexport {\n ADDON_ID,\n AXES_GLOBAL_KEY,\n GLOBAL_KEY,\n PARAM_KEY,\n VIRTUAL_MODULE_ID,\n} from '#/constants.ts';\nexport type { AddonOptions } from '#/options.ts';\n\n/**\n * CSF Next factory. Consumers call this inside\n * `definePreview({ addons: [swatchbookAddon()] })` so the preview annotations\n * (decorator, globalTypes, initialGlobals) are added to the preview bundle.\n */\nexport default function swatchbookAddon(): ReturnType<typeof definePreviewAddon> {\n return definePreviewAddon(previewExports);\n}\n"],"mappings":";;;;;;;;;AAiBA,SAAwB,kBAAyD;AAC/E,QAAO,mBAAmBA,gBAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|