@repobuddy/storybook 0.9.4 → 0.11.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.
Files changed (48) hide show
  1. package/esm/index.d.ts +3 -1
  2. package/esm/index.js +3 -1
  3. package/esm/manager/index.d.ts +0 -1
  4. package/esm/manager/index.js +0 -1
  5. package/esm/parameters/define_parameters.d.ts +4 -2
  6. package/esm/parameters/story_sort.d.ts +27 -0
  7. package/esm/parameters/story_sort.js +1 -0
  8. package/esm/storybook-addon-tag-badges/index.d.ts +1 -0
  9. package/esm/storybook-addon-tag-badges/index.js +1 -0
  10. package/esm/storybook-addon-tag-badges/tag_badges.d.ts +35 -0
  11. package/esm/{manager → storybook-addon-tag-badges}/tag_badges.js +17 -1
  12. package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +26 -0
  13. package/esm/storybook-dark-mode/dark_mode_docs_container.js +32 -0
  14. package/esm/storybook-dark-mode/define_dark_mode.d.ts +49 -0
  15. package/esm/storybook-dark-mode/define_dark_mode.js +19 -0
  16. package/esm/storybook-dark-mode/index.d.ts +3 -0
  17. package/esm/storybook-dark-mode/index.js +3 -0
  18. package/esm/storybook-dark-mode/with_dark_mode.d.ts +22 -0
  19. package/esm/storybook-dark-mode/with_dark_mode.js +71 -0
  20. package/package.json +29 -4
  21. package/readme.md +49 -10
  22. package/src/index.ts +3 -1
  23. package/src/manager/index.ts +0 -1
  24. package/src/parameters/define_parameters.ts +2 -3
  25. package/src/parameters/story_sort.ts +29 -0
  26. package/src/storybook-addon-tag-badges/index.ts +1 -0
  27. package/src/{manager → storybook-addon-tag-badges}/tag_badges.ts +31 -12
  28. package/src/storybook-dark-mode/dark_mode_docs_container.mdx +33 -0
  29. package/src/storybook-dark-mode/dark_mode_docs_container.tsx +48 -0
  30. package/src/storybook-dark-mode/define_dark_mode.ts +51 -0
  31. package/src/storybook-dark-mode/index.ts +3 -0
  32. package/src/storybook-dark-mode/with_dark_mode.tsx +90 -0
  33. package/esm/manager/tag_badges.d.ts +0 -128
  34. package/esm/parameters/define_story_sort.d.ts +0 -55
  35. package/esm/parameters/define_story_sort.js +0 -28
  36. package/esm/react/index.d.ts +0 -2
  37. package/esm/react/index.js +0 -2
  38. package/src/parameters/define_story_sort.ts +0 -58
  39. package/src/react/index.ts +0 -2
  40. /package/esm/{react/decorators → decorators}/show_doc_source.d.ts +0 -0
  41. /package/esm/{react/decorators → decorators}/show_doc_source.js +0 -0
  42. /package/esm/{react/decorators → decorators}/when_running_in_test.d.ts +0 -0
  43. /package/esm/{react/decorators → decorators}/when_running_in_test.js +0 -0
  44. /package/esm/{react/decorators → decorators}/when_running_in_text.ctx.d.ts +0 -0
  45. /package/esm/{react/decorators → decorators}/when_running_in_text.ctx.js +0 -0
  46. /package/src/{react/decorators → decorators}/show_doc_source.tsx +0 -0
  47. /package/src/{react/decorators → decorators}/when_running_in_test.tsx +0 -0
  48. /package/src/{react/decorators → decorators}/when_running_in_text.ctx.ts +0 -0
@@ -2,6 +2,8 @@ import { type TagBadgeParameters, defaultConfig } from 'storybook-addon-tag-badg
2
2
 
3
3
  const [, , , , , , versionBadge] = defaultConfig
4
4
 
5
+ type TagBadgeParameter = TagBadgeParameters[0]
6
+
5
7
  /**
6
8
  * Configuration for story tag badges that appear in the Storybook sidebar.
7
9
  * Each badge is associated with a specific tag and displays an emoji with a tooltip.
@@ -21,7 +23,7 @@ const [, , , , , , versionBadge] = defaultConfig
21
23
  *
22
24
  * Also includes the default version badge from `storybook-addon-tag-badges`.
23
25
  */
