@repobuddy/storybook 2.0.1 โ 2.1.1
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/esm/index.d.ts +574 -13
- package/esm/index.js +251 -12
- package/esm/manager/index.d.ts +38 -1
- package/esm/manager/index.js +32 -1
- package/esm/storybook-addon-tag-badges/index.d.ts +95 -2
- package/esm/storybook-addon-tag-badges/index.js +207 -1
- package/esm/storybook-dark-mode/index.d.ts +110 -3
- package/esm/storybook-dark-mode/index.js +102 -3
- package/package.json +4 -12
- package/cjs/components/show_html.d.ts +0 -16
- package/cjs/components/show_html.js +0 -29
- package/cjs/decorators/show_doc_source.d.ts +0 -6
- package/cjs/decorators/show_doc_source.js +0 -38
- package/cjs/index.d.ts +0 -13
- package/cjs/index.js +0 -137
- package/cjs/manager/brand_title.d.ts +0 -35
- package/cjs/manager/brand_title.js +0 -12
- package/cjs/manager/index.d.ts +0 -1
- package/cjs/manager/index.js +0 -16
- package/cjs/parameters/define_actions_param.d.ts +0 -24
- package/cjs/parameters/define_actions_param.js +0 -11
- package/cjs/parameters/define_backgrounds_param.d.ts +0 -45
- package/cjs/parameters/define_backgrounds_param.js +0 -10
- package/cjs/parameters/define_docs_param.d.ts +0 -217
- package/cjs/parameters/define_docs_param.js +0 -11
- package/cjs/parameters/define_layout_param.d.ts +0 -20
- package/cjs/parameters/define_layout_param.js +0 -10
- package/cjs/parameters/define_parameters.d.ts +0 -39
- package/cjs/parameters/define_parameters.js +0 -9
- package/cjs/parameters/define_test_param.d.ts +0 -34
- package/cjs/parameters/define_test_param.js +0 -11
- package/cjs/parameters/define_viewport_param.d.ts +0 -78
- package/cjs/parameters/define_viewport_param.js +0 -11
- package/cjs/parameters/story_sort.d.ts +0 -27
- package/cjs/parameters/story_sort.js +0 -1
- package/cjs/storybook-addon-tag-badges/index.d.ts +0 -2
- package/cjs/storybook-addon-tag-badges/index.js +0 -16
- package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
- package/cjs/storybook-addon-tag-badges/tag_badges.js +0 -179
- package/cjs/storybook-addon-tag-badges/types.d.ts +0 -9
- package/cjs/storybook-addon-tag-badges/types.js +0 -1
- package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
- package/cjs/storybook-dark-mode/dark_mode_docs_container.js +0 -23
- package/cjs/storybook-dark-mode/define_dark_mode.d.ts +0 -54
- package/cjs/storybook-dark-mode/define_dark_mode.js +0 -11
- package/cjs/storybook-dark-mode/index.d.ts +0 -3
- package/cjs/storybook-dark-mode/index.js +0 -38
- package/cjs/storybook-dark-mode/with_dark_mode.d.ts +0 -22
- package/cjs/storybook-dark-mode/with_dark_mode.js +0 -54
- package/cjs/testing/decorators/when_running_in_test.d.ts +0 -5
- package/cjs/testing/decorators/when_running_in_test.js +0 -12
- package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
- package/cjs/testing/decorators/when_running_in_text.ctx.js +0 -10
- package/cjs/types.d.ts +0 -41
- package/cjs/types.js +0 -1
- package/cjs/variants/index.d.ts +0 -1
- package/cjs/variants/index.js +0 -8
- package/cjs/variants/package.json +0 -3
- package/cjs/variants/preset.d.ts +0 -11
- package/cjs/variants/preset.js +0 -3
- package/esm/components/show_html.d.ts +0 -16
- package/esm/components/show_html.js +0 -19
- package/esm/decorators/show_doc_source.d.ts +0 -6
- package/esm/decorators/show_doc_source.js +0 -28
- package/esm/manager/brand_title.d.ts +0 -35
- package/esm/manager/brand_title.js +0 -6
- package/esm/parameters/define_actions_param.d.ts +0 -24
- package/esm/parameters/define_actions_param.js +0 -3
- package/esm/parameters/define_backgrounds_param.d.ts +0 -45
- package/esm/parameters/define_backgrounds_param.js +0 -3
- package/esm/parameters/define_docs_param.d.ts +0 -217
- package/esm/parameters/define_docs_param.js +0 -3
- package/esm/parameters/define_layout_param.d.ts +0 -20
- package/esm/parameters/define_layout_param.js +0 -3
- package/esm/parameters/define_parameters.d.ts +0 -39
- package/esm/parameters/define_parameters.js +0 -3
- package/esm/parameters/define_test_param.d.ts +0 -34
- package/esm/parameters/define_test_param.js +0 -3
- package/esm/parameters/define_viewport_param.d.ts +0 -78
- package/esm/parameters/define_viewport_param.js +0 -3
- package/esm/parameters/story_sort.d.ts +0 -27
- package/esm/parameters/story_sort.js +0 -0
- package/esm/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
- package/esm/storybook-addon-tag-badges/tag_badges.js +0 -189
- package/esm/storybook-addon-tag-badges/types.d.ts +0 -9
- package/esm/storybook-addon-tag-badges/types.js +0 -0
- package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
- package/esm/storybook-dark-mode/dark_mode_docs_container.js +0 -21
- package/esm/storybook-dark-mode/define_dark_mode.d.ts +0 -54
- package/esm/storybook-dark-mode/define_dark_mode.js +0 -3
- package/esm/storybook-dark-mode/with_dark_mode.d.ts +0 -22
- package/esm/storybook-dark-mode/with_dark_mode.js +0 -46
- package/esm/testing/decorators/when_running_in_test.d.ts +0 -5
- package/esm/testing/decorators/when_running_in_test.js +0 -6
- package/esm/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
- package/esm/testing/decorators/when_running_in_text.ctx.js +0 -4
- package/esm/types.d.ts +0 -41
- package/esm/types.js +0 -0
- package/esm/variants/index.d.ts +0 -1
- package/esm/variants/index.js +0 -2
- package/esm/variants/package.json +0 -3
- package/esm/variants/preset.d.ts +0 -11
- package/esm/variants/preset.js +0 -1
package/esm/index.js
CHANGED
|
@@ -1,12 +1,251 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export * from "
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { isRunningInTest } from "@repobuddy/test";
|
|
2
|
+
import { prettify } from "htmlfy";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { SyntaxHighlighter } from "storybook/internal/components";
|
|
6
|
+
import { addons } from "storybook/preview-api";
|
|
7
|
+
import { ThemeProvider, convert, themes } from "storybook/theming";
|
|
8
|
+
|
|
9
|
+
export * from "@repobuddy/test"
|
|
10
|
+
|
|
11
|
+
//#region src/components/show_html.tsx
|
|
12
|
+
/**
|
|
13
|
+
* A component that displays the HTML of a subject element.
|
|
14
|
+
* Uses `htmlfy` internally to format and prettify the HTML output.
|
|
15
|
+
*
|
|
16
|
+
* @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
|
|
17
|
+
* @param config - Configuration options passed to htmlfy's prettify function
|
|
18
|
+
* @param props - Additional props (className, style) passed to the pre element
|
|
19
|
+
* @returns A pre element containing the formatted HTML
|
|
20
|
+
*/
|
|
21
|
+
function ShowHtml({ selector = "[data-testid=\"subject\"]", config, ...props }) {
|
|
22
|
+
const [html, setHtml] = useState("");
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const subject = document.querySelector(selector);
|
|
25
|
+
if (subject) setHtml(prettify(subject.outerHTML, {
|
|
26
|
+
tag_wrap: 40,
|
|
27
|
+
...config
|
|
28
|
+
}));
|
|
29
|
+
else setHtml("No subject found");
|
|
30
|
+
}, [selector]);
|
|
31
|
+
return /* @__PURE__ */ jsx("pre", {
|
|
32
|
+
...props,
|
|
33
|
+
children: html
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/decorators/show_doc_source.tsx
|
|
39
|
+
const channel = addons.getChannel();
|
|
40
|
+
/**
|
|
41
|
+
* A decorator that shows the source code of a story above the rendered story.
|
|
42
|
+
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
43
|
+
*/
|
|
44
|
+
function showDocSource() {
|
|
45
|
+
return (Story, { parameters: { docs, darkMode } }) => {
|
|
46
|
+
const storedItem = window.localStorage.getItem("sb-addon-themes-3");
|
|
47
|
+
const current = typeof storedItem === "string" ? JSON.parse(storedItem).current : darkMode?.current;
|
|
48
|
+
const [isDark, setIsDark] = useState((darkMode?.stylePreview && current === "dark") ?? false);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
channel.on("DARK_MODE", setIsDark);
|
|
51
|
+
return () => channel.off("DARK_MODE", setIsDark);
|
|
52
|
+
}, []);
|
|
53
|
+
return /* @__PURE__ */ jsx(ThemeProvider, {
|
|
54
|
+
theme: convert(docs?.theme ?? (isDark ? themes.dark : themes.light)),
|
|
55
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
56
|
+
style: {
|
|
57
|
+
display: "flex",
|
|
58
|
+
flexDirection: "column",
|
|
59
|
+
gap: "1rem"
|
|
60
|
+
},
|
|
61
|
+
children: [/* @__PURE__ */ jsx(SyntaxHighlighter, {
|
|
62
|
+
language: docs?.source?.language,
|
|
63
|
+
children: docs?.source?.code
|
|
64
|
+
}), /* @__PURE__ */ jsx(Story, {})]
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/parameters/define_actions_param.ts
|
|
72
|
+
/**
|
|
73
|
+
* Defines actions parameters for Storybook stories.
|
|
74
|
+
*
|
|
75
|
+
* @see https://storybook.js.org/docs/essentials/actions#parameters
|
|
76
|
+
*
|
|
77
|
+
* @param actions - Configuration for actions parameters
|
|
78
|
+
* @returns An object containing the actions parameter configuration
|
|
79
|
+
*/
|
|
80
|
+
function defineActionsParam(actions) {
|
|
81
|
+
return { actions };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/parameters/define_backgrounds_param.ts
|
|
86
|
+
/**
|
|
87
|
+
* Defines backgrounds parameters for Storybook stories.
|
|
88
|
+
*
|
|
89
|
+
* @param backgrounds - The backgrounds configuration
|
|
90
|
+
* @returns An object containing the backgrounds parameter configuration
|
|
91
|
+
*/
|
|
92
|
+
const defineBackgroundsParam = (backgrounds) => ({ backgrounds });
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/parameters/define_docs_param.ts
|
|
96
|
+
/**
|
|
97
|
+
* Defines docs parameters for Storybook stories.
|
|
98
|
+
*
|
|
99
|
+
* @param docs - Configuration for docs parameters including options for:
|
|
100
|
+
* - Controls display and sorting
|
|
101
|
+
* - Story rendering (autoplay, height, inline vs iframe)
|
|
102
|
+
* - And other docs-related settings
|
|
103
|
+
* @returns An object containing the docs parameter configuration
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
108
|
+
*
|
|
109
|
+
* export default {
|
|
110
|
+
* parameters: defineDocsParam({
|
|
111
|
+
* controls: {
|
|
112
|
+
* sort: 'alpha',
|
|
113
|
+
* exclude: ['internal*']
|
|
114
|
+
* },
|
|
115
|
+
* story: {
|
|
116
|
+
* inline: true,
|
|
117
|
+
* height: '400px'
|
|
118
|
+
* }
|
|
119
|
+
* })
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
function defineDocsParam(docs) {
|
|
124
|
+
return { docs };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/parameters/define_layout_param.ts
|
|
129
|
+
/**
|
|
130
|
+
* Helper function to define the layout parameter for a story
|
|
131
|
+
*
|
|
132
|
+
* @see https://storybook.js.org/docs/api/parameters#layout
|
|
133
|
+
*
|
|
134
|
+
* @param layout - The layout type to use ('padded', 'fullscreen', or 'centered')
|
|
135
|
+
* @returns An object containing the layout parameter
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* export const MyStory = {
|
|
139
|
+
* parameters: defineLayoutParam('centered')
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
const defineLayoutParam = (layout) => ({ layout });
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/parameters/define_parameters.ts
|
|
147
|
+
/**
|
|
148
|
+
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
|
|
149
|
+
*
|
|
150
|
+
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
|
|
151
|
+
* @returns The combined parameters object
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* import { defineParameters } from '@repobuddy/storybook'
|
|
156
|
+
*
|
|
157
|
+
* export default {
|
|
158
|
+
* parameters: defineParameters({
|
|
159
|
+
* // Built-in parameters
|
|
160
|
+
* layout: 'centered',
|
|
161
|
+
* backgrounds: {
|
|
162
|
+
* default: 'light',
|
|
163
|
+
* values: [
|
|
164
|
+
* { name: 'light', value: '#ffffff' },
|
|
165
|
+
* { name: 'dark', value: '#333333' }
|
|
166
|
+
* ]
|
|
167
|
+
* },
|
|
168
|
+
* // Custom parameters
|
|
169
|
+
* myCustomParam: {
|
|
170
|
+
* someValue: true
|
|
171
|
+
* }
|
|
172
|
+
* })
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
function defineParameters(param, ...rest) {
|
|
177
|
+
return rest.reduce((acc, param$1) => Object.assign(acc, param$1), param);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/parameters/define_test_param.ts
|
|
182
|
+
/**
|
|
183
|
+
* Defines test parameters for Storybook stories.
|
|
184
|
+
*
|
|
185
|
+
* @see https://storybook.js.org/docs/api/parameters#test
|
|
186
|
+
*
|
|
187
|
+
* @param test - Configuration for test parameters
|
|
188
|
+
* @returns An object containing the test parameter configuration
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* defineTestParam({
|
|
192
|
+
* clearMocks: true,
|
|
193
|
+
* mockReset: true,
|
|
194
|
+
* restoreMocks: true,
|
|
195
|
+
* dangerouslyIgnoreUnhandledErrors: true
|
|
196
|
+
* })
|
|
197
|
+
*/
|
|
198
|
+
function defineTestParam(test) {
|
|
199
|
+
return { test };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/parameters/define_viewport_param.ts
|
|
204
|
+
/**
|
|
205
|
+
* Defines viewport parameters for Storybook stories.
|
|
206
|
+
*
|
|
207
|
+
* @see https://storybook.js.org/docs/api/parameters#viewport
|
|
208
|
+
*
|
|
209
|
+
* @param viewport - Configuration for viewport parameters including:
|
|
210
|
+
* - viewports: Custom viewport definitions
|
|
211
|
+
* - defaultViewport: The default viewport to use
|
|
212
|
+
* - defaultOrientation: Default orientation (landscape/portrait)
|
|
213
|
+
* - disabled: Whether viewport controls are disabled
|
|
214
|
+
* @returns An object containing the viewport parameter configuration
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* defineViewportParam({
|
|
219
|
+
* viewports: {
|
|
220
|
+
* mobile: {
|
|
221
|
+
* name: 'Mobile',
|
|
222
|
+
* styles: { width: '320px', height: '568px' },
|
|
223
|
+
* type: 'mobile'
|
|
224
|
+
* }
|
|
225
|
+
* },
|
|
226
|
+
* defaultViewport: 'mobile',
|
|
227
|
+
* defaultOrientation: 'portrait'
|
|
228
|
+
* })
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
function defineViewportParam(viewport) {
|
|
232
|
+
return { viewport };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/testing/decorators/when_running_in_text.ctx.ts
|
|
237
|
+
const ctx = { isRunningInTest };
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/testing/decorators/when_running_in_test.tsx
|
|
241
|
+
/**
|
|
242
|
+
* executes the specified decorator or handler if the code is running in test.
|
|
243
|
+
*/
|
|
244
|
+
function whenRunningInTest(decoratorOrHandler) {
|
|
245
|
+
return function RunInTest(Story, context) {
|
|
246
|
+
return ctx.isRunningInTest() ? decoratorOrHandler(Story, context) ?? /* @__PURE__ */ jsx(Story, {}) : /* @__PURE__ */ jsx(Story, {});
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
//#endregion
|
|
251
|
+
export { ShowHtml, defineActionsParam, defineBackgroundsParam, defineDocsParam, defineLayoutParam, defineParameters, defineTestParam, defineViewportParam, showDocSource, whenRunningInTest };
|
package/esm/manager/index.d.ts
CHANGED
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/manager/brand_title.d.ts
|
|
2
|
+
interface BrandTitleOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The title to display in the brand title.
|
|
5
|
+
* It can be a simple string or raw HTML.
|
|
6
|
+
*/
|
|
7
|
+
title: string;
|
|
8
|
+
/**
|
|
9
|
+
* The logo to display in the brand title.
|
|
10
|
+
* It can be a simple string or raw HTML (e.g. `<svg>`).
|
|
11
|
+
*/
|
|
12
|
+
logo?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a brand title element for the Storybook manager UI.
|
|
16
|
+
*
|
|
17
|
+
* @param options - The options for customizing the brand title
|
|
18
|
+
* @param options.title - The title text or HTML to display
|
|
19
|
+
* @param options.logo - Optional logo HTML to display before the title
|
|
20
|
+
* @returns An HTML string containing the brand title element
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { brandTitle } from '@repobuddy/storybook'
|
|
26
|
+
* import { addons } from 'storybook/manager-api'
|
|
27
|
+
*
|
|
28
|
+
* addons.setConfig({
|
|
29
|
+
* brandTitle: brandTitle({
|
|
30
|
+
* title: 'My Storybook',
|
|
31
|
+
* logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
|
|
32
|
+
* })
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function brandTitle(options: BrandTitleOptions): string;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { BrandTitleOptions, brandTitle };
|
package/esm/manager/index.js
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/manager/brand_title.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a brand title element for the Storybook manager UI.
|
|
4
|
+
*
|
|
5
|
+
* @param options - The options for customizing the brand title
|
|
6
|
+
* @param options.title - The title text or HTML to display
|
|
7
|
+
* @param options.logo - Optional logo HTML to display before the title
|
|
8
|
+
* @returns An HTML string containing the brand title element
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { brandTitle } from '@repobuddy/storybook'
|
|
14
|
+
* import { addons } from 'storybook/manager-api'
|
|
15
|
+
*
|
|
16
|
+
* addons.setConfig({
|
|
17
|
+
* brandTitle: brandTitle({
|
|
18
|
+
* title: 'My Storybook',
|
|
19
|
+
* logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
|
|
20
|
+
* })
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function brandTitle(options) {
|
|
25
|
+
return `<span style="display: flex; align-items: center; gap: 2px;">
|
|
26
|
+
${options.logo ?? ""}
|
|
27
|
+
${options.title}
|
|
28
|
+
</span>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { brandTitle };
|
|
@@ -1,2 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { TagBadgeParameters } from "storybook-addon-tag-badges/manager-helpers";
|
|
2
|
+
import { Args, Meta as Meta$1, StoryObj as StoryObj$1 } from "@storybook/react-vite";
|
|
3
|
+
|
|
4
|
+
//#region src/storybook-addon-tag-badges/tag_badges.d.ts
|
|
5
|
+
type TagBadgeParameter = TagBadgeParameters[0];
|
|
6
|
+
/**
|
|
7
|
+
* Type representing the names of predefined tags used in Storybook stories.
|
|
8
|
+
*/
|
|
9
|
+
type TagNames = 'editor' | 'new' | 'beta' | 'props' | 'deprecated' | 'outdated' | 'danger' | 'todo' | 'code-only' | 'snapshot' | 'unit' | 'integration' | 'keyboard' | 'internal';
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for story tag badges that appear in the Storybook sidebar.
|
|
12
|
+
* Each badge is associated with a specific tag and displays an emoji with a tooltip.
|
|
13
|
+
*
|
|
14
|
+
* The badges help visually identify stories with certain characteristics:
|
|
15
|
+
* - โ๏ธ Editor - Stories with live editor
|
|
16
|
+
* - ๐ New - Recently added stories
|
|
17
|
+
* - ๐
ฑ๏ธ Beta - Stories for features in beta
|
|
18
|
+
* - ๐ชฆ Deprecated - Stories for deprecated features
|
|
19
|
+
* - โ ๏ธ Outdated - Stories that need updating
|
|
20
|
+
* - ๐จ Danger - Stories demonstrating dangerous patterns
|
|
21
|
+
* - ๐ Todo - Stories marked as todo/incomplete
|
|
22
|
+
* - ๐ Code Only - Stories without visual examples
|
|
23
|
+
* - ๐ธ Snapshot - Stories with snapshot tests
|
|
24
|
+
* - ๐งช Unit - Stories with unit tests
|
|
25
|
+
* - ๐ Integration - Stories with integration tests
|
|
26
|
+
*
|
|
27
|
+
* Also includes the default version badge from `storybook-addon-tag-badges`.
|
|
28
|
+
*/
|
|
29
|
+
declare const editorBadge: TagBadgeParameter;
|
|
30
|
+
declare const newBadge: TagBadgeParameter;
|
|
31
|
+
declare const betaBadge: TagBadgeParameter;
|
|
32
|
+
declare const propsBadge: TagBadgeParameter;
|
|
33
|
+
declare const deprecatedBadge: TagBadgeParameter;
|
|
34
|
+
declare const outdatedBadge: TagBadgeParameter;
|
|
35
|
+
declare const dangerBadge: TagBadgeParameter;
|
|
36
|
+
declare const todoBadge: TagBadgeParameter;
|
|
37
|
+
declare const codeOnlyBadge: TagBadgeParameter;
|
|
38
|
+
declare const snapshotBadge: TagBadgeParameter;
|
|
39
|
+
declare const unitBadge: TagBadgeParameter;
|
|
40
|
+
declare const integrationBadge: TagBadgeParameter;
|
|
41
|
+
declare const keyboardBadge: TagBadgeParameter;
|
|
42
|
+
declare const internalBadge: TagBadgeParameter;
|
|
43
|
+
declare const tagBadges: TagBadgeParameters;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/types.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Extends the Storybook Meta type with custom tag types
|
|
48
|
+
* @template TCmpOrArgs - The component or args type
|
|
49
|
+
* @template M - The base Meta type
|
|
50
|
+
* @template E - The extension type containing tagType
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // Create a generic Meta type for a project
|
|
55
|
+
* type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, Meta<TCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
|
|
56
|
+
*
|
|
57
|
+
* // Create a specific Meta type for a component
|
|
58
|
+
* type Meta = ExtendMeta<typeof Component, Meta<typeof Component>, { tagType: 'tag1' | 'tag2' }>
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
type ExtendMeta<TCmpOrArgs, M extends Meta$1<TCmpOrArgs>, E extends {
|
|
62
|
+
tag: string;
|
|
63
|
+
}> = Omit<M, 'tags'> & {
|
|
64
|
+
tags?: Array<E['tag'] | (string & {})> | undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Extends the Storybook StoryObj type with custom tag types
|
|
68
|
+
* @template TMetaOrCmpOrArgs - The meta, component or args type
|
|
69
|
+
* @template S - The base StoryObj type
|
|
70
|
+
* @template E - The extension type containing tagType
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* // Create a generic StoryObj type for a project
|
|
75
|
+
* type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, StoryObj<TMetaOrCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
|
|
76
|
+
*
|
|
77
|
+
* // Create a specific StoryObj type for a component
|
|
78
|
+
* type StoryObj = ExtendStoryObj<typeof Component, StoryObj<typeof Component>, { tagType: 'tag1' | 'tag2' }>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
type ExtendStoryObj<TMetaOrCmpOrArgs, S extends StoryObj$1<TMetaOrCmpOrArgs>, E extends {
|
|
82
|
+
tag: string;
|
|
83
|
+
}> = Omit<S, 'tags'> & {
|
|
84
|
+
tags?: Array<E['tag'] | (string & {})> | undefined;
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/storybook-addon-tag-badges/types.d.ts
|
|
88
|
+
type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, Meta$1<TCmpOrArgs>, {
|
|
89
|
+
tag: TagNames;
|
|
90
|
+
}>;
|
|
91
|
+
type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, StoryObj$1<TMetaOrCmpOrArgs>, {
|
|
92
|
+
tag: TagNames;
|
|
93
|
+
}>;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { Meta, StoryObj, TagNames, betaBadge, codeOnlyBadge, dangerBadge, deprecatedBadge, editorBadge, integrationBadge, internalBadge, keyboardBadge, newBadge, outdatedBadge, propsBadge, snapshotBadge, tagBadges, todoBadge, unitBadge };
|
|
@@ -1 +1,207 @@
|
|
|
1
|
-
|
|
1
|
+
import { defaultConfig } from "storybook-addon-tag-badges/manager-helpers";
|
|
2
|
+
|
|
3
|
+
//#region src/storybook-addon-tag-badges/tag_badges.ts
|
|
4
|
+
const [, , , , , , versionBadge] = defaultConfig;
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for story tag badges that appear in the Storybook sidebar.
|
|
7
|
+
* Each badge is associated with a specific tag and displays an emoji with a tooltip.
|
|
8
|
+
*
|
|
9
|
+
* The badges help visually identify stories with certain characteristics:
|
|
10
|
+
* - โ๏ธ Editor - Stories with live editor
|
|
11
|
+
* - ๐ New - Recently added stories
|
|
12
|
+
* - ๐
ฑ๏ธ Beta - Stories for features in beta
|
|
13
|
+
* - ๐ชฆ Deprecated - Stories for deprecated features
|
|
14
|
+
* - โ ๏ธ Outdated - Stories that need updating
|
|
15
|
+
* - ๐จ Danger - Stories demonstrating dangerous patterns
|
|
16
|
+
* - ๐ Todo - Stories marked as todo/incomplete
|
|
17
|
+
* - ๐ Code Only - Stories without visual examples
|
|
18
|
+
* - ๐ธ Snapshot - Stories with snapshot tests
|
|
19
|
+
* - ๐งช Unit - Stories with unit tests
|
|
20
|
+
* - ๐ Integration - Stories with integration tests
|
|
21
|
+
*
|
|
22
|
+
* Also includes the default version badge from `storybook-addon-tag-badges`.
|
|
23
|
+
*/
|
|
24
|
+
const editorBadge = {
|
|
25
|
+
tags: "editor",
|
|
26
|
+
badge: {
|
|
27
|
+
text: "โ๏ธ",
|
|
28
|
+
style: {
|
|
29
|
+
backgroundColor: "transparent",
|
|
30
|
+
borderColor: "transparent"
|
|
31
|
+
},
|
|
32
|
+
tooltip: "Editor"
|
|
33
|
+
},
|
|
34
|
+
display: { sidebar: {
|
|
35
|
+
type: "story",
|
|
36
|
+
skipInherited: false
|
|
37
|
+
} }
|
|
38
|
+
};
|
|
39
|
+
const newBadge = {
|
|
40
|
+
tags: "new",
|
|
41
|
+
badge: {
|
|
42
|
+
text: "๐",
|
|
43
|
+
style: {
|
|
44
|
+
backgroundColor: "transparent",
|
|
45
|
+
borderColor: "transparent"
|
|
46
|
+
},
|
|
47
|
+
tooltip: "New"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const betaBadge = {
|
|
51
|
+
tags: "beta",
|
|
52
|
+
badge: {
|
|
53
|
+
text: "๐
ฑ๏ธ",
|
|
54
|
+
style: {
|
|
55
|
+
backgroundColor: "transparent",
|
|
56
|
+
borderColor: "transparent"
|
|
57
|
+
},
|
|
58
|
+
tooltip: "Beta"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const propsBadge = {
|
|
62
|
+
tags: "props",
|
|
63
|
+
badge: {
|
|
64
|
+
text: "๐ง",
|
|
65
|
+
style: {
|
|
66
|
+
backgroundColor: "transparent",
|
|
67
|
+
borderColor: "transparent"
|
|
68
|
+
},
|
|
69
|
+
tooltip: "Props"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const deprecatedBadge = {
|
|
73
|
+
tags: "deprecated",
|
|
74
|
+
badge: {
|
|
75
|
+
text: "๐ชฆ",
|
|
76
|
+
style: {
|
|
77
|
+
backgroundColor: "transparent",
|
|
78
|
+
borderColor: "transparent"
|
|
79
|
+
},
|
|
80
|
+
tooltip: "Deprecated"
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const outdatedBadge = {
|
|
84
|
+
tags: "outdated",
|
|
85
|
+
badge: {
|
|
86
|
+
text: "โ ๏ธ",
|
|
87
|
+
style: {
|
|
88
|
+
backgroundColor: "transparent",
|
|
89
|
+
borderColor: "transparent"
|
|
90
|
+
},
|
|
91
|
+
tooltip: "Outdated"
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const dangerBadge = {
|
|
95
|
+
tags: "danger",
|
|
96
|
+
badge: {
|
|
97
|
+
text: "๐จ",
|
|
98
|
+
style: {
|
|
99
|
+
backgroundColor: "transparent",
|
|
100
|
+
borderColor: "transparent"
|
|
101
|
+
},
|
|
102
|
+
tooltip: "Dangerous"
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const todoBadge = {
|
|
106
|
+
tags: "todo",
|
|
107
|
+
badge: {
|
|
108
|
+
text: "๐",
|
|
109
|
+
style: {
|
|
110
|
+
backgroundColor: "transparent",
|
|
111
|
+
borderColor: "transparent"
|
|
112
|
+
},
|
|
113
|
+
tooltip: "Todo"
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const codeOnlyBadge = {
|
|
117
|
+
tags: "code-only",
|
|
118
|
+
badge: {
|
|
119
|
+
text: "๐",
|
|
120
|
+
style: {
|
|
121
|
+
backgroundColor: "transparent",
|
|
122
|
+
borderColor: "transparent"
|
|
123
|
+
},
|
|
124
|
+
tooltip: "Code Only"
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const snapshotBadge = {
|
|
128
|
+
tags: "snapshot",
|
|
129
|
+
badge: {
|
|
130
|
+
text: "๐ธ",
|
|
131
|
+
style: {
|
|
132
|
+
backgroundColor: "transparent",
|
|
133
|
+
borderColor: "transparent"
|
|
134
|
+
},
|
|
135
|
+
tooltip: "Snapshot Test"
|
|
136
|
+
},
|
|
137
|
+
display: {
|
|
138
|
+
sidebar: false,
|
|
139
|
+
toolbar: ["story"]
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const unitBadge = {
|
|
143
|
+
tags: "unit",
|
|
144
|
+
badge: {
|
|
145
|
+
text: "๐งช",
|
|
146
|
+
style: {
|
|
147
|
+
backgroundColor: "transparent",
|
|
148
|
+
borderColor: "transparent"
|
|
149
|
+
},
|
|
150
|
+
tooltip: "Unit Test"
|
|
151
|
+
},
|
|
152
|
+
display: { sidebar: false }
|
|
153
|
+
};
|
|
154
|
+
const integrationBadge = {
|
|
155
|
+
tags: "integration",
|
|
156
|
+
badge: {
|
|
157
|
+
text: "๐",
|
|
158
|
+
style: {
|
|
159
|
+
backgroundColor: "transparent",
|
|
160
|
+
borderColor: "transparent"
|
|
161
|
+
},
|
|
162
|
+
tooltip: "Integration Test"
|
|
163
|
+
},
|
|
164
|
+
display: { sidebar: false }
|
|
165
|
+
};
|
|
166
|
+
const keyboardBadge = {
|
|
167
|
+
tags: "keyboard",
|
|
168
|
+
badge: {
|
|
169
|
+
text: "โจ๏ธ",
|
|
170
|
+
style: {
|
|
171
|
+
backgroundColor: "transparent",
|
|
172
|
+
borderColor: "transparent"
|
|
173
|
+
},
|
|
174
|
+
tooltip: "Keyboard Interaction"
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const internalBadge = {
|
|
178
|
+
tags: "internal",
|
|
179
|
+
badge: {
|
|
180
|
+
text: "๐",
|
|
181
|
+
style: {
|
|
182
|
+
backgroundColor: "transparent",
|
|
183
|
+
borderColor: "transparent"
|
|
184
|
+
},
|
|
185
|
+
tooltip: "Internal"
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const tagBadges = [
|
|
189
|
+
editorBadge,
|
|
190
|
+
unitBadge,
|
|
191
|
+
integrationBadge,
|
|
192
|
+
keyboardBadge,
|
|
193
|
+
newBadge,
|
|
194
|
+
betaBadge,
|
|
195
|
+
deprecatedBadge,
|
|
196
|
+
outdatedBadge,
|
|
197
|
+
dangerBadge,
|
|
198
|
+
propsBadge,
|
|
199
|
+
todoBadge,
|
|
200
|
+
codeOnlyBadge,
|
|
201
|
+
internalBadge,
|
|
202
|
+
snapshotBadge,
|
|
203
|
+
versionBadge
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
export { betaBadge, codeOnlyBadge, dangerBadge, deprecatedBadge, editorBadge, integrationBadge, internalBadge, keyboardBadge, newBadge, outdatedBadge, propsBadge, snapshotBadge, tagBadges, todoBadge, unitBadge };
|