@repobuddy/storybook 0.3.1 → 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/esm/decorators/show_doc_source.d.ts +4 -0
- package/esm/decorators/show_doc_source.js +4 -0
- package/esm/decorators/when_running_in_test.d.ts +5 -0
- package/esm/decorators/when_running_in_test.js +10 -0
- package/esm/decorators/when_running_in_text.ctx.d.ts +4 -0
- package/esm/decorators/when_running_in_text.ctx.js +4 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/manager/tag_badges.d.ts +17 -0
- package/esm/manager/tag_badges.js +17 -0
- package/esm/parameters/define_backgrounds_param.d.ts +6 -0
- package/esm/parameters/define_backgrounds_param.js +6 -0
- package/esm/parameters/define_docs_param.d.ts +27 -0
- package/esm/parameters/define_docs_param.js +27 -0
- package/esm/parameters/define_layout_param.d.ts +1 -3
- package/esm/parameters/define_layout_param.js +1 -3
- package/esm/parameters/define_parameters.d.ts +29 -0
- package/esm/parameters/define_parameters.js +29 -0
- package/esm/parameters/define_viewport_param.d.ts +27 -0
- package/esm/parameters/define_viewport_param.js +27 -0
- package/package.json +9 -1
- package/src/decorators/show_doc_source.tsx +4 -0
- package/src/decorators/when_running_in_test.tsx +16 -0
- package/src/decorators/when_running_in_text.ctx.ts +5 -0
- package/src/index.ts +2 -0
- package/src/manager/tag_badges.ts +17 -0
- package/src/parameters/define_backgrounds_param.ts +6 -0
- package/src/parameters/define_docs_param.ts +27 -0
- package/src/parameters/define_layout_param.ts +1 -3
- package/src/parameters/define_parameters.ts +29 -0
- package/src/parameters/define_viewport_param.ts +27 -0
- package/esm/testing/index.d.ts +0 -1
- package/esm/testing/index.js +0 -1
- package/esm/testing/it.d.ts +0 -6
- package/esm/testing/it.js +0 -19
- package/src/testing/index.ts +0 -1
- package/src/testing/it.ts +0 -30
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { Args, DecoratorFunction, Renderer } from 'storybook/internal/csf';
|
|
2
|
+
/**
|
|
3
|
+
* A decorator that shows the source code of a story above the rendered story.
|
|
4
|
+
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
5
|
+
*/
|
|
2
6
|
export declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(): DecoratorFunction<TRenderer, TArgs>;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A decorator that shows the source code of a story above the rendered story.
|
|
4
|
+
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
5
|
+
*/
|
|
2
6
|
export function showDocSource() {
|
|
3
7
|
return (Story, { parameters }) => {
|
|
4
8
|
return (_jsxs("section", { style: {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Decorator, StrictArgs } from '@storybook/react';
|
|
2
|
+
/**
|
|
3
|
+
* executes the specified decorator or handler if the code is running in test.
|
|
4
|
+
*/
|
|
5
|
+
export declare function whenRunningInTest<TArgs = StrictArgs>(decoratorOrHandler: ((...args: Parameters<Decorator<TArgs>>) => ReturnType<Decorator<TArgs>> | undefined | void) | (() => ReturnType<Decorator<TArgs>> | undefined | void)): Decorator<TArgs>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ctx } from "./when_running_in_text.ctx.js";
|
|
3
|
+
/**
|
|
4
|
+
* executes the specified decorator or handler if the code is running in test.
|
|
5
|
+
*/
|
|
6
|
+
export function whenRunningInTest(decoratorOrHandler) {
|
|
7
|
+
return function RunInTest(Story, context) {
|
|
8
|
+
return ctx.isRunningInTest() ? (decoratorOrHandler(Story, context) ?? _jsx(Story, {})) : _jsx(Story, {});
|
|
9
|
+
};
|
|
10
|
+
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from '@repobuddy/test';
|
|
1
2
|
export * from './decorators/show_doc_source.tsx';
|
|
3
|
+
export * from './decorators/when_running_in_test.tsx';
|
|
2
4
|
export * from './parameters/define_actions_param.ts';
|
|
3
5
|
export * from './parameters/define_backgrounds_param.ts';
|
|
4
6
|
export * from './parameters/define_docs_param.ts';
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from '@repobuddy/test';
|
|
1
2
|
export * from "./decorators/show_doc_source.js";
|
|
3
|
+
export * from "./decorators/when_running_in_test.js";
|
|
2
4
|
export * from "./parameters/define_actions_param.js";
|
|
3
5
|
export * from "./parameters/define_backgrounds_param.js";
|
|
4
6
|
export * from "./parameters/define_docs_param.js";
|
|
@@ -1,2 +1,19 @@
|
|
|
1
1
|
import { type TagBadgeParameters } from 'storybook-addon-tag-badges';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for story tag badges that appear in the Storybook sidebar.
|
|
4
|
+
* Each badge is associated with a specific tag and displays an emoji with a tooltip.
|
|
5
|
+
*
|
|
6
|
+
* The badges help visually identify stories with certain characteristics:
|
|
7
|
+
* - 🆕 New - Recently added stories
|
|
8
|
+
* - 🅱️ Beta - Stories for features in beta
|
|
9
|
+
* - 🪦 Deprecated - Stories for deprecated features
|
|
10
|
+
* - ⚠️ Outdated - Stories that need updating
|
|
11
|
+
* - 🚨 Danger - Stories demonstrating dangerous patterns
|
|
12
|
+
* - 📋 Todo - Stories marked as todo/incomplete
|
|
13
|
+
* - 📝 Code Only - Stories without visual examples
|
|
14
|
+
* - 🧪 Unit - Stories with unit tests
|
|
15
|
+
* - 🔄 Integration - Stories with integration tests
|
|
16
|
+
*
|
|
17
|
+
* Also includes the default version badge from `storybook-addon-tag-badges`.
|
|
18
|
+
*/
|
|
2
19
|
export declare const tagBadges: TagBadgeParameters;
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { defaultConfig } from 'storybook-addon-tag-badges';
|
|
2
2
|
const [, , , , , , versionBadge] = defaultConfig;
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for story tag badges that appear in the Storybook sidebar.
|
|
5
|
+
* Each badge is associated with a specific tag and displays an emoji with a tooltip.
|
|
6
|
+
*
|
|
7
|
+
* The badges help visually identify stories with certain characteristics:
|
|
8
|
+
* - 🆕 New - Recently added stories
|
|
9
|
+
* - 🅱️ Beta - Stories for features in beta
|
|
10
|
+
* - 🪦 Deprecated - Stories for deprecated features
|
|
11
|
+
* - ⚠️ Outdated - Stories that need updating
|
|
12
|
+
* - 🚨 Danger - Stories demonstrating dangerous patterns
|
|
13
|
+
* - 📋 Todo - Stories marked as todo/incomplete
|
|
14
|
+
* - 📝 Code Only - Stories without visual examples
|
|
15
|
+
* - 🧪 Unit - Stories with unit tests
|
|
16
|
+
* - 🔄 Integration - Stories with integration tests
|
|
17
|
+
*
|
|
18
|
+
* Also includes the default version badge from `storybook-addon-tag-badges`.
|
|
19
|
+
*/
|
|
3
20
|
export const tagBadges = [
|
|
4
21
|
{
|
|
5
22
|
tags: 'new',
|
|
@@ -36,4 +36,10 @@ export interface GlobalApiBackgroundsParam {
|
|
|
36
36
|
[k: string]: unknown;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Defines backgrounds parameters for Storybook stories.
|
|
41
|
+
*
|
|
42
|
+
* @param backgrounds - The backgrounds configuration
|
|
43
|
+
* @returns An object containing the backgrounds parameter configuration
|
|
44
|
+
*/
|
|
39
45
|
export declare const defineBackgroundsParam: (backgrounds: BackgroundsParam["backgrounds"] | GlobalApiBackgroundsParam["backgrounds"]) => BackgroundsParam;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines backgrounds parameters for Storybook stories.
|
|
3
|
+
*
|
|
4
|
+
* @param backgrounds - The backgrounds configuration
|
|
5
|
+
* @returns An object containing the backgrounds parameter configuration
|
|
6
|
+
*/
|
|
1
7
|
export const defineBackgroundsParam = (backgrounds) => ({
|
|
2
8
|
backgrounds
|
|
3
9
|
});
|
|
@@ -178,4 +178,31 @@ export interface DocsParam {
|
|
|
178
178
|
[k: string]: unknown;
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Defines docs parameters for Storybook stories.
|
|
183
|
+
*
|
|
184
|
+
* @param docs - Configuration for docs parameters including options for:
|
|
185
|
+
* - Controls display and sorting
|
|
186
|
+
* - Story rendering (autoplay, height, inline vs iframe)
|
|
187
|
+
* - And other docs-related settings
|
|
188
|
+
* @returns An object containing the docs parameter configuration
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
193
|
+
*
|
|
194
|
+
* export default {
|
|
195
|
+
* parameters: defineDocsParam({
|
|
196
|
+
* controls: {
|
|
197
|
+
* sort: 'alpha',
|
|
198
|
+
* exclude: ['internal*']
|
|
199
|
+
* },
|
|
200
|
+
* story: {
|
|
201
|
+
* inline: true,
|
|
202
|
+
* height: '400px'
|
|
203
|
+
* }
|
|
204
|
+
* })
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
181
208
|
export declare function defineDocsParam(docs: DocsParam['docs']): DocsParam['docs'];
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines docs parameters for Storybook stories.
|
|
3
|
+
*
|
|
4
|
+
* @param docs - Configuration for docs parameters including options for:
|
|
5
|
+
* - Controls display and sorting
|
|
6
|
+
* - Story rendering (autoplay, height, inline vs iframe)
|
|
7
|
+
* - And other docs-related settings
|
|
8
|
+
* @returns An object containing the docs parameter configuration
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
13
|
+
*
|
|
14
|
+
* export default {
|
|
15
|
+
* parameters: defineDocsParam({
|
|
16
|
+
* controls: {
|
|
17
|
+
* sort: 'alpha',
|
|
18
|
+
* exclude: ['internal*']
|
|
19
|
+
* },
|
|
20
|
+
* story: {
|
|
21
|
+
* inline: true,
|
|
22
|
+
* height: '400px'
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
1
28
|
export function defineDocsParam(docs) {
|
|
2
29
|
return { docs };
|
|
3
30
|
}
|
|
@@ -5,4 +5,33 @@ import type { StorySortParam } from './define_story_sort.ts';
|
|
|
5
5
|
import type { TestParam } from './define_test_param.ts';
|
|
6
6
|
import type { ViewportParam } from './define_viewport_param.ts';
|
|
7
7
|
export type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgroundsParam> & Partial<DocsParam> & Partial<LayoutParam> & Partial<StorySortParam> & Partial<TestParam> & Partial<ViewportParam>;
|
|
8
|
+
/**
|
|
9
|
+
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
|
|
10
|
+
*
|
|
11
|
+
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
|
|
12
|
+
* @returns The combined parameters object
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { defineParameters } from '@repobuddy/storybook'
|
|
17
|
+
*
|
|
18
|
+
* export default {
|
|
19
|
+
* parameters: defineParameters({
|
|
20
|
+
* // Built-in parameters
|
|
21
|
+
* layout: 'centered',
|
|
22
|
+
* backgrounds: {
|
|
23
|
+
* default: 'light',
|
|
24
|
+
* values: [
|
|
25
|
+
* { name: 'light', value: '#ffffff' },
|
|
26
|
+
* { name: 'dark', value: '#333333' }
|
|
27
|
+
* ]
|
|
28
|
+
* },
|
|
29
|
+
* // Custom parameters
|
|
30
|
+
* myCustomParam: {
|
|
31
|
+
* someValue: true
|
|
32
|
+
* }
|
|
33
|
+
* })
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
8
37
|
export declare function defineParameters<P extends Record<string, any>>(parameters: P & StorybookBuiltInParams): P & StorybookBuiltInParams;
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
|
|
3
|
+
*
|
|
4
|
+
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
|
|
5
|
+
* @returns The combined parameters object
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { defineParameters } from '@repobuddy/storybook'
|
|
10
|
+
*
|
|
11
|
+
* export default {
|
|
12
|
+
* parameters: defineParameters({
|
|
13
|
+
* // Built-in parameters
|
|
14
|
+
* layout: 'centered',
|
|
15
|
+
* backgrounds: {
|
|
16
|
+
* default: 'light',
|
|
17
|
+
* values: [
|
|
18
|
+
* { name: 'light', value: '#ffffff' },
|
|
19
|
+
* { name: 'dark', value: '#333333' }
|
|
20
|
+
* ]
|
|
21
|
+
* },
|
|
22
|
+
* // Custom parameters
|
|
23
|
+
* myCustomParam: {
|
|
24
|
+
* someValue: true
|
|
25
|
+
* }
|
|
26
|
+
* })
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
1
30
|
export function defineParameters(parameters) {
|
|
2
31
|
return parameters;
|
|
3
32
|
}
|
|
@@ -48,4 +48,31 @@ export interface GlobalApiViewportParam {
|
|
|
48
48
|
disabled?: boolean | undefined;
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Defines viewport parameters for Storybook stories.
|
|
53
|
+
*
|
|
54
|
+
* @see https://storybook.js.org/docs/api/parameters#viewport
|
|
55
|
+
*
|
|
56
|
+
* @param viewport - Configuration for viewport parameters including:
|
|
57
|
+
* - viewports: Custom viewport definitions
|
|
58
|
+
* - defaultViewport: The default viewport to use
|
|
59
|
+
* - defaultOrientation: Default orientation (landscape/portrait)
|
|
60
|
+
* - disabled: Whether viewport controls are disabled
|
|
61
|
+
* @returns An object containing the viewport parameter configuration
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* defineViewportParam({
|
|
66
|
+
* viewports: {
|
|
67
|
+
* mobile: {
|
|
68
|
+
* name: 'Mobile',
|
|
69
|
+
* styles: { width: '320px', height: '568px' },
|
|
70
|
+
* type: 'mobile'
|
|
71
|
+
* }
|
|
72
|
+
* },
|
|
73
|
+
* defaultViewport: 'mobile',
|
|
74
|
+
* defaultOrientation: 'portrait'
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
51
78
|
export declare function defineViewportParam(viewport: ViewportParam['viewport'] | GlobalApiViewportParam['viewport']): ViewportParam;
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines viewport parameters for Storybook stories.
|
|
3
|
+
*
|
|
4
|
+
* @see https://storybook.js.org/docs/api/parameters#viewport
|
|
5
|
+
*
|
|
6
|
+
* @param viewport - Configuration for viewport parameters including:
|
|
7
|
+
* - viewports: Custom viewport definitions
|
|
8
|
+
* - defaultViewport: The default viewport to use
|
|
9
|
+
* - defaultOrientation: Default orientation (landscape/portrait)
|
|
10
|
+
* - disabled: Whether viewport controls are disabled
|
|
11
|
+
* @returns An object containing the viewport parameter configuration
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* defineViewportParam({
|
|
16
|
+
* viewports: {
|
|
17
|
+
* mobile: {
|
|
18
|
+
* name: 'Mobile',
|
|
19
|
+
* styles: { width: '320px', height: '568px' },
|
|
20
|
+
* type: 'mobile'
|
|
21
|
+
* }
|
|
22
|
+
* },
|
|
23
|
+
* defaultViewport: 'mobile',
|
|
24
|
+
* defaultOrientation: 'portrait'
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
1
28
|
export function defineViewportParam(viewport) {
|
|
2
29
|
return { viewport };
|
|
3
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
"./manager": {
|
|
23
23
|
"types": "./esm/manager.d.ts",
|
|
24
24
|
"default": "./esm/manager.js"
|
|
25
|
+
},
|
|
26
|
+
"./testing": {
|
|
27
|
+
"types": "./esm/testing.d.ts",
|
|
28
|
+
"default": "./esm/testing.js"
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
31
|
"files": [
|
|
@@ -29,7 +33,11 @@
|
|
|
29
33
|
"src",
|
|
30
34
|
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress,study,stories}.*"
|
|
31
35
|
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@repobuddy/test": "^1.0.0"
|
|
38
|
+
},
|
|
32
39
|
"devDependencies": {
|
|
40
|
+
"@repobuddy/vitest": "^1.2.1",
|
|
33
41
|
"@storybook/addon-essentials": "^8.6.12",
|
|
34
42
|
"@storybook/addon-storysource": "^8.6.12",
|
|
35
43
|
"@storybook/blocks": "^8.6.12",
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Args, DecoratorFunction, Renderer } from 'storybook/internal/csf'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A decorator that shows the source code of a story above the rendered story.
|
|
5
|
+
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
6
|
+
*/
|
|
3
7
|
export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(): DecoratorFunction<
|
|
4
8
|
TRenderer,
|
|
5
9
|
TArgs
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Decorator, StrictArgs } from '@storybook/react'
|
|
2
|
+
import { ctx } from './when_running_in_text.ctx.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* executes the specified decorator or handler if the code is running in test.
|
|
6
|
+
*/
|
|
7
|
+
export function whenRunningInTest<TArgs = StrictArgs>(
|
|
8
|
+
decoratorOrHandler: // biome-ignore lint/suspicious/noConfusingVoidType: on purpose
|
|
9
|
+
| ((...args: Parameters<Decorator<TArgs>>) => ReturnType<Decorator<TArgs>> | undefined | void)
|
|
10
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: on purpose
|
|
11
|
+
| (() => ReturnType<Decorator<TArgs>> | undefined | void)
|
|
12
|
+
): Decorator<TArgs> {
|
|
13
|
+
return function RunInTest(Story, context) {
|
|
14
|
+
return ctx.isRunningInTest() ? (decoratorOrHandler(Story, context) ?? <Story />) : <Story />
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from '@repobuddy/test'
|
|
1
2
|
export * from './decorators/show_doc_source.tsx'
|
|
3
|
+
export * from './decorators/when_running_in_test.tsx'
|
|
2
4
|
export * from './parameters/define_actions_param.ts'
|
|
3
5
|
export * from './parameters/define_backgrounds_param.ts'
|
|
4
6
|
export * from './parameters/define_docs_param.ts'
|
|
@@ -2,6 +2,23 @@ import { type TagBadgeParameters, defaultConfig } from 'storybook-addon-tag-badg
|
|
|
2
2
|
|
|
3
3
|
const [, , , , , , versionBadge] = defaultConfig
|
|
4
4
|
|
|
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
|
+
* - 🆕 New - Recently added stories
|
|
11
|
+
* - 🅱️ Beta - Stories for features in beta
|
|
12
|
+
* - 🪦 Deprecated - Stories for deprecated features
|
|
13
|
+
* - ⚠️ Outdated - Stories that need updating
|
|
14
|
+
* - 🚨 Danger - Stories demonstrating dangerous patterns
|
|
15
|
+
* - 📋 Todo - Stories marked as todo/incomplete
|
|
16
|
+
* - 📝 Code Only - Stories without visual examples
|
|
17
|
+
* - 🧪 Unit - Stories with unit tests
|
|
18
|
+
* - 🔄 Integration - Stories with integration tests
|
|
19
|
+
*
|
|
20
|
+
* Also includes the default version badge from `storybook-addon-tag-badges`.
|
|
21
|
+
*/
|
|
5
22
|
export const tagBadges: TagBadgeParameters = [
|
|
6
23
|
{
|
|
7
24
|
tags: 'new',
|
|
@@ -41,6 +41,12 @@ export interface GlobalApiBackgroundsParam {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Defines backgrounds parameters for Storybook stories.
|
|
46
|
+
*
|
|
47
|
+
* @param backgrounds - The backgrounds configuration
|
|
48
|
+
* @returns An object containing the backgrounds parameter configuration
|
|
49
|
+
*/
|
|
44
50
|
export const defineBackgroundsParam = (
|
|
45
51
|
backgrounds: BackgroundsParam['backgrounds'] | GlobalApiBackgroundsParam['backgrounds']
|
|
46
52
|
): BackgroundsParam => ({
|
|
@@ -201,6 +201,33 @@ export interface DocsParam {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Defines docs parameters for Storybook stories.
|
|
206
|
+
*
|
|
207
|
+
* @param docs - Configuration for docs parameters including options for:
|
|
208
|
+
* - Controls display and sorting
|
|
209
|
+
* - Story rendering (autoplay, height, inline vs iframe)
|
|
210
|
+
* - And other docs-related settings
|
|
211
|
+
* @returns An object containing the docs parameter configuration
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
216
|
+
*
|
|
217
|
+
* export default {
|
|
218
|
+
* parameters: defineDocsParam({
|
|
219
|
+
* controls: {
|
|
220
|
+
* sort: 'alpha',
|
|
221
|
+
* exclude: ['internal*']
|
|
222
|
+
* },
|
|
223
|
+
* story: {
|
|
224
|
+
* inline: true,
|
|
225
|
+
* height: '400px'
|
|
226
|
+
* }
|
|
227
|
+
* })
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
204
231
|
export function defineDocsParam(docs: DocsParam['docs']): DocsParam['docs'] {
|
|
205
232
|
return { docs }
|
|
206
233
|
}
|
|
@@ -12,6 +12,35 @@ export type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgro
|
|
|
12
12
|
Partial<TestParam> &
|
|
13
13
|
Partial<ViewportParam>
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
|
|
17
|
+
*
|
|
18
|
+
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
|
|
19
|
+
* @returns The combined parameters object
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { defineParameters } from '@repobuddy/storybook'
|
|
24
|
+
*
|
|
25
|
+
* export default {
|
|
26
|
+
* parameters: defineParameters({
|
|
27
|
+
* // Built-in parameters
|
|
28
|
+
* layout: 'centered',
|
|
29
|
+
* backgrounds: {
|
|
30
|
+
* default: 'light',
|
|
31
|
+
* values: [
|
|
32
|
+
* { name: 'light', value: '#ffffff' },
|
|
33
|
+
* { name: 'dark', value: '#333333' }
|
|
34
|
+
* ]
|
|
35
|
+
* },
|
|
36
|
+
* // Custom parameters
|
|
37
|
+
* myCustomParam: {
|
|
38
|
+
* someValue: true
|
|
39
|
+
* }
|
|
40
|
+
* })
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
15
44
|
export function defineParameters<P extends Record<string, any>>(parameters: P & StorybookBuiltInParams) {
|
|
16
45
|
return parameters
|
|
17
46
|
}
|
|
@@ -51,6 +51,33 @@ export interface GlobalApiViewportParam {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Defines viewport parameters for Storybook stories.
|
|
56
|
+
*
|
|
57
|
+
* @see https://storybook.js.org/docs/api/parameters#viewport
|
|
58
|
+
*
|
|
59
|
+
* @param viewport - Configuration for viewport parameters including:
|
|
60
|
+
* - viewports: Custom viewport definitions
|
|
61
|
+
* - defaultViewport: The default viewport to use
|
|
62
|
+
* - defaultOrientation: Default orientation (landscape/portrait)
|
|
63
|
+
* - disabled: Whether viewport controls are disabled
|
|
64
|
+
* @returns An object containing the viewport parameter configuration
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* defineViewportParam({
|
|
69
|
+
* viewports: {
|
|
70
|
+
* mobile: {
|
|
71
|
+
* name: 'Mobile',
|
|
72
|
+
* styles: { width: '320px', height: '568px' },
|
|
73
|
+
* type: 'mobile'
|
|
74
|
+
* }
|
|
75
|
+
* },
|
|
76
|
+
* defaultViewport: 'mobile',
|
|
77
|
+
* defaultOrientation: 'portrait'
|
|
78
|
+
* })
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
54
81
|
export function defineViewportParam(
|
|
55
82
|
viewport: ViewportParam['viewport'] | GlobalApiViewportParam['viewport']
|
|
56
83
|
): ViewportParam {
|
package/esm/testing/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './it.ts';
|
package/esm/testing/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./it.js";
|
package/esm/testing/it.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Args, Renderer, StoryAnnotations } from 'storybook/internal/csf';
|
|
2
|
-
export type ItObj<TRenderer extends Renderer, TArgs extends Args> = StoryAnnotations<TRenderer, TArgs>;
|
|
3
|
-
export declare function it<TRenderer extends Renderer, TArgs extends Args>(description: string, story: StoryAnnotations<TRenderer, TArgs>): StoryAnnotations<TRenderer, TArgs>;
|
|
4
|
-
export declare namespace it {
|
|
5
|
-
var skip: <TRenderer extends Renderer, TArgs extends Args>(description: string, story: StoryAnnotations<TRenderer, TArgs>) => StoryAnnotations<TRenderer, TArgs>;
|
|
6
|
-
}
|
package/esm/testing/it.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function it(description, story) {
|
|
2
|
-
const { play, ...rest } = story;
|
|
3
|
-
return {
|
|
4
|
-
...rest,
|
|
5
|
-
async play(context) {
|
|
6
|
-
await context.step(description, async () => {
|
|
7
|
-
await play?.(context);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
// does not work
|
|
13
|
-
it.skip = (description, story) => {
|
|
14
|
-
const { tags = [], ...rest } = story;
|
|
15
|
-
return it(description, {
|
|
16
|
-
tags: [...tags, '!test'],
|
|
17
|
-
...rest
|
|
18
|
-
});
|
|
19
|
-
};
|
package/src/testing/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './it.ts'
|
package/src/testing/it.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Args, Renderer, StoryAnnotations } from 'storybook/internal/csf'
|
|
2
|
-
|
|
3
|
-
export type ItObj<TRenderer extends Renderer, TArgs extends Args> = StoryAnnotations<TRenderer, TArgs>
|
|
4
|
-
|
|
5
|
-
export function it<TRenderer extends Renderer, TArgs extends Args>(
|
|
6
|
-
description: string,
|
|
7
|
-
story: StoryAnnotations<TRenderer, TArgs>
|
|
8
|
-
): StoryAnnotations<TRenderer, TArgs> {
|
|
9
|
-
const { play, ...rest } = story
|
|
10
|
-
return {
|
|
11
|
-
...rest,
|
|
12
|
-
async play(context) {
|
|
13
|
-
await context.step(description, async () => {
|
|
14
|
-
await play?.(context)
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// does not work
|
|
21
|
-
it.skip = <TRenderer extends Renderer, TArgs extends Args>(
|
|
22
|
-
description: string,
|
|
23
|
-
story: StoryAnnotations<TRenderer, TArgs>
|
|
24
|
-
) => {
|
|
25
|
-
const { tags = [], ...rest } = story
|
|
26
|
-
return it(description, {
|
|
27
|
-
tags: [...tags, '!test'],
|
|
28
|
-
...rest
|
|
29
|
-
})
|
|
30
|
-
}
|