24
- export const editorBadge = {
26
+ export const editorBadge: TagBadgeParameter = {
25
27
  tags: 'editor',
26
28
  badge: {
27
29
  text: '✏️',
@@ -35,7 +37,7 @@ export const editorBadge = {
35
37
  }
36
38
  }
37
39
 
38
- export const newBadge = {
40
+ export const newBadge: TagBadgeParameter = {
39
41
  tags: 'new',
40
42
  badge: {
41
43
  text: '🆕',
@@ -45,7 +47,7 @@ export const newBadge = {
45
47
  }
46
48
  }
47
49
 
48
- export const betaBadge = {
50
+ export const betaBadge: TagBadgeParameter = {
49
51
  tags: 'beta',
50
52
  badge: {
51
53
  text: '🅱️',
@@ -55,7 +57,17 @@ export const betaBadge = {
55
57
  }
56
58
  }
57
59
 
58
- export const deprecatedBadge = {
60
+ export const propsBadge: TagBadgeParameter = {
61
+ tags: 'props',
62
+ badge: {
63
+ text: '🔧',
64
+ bgColor: 'transparent',
65
+ borderColor: 'transparent',
66
+ tooltip: 'Props'
67
+ }
68
+ }
69
+
70
+ export const deprecatedBadge: TagBadgeParameter = {
59
71
  tags: 'deprecated',
60
72
  badge: {
61
73
  text: '🪦',
@@ -65,7 +77,7 @@ export const deprecatedBadge = {
65
77
  }
66
78
  }
67
79
 
68
- export const outdatedBadge = {
80
+ export const outdatedBadge: TagBadgeParameter = {
69
81
  tags: 'outdated',
70
82
  badge: {
71
83
  text: '⚠️',
@@ -75,7 +87,7 @@ export const outdatedBadge = {
75
87
  }
76
88
  }
77
89
 
78
- export const dangerBadge = {
90
+ export const dangerBadge: TagBadgeParameter = {
79
91
  tags: 'danger',
80
92
  badge: {
81
93
  text: '🚨',
@@ -85,7 +97,7 @@ export const dangerBadge = {
85
97
  }
86
98
  }
87
99
 
88
- export const todoBadge = {
100
+ export const todoBadge: TagBadgeParameter = {
89
101
  tags: 'todo',
90
102
  badge: {
91
103
  text: '📋',
@@ -95,7 +107,7 @@ export const todoBadge = {
95
107
  }
96
108
  }
97
109
 
98
- export const codeOnlyBadge = {
110
+ export const codeOnlyBadge: TagBadgeParameter = {
99
111
  tags: 'code-only',
100
112
  badge: {
101
113
  text: '📝',
@@ -105,7 +117,7 @@ export const codeOnlyBadge = {
105
117
  }
106
118
  }
107
119
 
108
- export const snapshotBadge = {
120
+ export const snapshotBadge: TagBadgeParameter = {
109
121
  tags: 'snapshot',
110
122
  badge: {
111
123
  text: '📸',
@@ -114,28 +126,34 @@ export const snapshotBadge = {
114
126
  tooltip: 'Snapshot Test'
115
127
  },
116
128
  display: {
117
- sidebar: ['story'],
129
+ sidebar: false,
118
130
  toolbar: ['story']
119
131
  }
120
132
  }
121
133
 
122
- export const unitBadge = {
134
+ export const unitBadge: TagBadgeParameter = {
123
135
  tags: 'unit',
124
136
  badge: {
125
137
  text: '🧪',
126
138
  bgColor: 'transparent',
127
139
  borderColor: 'transparent',
128
140
  tooltip: 'Unit Test'
141
+ },
142
+ display: {
143
+ sidebar: false
129
144
  }
130
145
  }
131
146
 
132
- export const integrationBadge = {
147
+ export const integrationBadge: TagBadgeParameter = {
133
148
  tags: 'integration',
134
149
  badge: {
135
150
  text: '🔗',
136
151
  bgColor: 'transparent',
137
152
  borderColor: 'transparent',
138
153
  tooltip: 'Integration Test'
154
+ },
155
+ display: {
156
+ sidebar: false
139
157
  }
140
158
  }
141
159
 
@@ -148,6 +166,7 @@ export const tagBadges: TagBadgeParameters = [
148
166
  deprecatedBadge,
149
167
  outdatedBadge,
150
168
  dangerBadge,
169
+ propsBadge,
151
170
  todoBadge,
152
171
  codeOnlyBadge,
153
172
  snapshotBadge,
@@ -0,0 +1,33 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ # `createDarkModeDocsContainer`
4
+
5
+ <Meta title="storybook-dark-mode/createDarkModeDocsContainer" />
6
+
7
+ Creates a `DocsContainer` for `storybook` that works with `storybook-dark-mode`.
8
+
9
+ ## Usage
10
+
11
+ It can be called with no arguments to use the default themes from `@storybook/theming`.
12
+
13
+ ```tsx
14
+ // .storybook/preview.tsx
15
+ import { createDarkModeDocsContainer } from '@repobuddy/storybook/react'
16
+
17
+ export const preview: Preview = {
18
+ parameters: {
19
+ docs: {
20
+ container: createDarkModeDocsContainer()
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ It can also be called with a custom themes.
27
+
28
+ ```tsx
29
+ container: createDarkModeDocsContainer({
30
+ light: customThemes.light,
31
+ dark: customThemes.dark
32
+ })
33
+ ```
@@ -0,0 +1,48 @@
1
+ import { DocsContainer, type DocsContextProps } from '@storybook/blocks'
2
+ import { type ThemeVars, themes } from '@storybook/theming'
3
+ import { type PropsWithChildren, useEffect, useState } from 'react'
4
+ import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode'
5
+
6
+ /**
7
+ * Creates a `DocsContainer` for `storybook` that works with `storybook-dark-mode`.
8
+ *
9
+ * @see https://github.com/hipstersmoothie/storybook-dark-mode/issues/282
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // .storybook/preview.tsx
14
+ * const preview: Preview = {
15
+ * parameters: {
16
+ * docs: {
17
+ * container: createDarkModeDocsContainer()
18
+ * }
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export function createDarkModeDocsContainer(
24
+ customThemes?:
25
+ | {
26
+ light?: ThemeVars | undefined
27
+ dark?: ThemeVars | undefined
28
+ }
29
+ | undefined
30
+ ) {
31
+ return function DarkModeDocsContainer(props: PropsWithChildren<{ context: DocsContextProps }>) {
32
+ const [isDark, setDark] = useState(true)
33
+
34
+ useEffect(() => {
35
+ props.context.channel.on(DARK_MODE_EVENT_NAME, setDark)
36
+
37
+ return () => props.context.channel.removeListener(DARK_MODE_EVENT_NAME, setDark)
38
+ }, [props.context.channel])
39
+ return (
40
+ <DocsContainer
41
+ {...props}
42
+ theme={isDark ? (customThemes?.dark ?? themes.dark) : (customThemes?.light ?? themes.light)}
43
+ >
44
+ {props.children}
45
+ </DocsContainer>
46
+ )
47
+ }
48
+ }
@@ -0,0 +1,51 @@
1
+ import type { CSSProperties } from '@just-web/css'
2
+
3
+ /**
4
+ * Configuration parameters for `storybook-dark-mode`.
5
+ */
6
+ export interface DarkModeParam {
7
+ /** The current theme ('dark' or 'light') */
8
+ current?: 'dark' | 'light' | undefined
9
+ /**
10
+ * CSS class(es) to apply in dark mode.
11
+ */
12
+ darkClass?: string | string[] | undefined
13
+ /**
14
+ * CSS style(s) to apply in dark mode.
15
+ *
16
+ * This only works when using `withStoryRoot`.
17
+ */
18
+ darkStyle?: CSSProperties | undefined
19
+ /** CSS class(es) to apply in light mode */
20
+ lightClass?: string | string[] | undefined
21
+ /**
22
+ * CSS style(s) to apply in light mode.
23
+ *
24
+ * This only works when using `withStoryRoot`.
25
+ */
26
+ lightStyle?: CSSProperties | undefined
27
+ /** Element to apply theme classes to ('html' or 'body') */
28
+ classTarget?: 'html' | 'body' | undefined
29
+ /** Whether to apply theme styles to preview iframe */
30
+ stylePreview?: boolean | undefined
31
+ }
32
+
33
+ /**
34
+ * Defines `storybook-dark-mode` parameters for Storybook stories.
35
+ *
36
+ * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
37
+ * @returns An object containing the dark mode parameter configuration
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * // ./storybook/preview.tsx
42
+ *
43
+ * export const preview = {
44
+ * parameters: {
45
+ * ...defineDarkModeParam({ darkClass: 'dark' })
46
+ * }
47
+ * }
48
+ */
49
+ export function defineDarkModeParam(darkMode: DarkModeParam) {
50
+ return { darkMode }
51
+ }
@@ -0,0 +1,3 @@
1
+ export * from './dark_mode_docs_container.tsx'
2
+ export * from './define_dark_mode.ts'
3
+ export * from './with_dark_mode.tsx'
@@ -0,0 +1,90 @@
1
+ import type { CSSProperties } from '@just-web/css'
2
+ import { toDOMStyle } from '@just-web/css'
3
+ import { useDarkMode } from 'storybook-dark-mode'
4
+ import type { DecoratorFunction } from 'storybook/internal/types'
5
+ import type { DarkModeParam } from './define_dark_mode.ts'
6
+
7
+ /**
8
+ * Applies additional dark mode behavior.
9
+ *
10
+ * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
11
+ * @returns A decorator function that applies additional dark mode behavior.
12
+ */
13
+ export function withDarkMode(
14
+ options?:
15
+ | {
16
+ /**
17
+ * CSS class(es) to apply to the body element.
18
+ *
19
+ * Useful when using Tailwind CSS and `classTarget: 'html'`
20
+ */
21
+ bodyClass?: string | string[] | undefined
22
+ /**
23
+ * CSS style(s) to apply to the body element.
24
+ *
25
+ * Useful when using Tailwind CSS and `classTarget: 'html'`
26
+ */
27
+ bodyStyle?: CSSProperties | undefined
28
+ }
29
+ | undefined
30
+ ): DecoratorFunction<any, any> {
31
+ return function darkModeDecorator(Story, { parameters }) {
32
+ const darkMode = parameters.darkMode as DarkModeParam | undefined
33
+ if (!darkMode) return <Story />
34
+
35
+ const dark = useDarkMode()
36
+ const target = darkMode.classTarget === 'html' ? document.documentElement : document.body
37
+ if (dark) {
38
+ removeClass(target, darkMode.lightClass)
39
+ addClass(target, darkMode.darkClass)
40
+ removeStyle(target, darkMode.lightStyle)
41
+ addStyle(target, darkMode.darkStyle)
42
+ } else {
43
+ removeClass(target, darkMode.darkClass)
44
+ addClass(target, darkMode.lightClass)
45
+ removeStyle(target, darkMode.darkStyle)
46
+ addStyle(target, darkMode.lightStyle)
47
+ }
48
+ if (options?.bodyClass) {
49
+ addClass(document.body, options.bodyClass)
50
+ }
51
+ if (options?.bodyStyle) {
52
+ addStyle(document.body, options.bodyStyle)
53
+ }
54
+ return <Story />
55
+ }
56
+ }
57
+
58
+ function addClass(target: HTMLElement, className: string | string[] | undefined) {
59
+ if (!className) return
60
+ if (typeof className === 'string') {
61
+ target.classList.add(className)
62
+ } else if (Array.isArray(className)) {
63
+ target.classList.add(...className)
64
+ }
65
+ }
66
+
67
+ function removeClass(target: HTMLElement, className: string | string[] | undefined) {
68
+ if (!className) return
69
+ if (typeof className === 'string') {
70
+ target.classList.remove(className)
71
+ } else if (Array.isArray(className)) {
72
+ target.classList.remove(...className)
73
+ }
74
+ }
75
+
76
+ function addStyle(target: HTMLElement, style: CSSProperties | undefined) {
77
+ if (style) {
78
+ for (const [key, value] of Object.entries(toDOMStyle(style)!)) {
79
+ target.style.setProperty(key, value as any)
80
+ }
81
+ }
82
+ }
83
+
84
+ function removeStyle(target: HTMLElement, style: CSSProperties | undefined) {
85
+ if (style) {
86
+ for (const key of Object.keys(toDOMStyle(style)!)) {
87
+ target.style.removeProperty(key)
88
+ }
89
+ }
90
+ }
@@ -1,128 +0,0 @@
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
- * - ✏️ Editor - Stories with live editor
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
- * - 📸 Snapshot - Stories with snapshot tests
16
- * - 🧪 Unit - Stories with unit tests
17
- * - 🔗 Integration - Stories with integration tests
18
- *
19
- * Also includes the default version badge from `storybook-addon-tag-badges`.
20
- */
21
- export declare const editorBadge: {
22
- tags: string;
23
- badge: {
24
- text: string;
25
- bgColor: string;
26
- borderColor: string;
27
- tooltip: string;
28
- };
29
- display: {
30
- sidebar: string[];
31
- toolbar: string[];
32
- };
33
- };
34
- export declare const newBadge: {
35
- tags: string;
36
- badge: {
37
- text: string;
38
- bgColor: string;
39
- borderColor: string;
40
- tooltip: string;
41
- };
42
- };
43
- export declare const betaBadge: {
44
- tags: string;
45
- badge: {
46
- text: string;
47
- bgColor: string;
48
- borderColor: string;
49
- tooltip: string;
50
- };
51
- };
52
- export declare const deprecatedBadge: {
53
- tags: string;
54
- badge: {
55
- text: string;
56
- bgColor: string;
57
- borderColor: string;
58
- tooltip: string;
59
- };
60
- };
61
- export declare const outdatedBadge: {
62
- tags: string;
63
- badge: {
64
- text: string;
65
- bgColor: string;
66
- borderColor: string;
67
- tooltip: string;
68
- };
69
- };
70
- export declare const dangerBadge: {
71
- tags: string;
72
- badge: {
73
- text: string;
74
- bgColor: string;
75
- borderColor: string;
76
- tooltip: string;
77
- };
78
- };
79
- export declare const todoBadge: {
80
- tags: string;
81
- badge: {
82
- text: string;
83
- bgColor: string;
84
- borderColor: string;
85
- tooltip: string;
86
- };
87
- };
88
- export declare const codeOnlyBadge: {
89
- tags: string;
90
- badge: {
91
- text: string;
92
- bgColor: string;
93
- borderColor: string;
94
- tooltip: string;
95
- };
96
- };
97
- export declare const snapshotBadge: {
98
- tags: string;
99
- badge: {
100
- text: string;
101
- bgColor: string;
102
- borderColor: string;
103
- tooltip: string;
104
- };
105
- display: {
106
- sidebar: string[];
107
- toolbar: string[];
108
- };
109
- };
110
- export declare const unitBadge: {
111
- tags: string;
112
- badge: {
113
- text: string;
114
- bgColor: string;
115
- borderColor: string;
116
- tooltip: string;
117
- };
118
- };
119
- export declare const integrationBadge: {
120
- tags: string;
121
- badge: {
122
- text: string;
123
- bgColor: string;
124
- borderColor: string;
125
- tooltip: string;
126
- };
127
- };
128
- export declare const tagBadges: TagBadgeParameters;
@@ -1,55 +0,0 @@
1
- type StorySortConfig = {
2
- includeNames?: boolean;
3
- locales?: string;
4
- method?: 'alphabetical' | 'alphabetical-by-kind' | 'custom';
5
- order?: string[];
6
- [k: string]: unknown;
7
- };
8
- type Story = {
9
- id: string;
10
- importPath: string;
11
- name: string;
12
- title: string;
13
- };
14
- type StorySortFn = (a: Story, b: Story) => number;
15
- /**
16
- * Interface for story sorting parameters in Storybook.
17
- * Used to define how stories should be sorted in the navigation sidebar.
18
- */
19
- export interface StorySortParam {
20
- /**
21
- * Configuration for story sorting. Can be either:
22
- * - A StorySortConfig object specifying sort method and options
23
- * - A custom sorting function that takes two stories and returns their sort order
24
- */
25
- storySort: StorySortConfig | StorySortFn;
26
- }
27
- /**
28
- * Defines story sorting parameters for Storybook navigation.
29
- *
30
- * @see https://storybook.js.org/docs/api/parameters#optionsstorysort
31
- *
32
- * @param storySort - Configuration for how stories should be sorted. Can be either:
33
- * - A configuration object specifying sort method and options
34
- * - A custom sorting function that takes two stories and returns their sort order
35
- * @returns An object containing the story sort configuration
36
- *
37
- * @example
38
- * // Alphabetical sorting
39
- * defineStorySort({ method: 'alphabetical' })
40
- *
41
- * @example
42
- * // Custom order
43
- * defineStorySort({
44
- * method: 'custom',
45
- * order: ['Introduction', 'Components', '*']
46
- * })
47
- *
48
- * @example
49
- * // Custom sort function
50
- * defineStorySort((a, b) => a.title.localeCompare(b.title))
51
- */
52
- export declare function defineStorySort(storySort: StorySortParam['storySort']): {
53
- storySort: StorySortConfig | StorySortFn;
54
- };
55
- export {};
@@ -1,28 +0,0 @@
1
- /**
2
- * Defines story sorting parameters for Storybook navigation.
3
- *
4
- * @see https://storybook.js.org/docs/api/parameters#optionsstorysort
5
- *
6
- * @param storySort - Configuration for how stories should be sorted. Can be either:
7
- * - A configuration object specifying sort method and options
8
- * - A custom sorting function that takes two stories and returns their sort order
9
- * @returns An object containing the story sort configuration
10
- *
11
- * @example
12
- * // Alphabetical sorting
13
- * defineStorySort({ method: 'alphabetical' })
14
- *
15
- * @example
16
- * // Custom order
17
- * defineStorySort({
18
- * method: 'custom',
19
- * order: ['Introduction', 'Components', '*']
20
- * })
21
- *
22
- * @example
23
- * // Custom sort function
24
- * defineStorySort((a, b) => a.title.localeCompare(b.title))
25
- */
26
- export function defineStorySort(storySort) {
27
- return { storySort };
28
- }
@@ -1,2 +0,0 @@
1
- export * from './decorators/show_doc_source.tsx';
2
- export * from './decorators/when_running_in_test.tsx';
@@ -1,2 +0,0 @@
1
- export * from "./decorators/show_doc_source.js";
2
- export * from "./decorators/when_running_in_test.js";
@@ -1,58 +0,0 @@
1
- type StorySortConfig = {
2
- includeNames?: boolean
3
- locales?: string
4
- method?: 'alphabetical' | 'alphabetical-by-kind' | 'custom'
5
- order?: string[]
6
- [k: string]: unknown
7
- }
8
-
9
- type Story = {
10
- id: string
11
- importPath: string
12
- name: string
13
- title: string
14
- }
15
-
16
- type StorySortFn = (a: Story, b: Story) => number
17
-
18
- /**
19
- * Interface for story sorting parameters in Storybook.
20
- * Used to define how stories should be sorted in the navigation sidebar.
21
- */
22
- export interface StorySortParam {
23
- /**
24
- * Configuration for story sorting. Can be either:
25
- * - A StorySortConfig object specifying sort method and options
26
- * - A custom sorting function that takes two stories and returns their sort order
27
- */
28
- storySort: StorySortConfig | StorySortFn
29
- }
30
-
31
- /**
32
- * Defines story sorting parameters for Storybook navigation.
33
- *
34
- * @see https://storybook.js.org/docs/api/parameters#optionsstorysort
35
- *
36
- * @param storySort - Configuration for how stories should be sorted. Can be either:
37
- * - A configuration object specifying sort method and options
38
- * - A custom sorting function that takes two stories and returns their sort order
39
- * @returns An object containing the story sort configuration
40
- *
41
- * @example
42
- * // Alphabetical sorting
43
- * defineStorySort({ method: 'alphabetical' })
44
- *
45
- * @example
46
- * // Custom order
47
- * defineStorySort({
48
- * method: 'custom',
49
- * order: ['Introduction', 'Components', '*']
50
- * })
51
- *
52
- * @example
53
- * // Custom sort function
54
- * defineStorySort((a, b) => a.title.localeCompare(b.title))
55
- */
56
- export function defineStorySort(storySort: StorySortParam['storySort']) {
57
- return { storySort }
58
- }
@@ -1,2 +0,0 @@
1
- export * from './decorators/show_doc_source.tsx'
2
- export * from './decorators/when_running_in_test.tsx'