@razorwind/storybook 0.0.22 → 0.0.24
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/dist/index.cjs +32 -3
- package/dist/index.d.cts +7 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.mjs +32 -3
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -180,11 +180,40 @@ import { TypesetBlock } from "./blocks/Typeset";
|
|
|
180
180
|
# Typography
|
|
181
181
|
|
|
182
182
|
<TypesetBlock />
|
|
183
|
-
`}function x(){return`
|
|
183
|
+
`}function x(e,t){let n=e[t];return typeof n==`string`?n:void 0}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(e){return`import { IconGallery, IconItem } from "@storybook/addon-docs/blocks";
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Icons rendered with Storybook's IconGallery doc block.
|
|
187
|
+
*
|
|
188
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-icongallery
|
|
189
|
+
*/
|
|
190
|
+
export function IconGalleryBlock() {
|
|
191
|
+
return (
|
|
192
|
+
<IconGallery>
|
|
193
|
+
${(S(e)?Object.values(e).filter(S).toSorted((e,t)=>(x(e,`name`)??``).localeCompare(x(t,`name`)??``)):[]).map(e=>{let t=x(e,`name`)??`unknown`,n=(Array.isArray(e.files)?e.files:[]).find(e=>S(e)&&x(e,`type`)===`svg`&&typeof e.content==`string`),a=S(n)&&typeof n.content==`string`?`<span
|
|
194
|
+
style={{ display: "inline-flex", width: 24, height: 24 }}
|
|
195
|
+
dangerouslySetInnerHTML={{ __html: ${i(n.content)} }}
|
|
196
|
+
/>`:`<code>${r(t)}</code>`;return` <IconItem name={${i(t)}}>
|
|
197
|
+
${a}
|
|
198
|
+
</IconItem>`}).join(`
|
|
199
|
+
`)||` {/* No icons */}`}
|
|
200
|
+
</IconGallery>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
`}function w(e={}){return`import { Meta } from "@storybook/addon-docs/blocks";
|
|
204
|
+
import { IconGalleryBlock } from "./blocks/IconGallery";
|
|
205
|
+
|
|
206
|
+
<Meta title="${r(e.titlePrefix??`Design Tokens`)}/Icons" />
|
|
207
|
+
|
|
208
|
+
# Icons
|
|
209
|
+
|
|
210
|
+
<IconGalleryBlock />
|
|
211
|
+
`}function T(){return`export { ColorPaletteBlock } from "./ColorPalette";
|
|
212
|
+
export { IconGalleryBlock } from "./IconGallery";
|
|
184
213
|
export { TokenTableBlock } from "./TokenTable";
|
|
185
214
|
export type { TokenTableBlockProps, TokenTableRow } from "./TokenTable";
|
|
186
215
|
export { TypesetBlock } from "./Typeset";
|
|
187
|
-
`}function
|
|
216
|
+
`}function E(e){return`import { create } from "storybook/theming";
|
|
188
217
|
|
|
189
218
|
/**
|
|
190
219
|
* Storybook UI theme generated by \`@razorwind/storybook\`.
|
|
@@ -195,4 +224,4 @@ export default create({
|
|
|
195
224
|
${Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}: ${i(t)}`).join(`,
|
|
196
225
|
`)}
|
|
197
226
|
});
|
|
198
|
-
`}function
|
|
227
|
+
`}function D(e,n,r){return(0,t.createDocument)(e,n,{name:`razorwind-storybook`},r)}function O(e,t={}){let r=t.outputPath??`storybook/tokens`,i=f(e.tokens,t),a=i.some(e=>e.type===`color`),o=i.some(e=>e.type===`fontFamily`||e.type===`fontWeight`||e.type===`typography`||e.type===`dimension`&&/(?:font|type|text).*size|size.*(?:font|type|text)/i.test(e.path)),s=!t.skipIcons&&S(e.icons)&&Object.keys(e.icons).length>0,c={[(0,n.join)(r,`blocks/ColorPalette.tsx`)]:D((0,n.join)(r,`blocks/ColorPalette.tsx`),h(i,t),`tsx`),[(0,n.join)(r,`blocks/Typeset.tsx`)]:D((0,n.join)(r,`blocks/Typeset.tsx`),g(i,t),`tsx`),[(0,n.join)(r,`blocks/TokenTable.tsx`)]:D((0,n.join)(r,`blocks/TokenTable.tsx`),_(i),`tsx`),[(0,n.join)(r,`blocks/IconGallery.tsx`)]:D((0,n.join)(r,`blocks/IconGallery.tsx`),C(t.skipIcons?{}:e.icons),`tsx`),[(0,n.join)(r,`blocks/index.ts`)]:D((0,n.join)(r,`blocks/index.ts`),T(),`typescript`),[(0,n.join)(r,`Tokens.mdx`)]:D((0,n.join)(r,`Tokens.mdx`),v({titlePrefix:t.titlePrefix,hasColors:a,hasTypography:o}),`mdx`)};if(a&&(c[(0,n.join)(r,`Colors.mdx`)]=D((0,n.join)(r,`Colors.mdx`),y(t),`mdx`)),o&&(c[(0,n.join)(r,`Typography.mdx`)]=D((0,n.join)(r,`Typography.mdx`),b(t),`mdx`)),s&&(c[(0,n.join)(r,`Icons.mdx`)]=D((0,n.join)(r,`Icons.mdx`),w(t),`mdx`)),c[(0,n.join)(r,`tokens.json`)]=D((0,n.join)(r,`tokens.json`),`${JSON.stringify(i,null,2)}\n`,`json`),t.generateTheme){let i=t.generateTheme(e.tokens);if(typeof i==`object`&&i)for(let[e,t]of Object.entries(i))c[(0,n.join)(r,`theme-${e}.ts`)]=D((0,n.join)(r,`theme-${e}.ts`),E(t),`typescript`);else c[(0,n.join)(r,`theme.ts`)]=D((0,n.join)(r,`theme.ts`),E(i),`typescript`)}return c}var k=(0,e.definePlugin)(e=>({name:`storybook`,generate:async t=>O(t,e??{})}));exports.default=k,exports.flattenTokens=f,Object.defineProperty(exports,"formatTokenValue",{enumerable:!0,get:function(){return t.formatTokenValue}}),exports.generateTokenDocs=O,exports.renderThemeFile=E,exports.resolveTokenSets=d,Object.defineProperty(exports,"toCssVar",{enumerable:!0,get:function(){return t.toCssVar}});
|
package/dist/index.d.cts
CHANGED
|
@@ -116,6 +116,12 @@ interface StorybookPluginOptions {
|
|
|
116
116
|
* @see https://storybook.js.org/docs/configure/user-interface/theming
|
|
117
117
|
*/
|
|
118
118
|
generateTheme?: GenerateStorybookTheme;
|
|
119
|
+
/**
|
|
120
|
+
* Skip generating icon documentation pages.
|
|
121
|
+
*
|
|
122
|
+
* @defaultValue `false`
|
|
123
|
+
*/
|
|
124
|
+
skipIcons?: boolean;
|
|
119
125
|
}
|
|
120
126
|
//#endregion
|
|
121
127
|
//#region src/flatten.d.ts
|
|
@@ -150,7 +156,7 @@ declare function generateTokenDocs(spec: Schema, options?: StorybookPluginOption
|
|
|
150
156
|
//#region src/index.d.ts
|
|
151
157
|
/**
|
|
152
158
|
* Razorwind plugin that turns design tokens into Storybook MDX doc blocks
|
|
153
|
-
* (`ColorPalette`, `Typeset`, `TokenTable`) and optional UI themes.
|
|
159
|
+
* (`ColorPalette`, `Typeset`, `TokenTable`, `IconGallery`) and optional UI themes.
|
|
154
160
|
*
|
|
155
161
|
* @see https://storybook.js.org/docs/writing-docs/doc-blocks
|
|
156
162
|
* @see https://storybook.js.org/docs/configure/user-interface/theming
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAuBiB;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;;EAEf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,uBACV,iBAAiB,eAAe;;;;;;KAOtB,0BACV,QAAQ,SAAS,eAAe,YAC7B;;;;UAKY;;;;;;EAMf;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,eAAe;;;;;;EAOf;;;;;;;;;EAUA,gBAAgB;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/flatten.ts","../src/generate.ts","../src/index.ts"],"mappings":";;;;;;;;UAuBiB;;EAEf;;EAEA,OAAO;;EAEP;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQe;;EAEf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,uBACV,iBAAiB,eAAe;;;;;;KAOtB,0BACV,QAAQ,SAAS,eAAe,YAC7B;;;;UAKY;;;;;;EAMf;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA,eAAe;;;;;;EAOf;;;;;;;;;EAUA,gBAAgB;;;;;;EAOhB;;;;UC5Ce;EACf;EACA,QAAQ;;;;;;;;iBASM,iBACd,QAAQ,WAAS,eAAe,YAC/B;;;;iBAwBa,cACd,QAAQ,WAAS,eAAe,WAChC,UAAS,KAAK,2DACb;;;;;;;;iBC8Ta,gBAAgB,OAAO;;;;iBAmCvB,kBACd,MAAM,QACN,UAAS,yBACR,wBAAwB,QAAQ"}
|
package/dist/index.d.mts
CHANGED
|
@@ -116,6 +116,12 @@ interface StorybookPluginOptions {
|
|
|
116
116
|
* @see https://storybook.js.org/docs/configure/user-interface/theming
|
|
117
117
|
*/
|
|
118
118
|
generateTheme?: GenerateStorybookTheme;
|
|
119
|
+
/**
|
|
120
|
+
* Skip generating icon documentation pages.
|
|
121
|
+
*
|
|
122
|
+
* @defaultValue `false`
|
|
123
|
+
*/
|
|
124
|
+
skipIcons?: boolean;
|
|
119
125
|
}
|
|
120
126
|
//#endregion
|
|
121
127
|
//#region src/flatten.d.ts
|
|
@@ -150,7 +156,7 @@ declare function generateTokenDocs(spec: Schema, options?: StorybookPluginOption
|
|
|
150
156
|
//#region src/index.d.ts
|
|
151
157
|
/**
|
|
152
158
|
* Razorwind plugin that turns design tokens into Storybook MDX doc blocks
|
|
153
|
-
* (`ColorPalette`, `Typeset`, `TokenTable`) and optional UI themes.
|
|
159
|
+
* (`ColorPalette`, `Typeset`, `TokenTable`, `IconGallery`) and optional UI themes.
|
|
154
160
|
*
|
|
155
161
|
* @see https://storybook.js.org/docs/writing-docs/doc-blocks
|
|
156
162
|
* @see https://storybook.js.org/docs/configure/user-interface/theming
|
package/dist/index.mjs
CHANGED
|
@@ -180,11 +180,40 @@ import { TypesetBlock } from "./blocks/Typeset";
|
|
|
180
180
|
# Typography
|
|
181
181
|
|
|
182
182
|
<TypesetBlock />
|
|
183
|
-
`}function w(){return`
|
|
183
|
+
`}function w(e,t){let n=e[t];return typeof n==`string`?n:void 0}function T(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function E(e){return`import { IconGallery, IconItem } from "@storybook/addon-docs/blocks";
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Icons rendered with Storybook's IconGallery doc block.
|
|
187
|
+
*
|
|
188
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-icongallery
|
|
189
|
+
*/
|
|
190
|
+
export function IconGalleryBlock() {
|
|
191
|
+
return (
|
|
192
|
+
<IconGallery>
|
|
193
|
+
${(T(e)?Object.values(e).filter(T).toSorted((e,t)=>(w(e,`name`)??``).localeCompare(w(t,`name`)??``)):[]).map(e=>{let t=w(e,`name`)??`unknown`,n=(Array.isArray(e.files)?e.files:[]).find(e=>T(e)&&w(e,`type`)===`svg`&&typeof e.content==`string`),r=T(n)&&typeof n.content==`string`?`<span
|
|
194
|
+
style={{ display: "inline-flex", width: 24, height: 24 }}
|
|
195
|
+
dangerouslySetInnerHTML={{ __html: ${s(n.content)} }}
|
|
196
|
+
/>`:`<code>${o(t)}</code>`;return` <IconItem name={${s(t)}}>
|
|
197
|
+
${r}
|
|
198
|
+
</IconItem>`}).join(`
|
|
199
|
+
`)||` {/* No icons */}`}
|
|
200
|
+
</IconGallery>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
`}function D(e={}){return`import { Meta } from "@storybook/addon-docs/blocks";
|
|
204
|
+
import { IconGalleryBlock } from "./blocks/IconGallery";
|
|
205
|
+
|
|
206
|
+
<Meta title="${o(e.titlePrefix??`Design Tokens`)}/Icons" />
|
|
207
|
+
|
|
208
|
+
# Icons
|
|
209
|
+
|
|
210
|
+
<IconGalleryBlock />
|
|
211
|
+
`}function O(){return`export { ColorPaletteBlock } from "./ColorPalette";
|
|
212
|
+
export { IconGalleryBlock } from "./IconGallery";
|
|
184
213
|
export { TokenTableBlock } from "./TokenTable";
|
|
185
214
|
export type { TokenTableBlockProps, TokenTableRow } from "./TokenTable";
|
|
186
215
|
export { TypesetBlock } from "./Typeset";
|
|
187
|
-
`}function
|
|
216
|
+
`}function k(e){return`import { create } from "storybook/theming";
|
|
188
217
|
|
|
189
218
|
/**
|
|
190
219
|
* Storybook UI theme generated by \`@razorwind/storybook\`.
|
|
@@ -195,5 +224,5 @@ export default create({
|
|
|
195
224
|
${Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>` ${e}: ${s(t)}`).join(`,
|
|
196
225
|
`)}
|
|
197
226
|
});
|
|
198
|
-
`}function
|
|
227
|
+
`}function A(e,n,r){return t(e,n,{name:`razorwind-storybook`},r)}function j(e,t={}){let n=t.outputPath??`storybook/tokens`,r=h(e.tokens,t),i=r.some(e=>e.type===`color`),o=r.some(e=>e.type===`fontFamily`||e.type===`fontWeight`||e.type===`typography`||e.type===`dimension`&&/(?:font|type|text).*size|size.*(?:font|type|text)/i.test(e.path)),s=!t.skipIcons&&T(e.icons)&&Object.keys(e.icons).length>0,c={[a(n,`blocks/ColorPalette.tsx`)]:A(a(n,`blocks/ColorPalette.tsx`),v(r,t),`tsx`),[a(n,`blocks/Typeset.tsx`)]:A(a(n,`blocks/Typeset.tsx`),y(r,t),`tsx`),[a(n,`blocks/TokenTable.tsx`)]:A(a(n,`blocks/TokenTable.tsx`),b(r),`tsx`),[a(n,`blocks/IconGallery.tsx`)]:A(a(n,`blocks/IconGallery.tsx`),E(t.skipIcons?{}:e.icons),`tsx`),[a(n,`blocks/index.ts`)]:A(a(n,`blocks/index.ts`),O(),`typescript`),[a(n,`Tokens.mdx`)]:A(a(n,`Tokens.mdx`),x({titlePrefix:t.titlePrefix,hasColors:i,hasTypography:o}),`mdx`)};if(i&&(c[a(n,`Colors.mdx`)]=A(a(n,`Colors.mdx`),S(t),`mdx`)),o&&(c[a(n,`Typography.mdx`)]=A(a(n,`Typography.mdx`),C(t),`mdx`)),s&&(c[a(n,`Icons.mdx`)]=A(a(n,`Icons.mdx`),D(t),`mdx`)),c[a(n,`tokens.json`)]=A(a(n,`tokens.json`),`${JSON.stringify(r,null,2)}\n`,`json`),t.generateTheme){let r=t.generateTheme(e.tokens);if(typeof r==`object`&&r)for(let[e,t]of Object.entries(r))c[a(n,`theme-${e}.ts`)]=A(a(n,`theme-${e}.ts`),k(t),`typescript`);else c[a(n,`theme.ts`)]=A(a(n,`theme.ts`),k(r),`typescript`)}return c}var M=e(e=>({name:`storybook`,generate:async t=>j(t,e??{})}));export{M as default,h as flattenTokens,n as formatTokenValue,j as generateTokenDocs,k as renderThemeFile,m as resolveTokenSets,i as toCssVar};
|
|
199
228
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@razorwind/storybook",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Razorwind plugin that creates Storybook MDX token doc blocks from Razorwind design tokens.",
|
|
6
6
|
"repository": {
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"types": "./dist/index.d.cts",
|
|
84
84
|
"typings": "dist/index.d.mts",
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@power-plant/core": "^0.0.
|
|
86
|
+
"@power-plant/core": "^0.0.75",
|
|
87
87
|
"@power-plant/dtcg-schema": "^0.0.1",
|
|
88
|
-
"@razorwind/core": "
|
|
89
|
-
"@stryke/type-checks": "^0.6.
|
|
88
|
+
"@razorwind/core": "0.0.27",
|
|
89
|
+
"@stryke/type-checks": "^0.6.35"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@storybook/addon-docs": ">=8",
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"storybook": { "optional": true }
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@powerlines/plugin-tsdown": "^0.1.
|
|
102
|
+
"@powerlines/plugin-tsdown": "^0.1.589",
|
|
103
103
|
"@types/node": "^25.9.5",
|
|
104
104
|
"typescript": "^6.0.3"
|
|
105
105
|
},
|
|
106
106
|
"publishConfig": { "access": "public" },
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "556f2499e0ef94c0463e86c2d8f9b42bbdb0bc08"
|
|
108
108
|
}
|