@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
package/esm/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export * from '@repobuddy/test';
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';
5
7
  export * from './parameters/define_layout_param.ts';
6
8
  export * from './parameters/define_parameters.ts';
7
- export * from './parameters/define_story_sort.ts';
8
9
  export * from './parameters/define_test_param.ts';
9
10
  export * from './parameters/define_viewport_param.ts';
11
+ export * from './parameters/story_sort.ts';
package/esm/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  export * from '@repobuddy/test';
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";
5
7
  export * from "./parameters/define_layout_param.js";
6
8
  export * from "./parameters/define_parameters.js";
7
- export * from "./parameters/define_story_sort.js";
8
9
  export * from "./parameters/define_test_param.js";
9
10
  export * from "./parameters/define_viewport_param.js";
11
+ export * from "./parameters/story_sort.js";
@@ -1,2 +1 @@
1
1
  export * from './brand_title.ts';
2
- export * from './tag_badges.ts';
@@ -1,2 +1 @@
1
1
  export * from "./brand_title.js";
2
- export * from "./tag_badges.js";
@@ -1,10 +1,12 @@
1
1
  import type { BackgroundsParam, GlobalApiBackgroundsParam } from './define_backgrounds_param.ts';
2
2
  import type { DocsParam } from './define_docs_param.ts';
3
3
  import type { LayoutParam } from './define_layout_param.ts';
4
- import type { StorySortParam } from './define_story_sort.ts';
5
4
  import type { TestParam } from './define_test_param.ts';
6
5
  import type { ViewportParam } from './define_viewport_param.ts';
7
- export type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgroundsParam> & Partial<DocsParam> & Partial<LayoutParam> & Partial<StorySortParam> & Partial<TestParam> & Partial<ViewportParam>;
6
+ import type { StorySortParam } from './story_sort.ts';
7
+ export type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgroundsParam> & Partial<DocsParam> & Partial<LayoutParam> & Partial<TestParam> & Partial<ViewportParam> & {
8
+ options?: StorySortParam & Record<string, any>;
9
+ } & Record<string, any>;
8
10
  /**
9
11
  * Defines parameters for Storybook stories, combining built-in parameters with custom ones.
10
12
  *
@@ -0,0 +1,27 @@
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
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './tag_badges.ts';
@@ -0,0 +1 @@
1
+ export * from "./tag_badges.js";
@@ -0,0 +1,35 @@
1
+ import { type TagBadgeParameters } from 'storybook-addon-tag-badges';
2
+ type TagBadgeParameter = TagBadgeParameters[0];
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
+ * - ✏️ Editor - Stories with live editor
9
+ * - 🆕 New - Recently added stories
10
+ * - 🅱️ Beta - Stories for features in beta
11
+ * - 🪦 Deprecated - Stories for deprecated features
12
+ * - ⚠️ Outdated - Stories that need updating
13
+ * - 🚨 Danger - Stories demonstrating dangerous patterns
14
+ * - 📋 Todo - Stories marked as todo/incomplete
15
+ * - 📝 Code Only - Stories without visual examples
16
+ * - 📸 Snapshot - Stories with snapshot tests
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
+ */
22
+ export declare const editorBadge: TagBadgeParameter;
23
+ export declare const newBadge: TagBadgeParameter;
24
+ export declare const betaBadge: TagBadgeParameter;
25
+ export declare const propsBadge: TagBadgeParameter;
26
+ export declare const deprecatedBadge: TagBadgeParameter;
27
+ export declare const outdatedBadge: TagBadgeParameter;
28
+ export declare const dangerBadge: TagBadgeParameter;
29
+ export declare const todoBadge: TagBadgeParameter;
30
+ export declare const codeOnlyBadge: TagBadgeParameter;
31
+ export declare const snapshotBadge: TagBadgeParameter;
32
+ export declare const unitBadge: TagBadgeParameter;
33
+ export declare const integrationBadge: TagBadgeParameter;
34
+ export declare const tagBadges: TagBadgeParameters;
35
+ export {};
@@ -50,6 +50,15 @@ export const betaBadge = {
50
50
  tooltip: 'Beta'
51
51
  }
52
52
  };
53
+ export const propsBadge = {
54
+ tags: 'props',
55
+ badge: {
56
+ text: '🔧',
57
+ bgColor: 'transparent',
58
+ borderColor: 'transparent',
59
+ tooltip: 'Props'
60
+ }
61
+ };
53
62
  export const deprecatedBadge = {
54
63
  tags: 'deprecated',
55
64
  badge: {
@@ -104,7 +113,7 @@ export const snapshotBadge = {
104
113
  tooltip: 'Snapshot Test'
105
114
  },
106
115
  display: {
107
- sidebar: ['story'],
116
+ sidebar: false,
108
117
  toolbar: ['story']
109
118
  }
110
119
  };
@@ -115,6 +124,9 @@ export const unitBadge = {
115
124
  bgColor: 'transparent',
116
125
  borderColor: 'transparent',
117
126
  tooltip: 'Unit Test'
127
+ },
128
+ display: {
129
+ sidebar: false
118
130
  }
119
131
  };
120
132
  export const integrationBadge = {
@@ -124,6 +136,9 @@ export const integrationBadge = {
124
136
  bgColor: 'transparent',
125
137
  borderColor: 'transparent',
126
138
  tooltip: 'Integration Test'
139
+ },
140
+ display: {
141
+ sidebar: false
127
142
  }
128
143
  };
129
144
  export const tagBadges = [
@@ -135,6 +150,7 @@ export const tagBadges = [
135
150
  deprecatedBadge,
136
151
  outdatedBadge,
137
152
  dangerBadge,
153
+ propsBadge,
138
154
  todoBadge,
139
155
  codeOnlyBadge,
140
156
  snapshotBadge,
@@ -0,0 +1,26 @@
1
+ import { type DocsContextProps } from '@storybook/blocks';
2
+ import { type ThemeVars } from '@storybook/theming';
3
+ import { type PropsWithChildren } from 'react';
4
+ /**
5
+ * Creates a `DocsContainer` for `storybook` that works with `storybook-dark-mode`.
6
+ *
7
+ * @see https://github.com/hipstersmoothie/storybook-dark-mode/issues/282
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // .storybook/preview.tsx
12
+ * const preview: Preview = {
13
+ * parameters: {
14
+ * docs: {
15
+ * container: createDarkModeDocsContainer()
16
+ * }
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function createDarkModeDocsContainer(customThemes?: {
22
+ light?: ThemeVars | undefined;
23
+ dark?: ThemeVars | undefined;
24
+ } | undefined): (props: PropsWithChildren<{
25
+ context: DocsContextProps;
26
+ }>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DocsContainer } from '@storybook/blocks';
3
+ import { themes } from '@storybook/theming';
4
+ import { useEffect, useState } from 'react';
5
+ import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';
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(customThemes) {
24
+ return function DarkModeDocsContainer(props) {
25
+ const [isDark, setDark] = useState(true);
26
+ useEffect(() => {
27
+ props.context.channel.on(DARK_MODE_EVENT_NAME, setDark);
28
+ return () => props.context.channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
29
+ }, [props.context.channel]);
30
+ return (_jsx(DocsContainer, { ...props, theme: isDark ? (customThemes?.dark ?? themes.dark) : (customThemes?.light ?? themes.light), children: props.children }));
31
+ };
32
+ }
@@ -0,0 +1,49 @@
1
+ import type { CSSProperties } from '@just-web/css';
2
+ /**
3
+ * Configuration parameters for `storybook-dark-mode`.
4
+ */
5
+ export interface DarkModeParam {
6
+ /** The current theme ('dark' or 'light') */
7
+ current?: 'dark' | 'light' | undefined;
8
+ /**
9
+ * CSS class(es) to apply in dark mode.
10
+ */
11
+ darkClass?: string | string[] | undefined;
12
+ /**
13
+ * CSS style(s) to apply in dark mode.
14
+ *
15
+ * This only works when using `withStoryRoot`.
16
+ */
17
+ darkStyle?: CSSProperties | undefined;
18
+ /** CSS class(es) to apply in light mode */
19
+ lightClass?: string | string[] | undefined;
20
+ /**
21
+ * CSS style(s) to apply in light mode.
22
+ *
23
+ * This only works when using `withStoryRoot`.
24
+ */
25
+ lightStyle?: CSSProperties | undefined;
26
+ /** Element to apply theme classes to ('html' or 'body') */
27
+ classTarget?: 'html' | 'body' | undefined;
28
+ /** Whether to apply theme styles to preview iframe */
29
+ stylePreview?: boolean | undefined;
30
+ }
31
+ /**
32
+ * Defines `storybook-dark-mode` parameters for Storybook stories.
33
+ *
34
+ * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
35
+ * @returns An object containing the dark mode parameter configuration
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // ./storybook/preview.tsx
40
+ *
41
+ * export const preview = {
42
+ * parameters: {
43
+ * ...defineDarkModeParam({ darkClass: 'dark' })
44
+ * }
45
+ * }
46
+ */
47
+ export declare function defineDarkModeParam(darkMode: DarkModeParam): {
48
+ darkMode: DarkModeParam;
49
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Defines `storybook-dark-mode` parameters for Storybook stories.
3
+ *
4
+ * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
5
+ * @returns An object containing the dark mode parameter configuration
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // ./storybook/preview.tsx
10
+ *
11
+ * export const preview = {
12
+ * parameters: {
13
+ * ...defineDarkModeParam({ darkClass: 'dark' })
14
+ * }
15
+ * }
16
+ */
17
+ export function defineDarkModeParam(darkMode) {
18
+ return { darkMode };
19
+ }
@@ -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,3 @@
1
+ export * from "./dark_mode_docs_container.js";
2
+ export * from "./define_dark_mode.js";
3
+ export * from "./with_dark_mode.js";
@@ -0,0 +1,22 @@
1
+ import type { CSSProperties } from '@just-web/css';
2
+ import type { DecoratorFunction } from 'storybook/internal/types';
3
+ /**
4
+ * Applies additional dark mode behavior.
5
+ *
6
+ * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
7
+ * @returns A decorator function that applies additional dark mode behavior.
8
+ */
9
+ export declare function withDarkMode(options?: {
10
+ /**
11
+ * CSS class(es) to apply to the body element.
12
+ *
13
+ * Useful when using Tailwind CSS and `classTarget: 'html'`
14
+ */
15
+ bodyClass?: string | string[] | undefined;
16
+ /**
17
+ * CSS style(s) to apply to the body element.
18
+ *
19
+ * Useful when using Tailwind CSS and `classTarget: 'html'`
20
+ */
21
+ bodyStyle?: CSSProperties | undefined;
22
+ } | undefined): DecoratorFunction<any, any>;
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { toDOMStyle } from '@just-web/css';
3
+ import { useDarkMode } from 'storybook-dark-mode';
4
+ /**
5
+ * Applies additional dark mode behavior.
6
+ *
7
+ * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
8
+ * @returns A decorator function that applies additional dark mode behavior.
9
+ */
10
+ export function withDarkMode(options) {
11
+ return function darkModeDecorator(Story, { parameters }) {
12
+ const darkMode = parameters.darkMode;
13
+ if (!darkMode)
14
+ return _jsx(Story, {});
15
+ const dark = useDarkMode();
16
+ const target = darkMode.classTarget === 'html' ? document.documentElement : document.body;
17
+ if (dark) {
18
+ removeClass(target, darkMode.lightClass);
19
+ addClass(target, darkMode.darkClass);
20
+ removeStyle(target, darkMode.lightStyle);
21
+ addStyle(target, darkMode.darkStyle);
22
+ }
23
+ else {
24
+ removeClass(target, darkMode.darkClass);
25
+ addClass(target, darkMode.lightClass);
26
+ removeStyle(target, darkMode.darkStyle);
27
+ addStyle(target, darkMode.lightStyle);
28
+ }
29
+ if (options?.bodyClass) {
30
+ addClass(document.body, options.bodyClass);
31
+ }
32
+ if (options?.bodyStyle) {
33
+ addStyle(document.body, options.bodyStyle);
34
+ }
35
+ return _jsx(Story, {});
36
+ };
37
+ }
38
+ function addClass(target, className) {
39
+ if (!className)
40
+ return;
41
+ if (typeof className === 'string') {
42
+ target.classList.add(className);
43
+ }
44
+ else if (Array.isArray(className)) {
45
+ target.classList.add(...className);
46
+ }
47
+ }
48
+ function removeClass(target, className) {
49
+ if (!className)
50
+ return;
51
+ if (typeof className === 'string') {
52
+ target.classList.remove(className);
53
+ }
54
+ else if (Array.isArray(className)) {
55
+ target.classList.remove(...className);
56
+ }
57
+ }
58
+ function addStyle(target, style) {
59
+ if (style) {
60
+ for (const [key, value] of Object.entries(toDOMStyle(style))) {
61
+ target.style.setProperty(key, value);
62
+ }
63
+ }
64
+ }
65
+ function removeStyle(target, style) {
66
+ if (style) {
67
+ for (const key of Object.keys(toDOMStyle(style))) {
68
+ target.style.removeProperty(key);
69
+ }
70
+ }
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repobuddy/storybook",
3
- "version": "0.9.4",
3
+ "version": "0.11.0",
4
4
  "description": "Storybook repo buddy",
5
5
  "keywords": [
6
6
  "storybook",
@@ -23,9 +23,13 @@
23
23
  "types": "./esm/manager/index.d.ts",
24
24
  "default": "./esm/manager/index.js"
25
25
  },
26
- "./react": {
27
- "types": "./esm/react/index.d.ts",
28
- "default": "./esm/react/index.js"
26
+ "./storybook-addon-tag-badges": {
27
+ "types": "./esm/storybook-addon-tag-badges/index.d.ts",
28
+ "default": "./esm/storybook-addon-tag-badges/index.js"
29
+ },
30
+ "./storybook-dark-mode": {
31
+ "types": "./esm/storybook-dark-mode/index.d.ts",
32
+ "default": "./esm/storybook-dark-mode/index.js"
29
33
  },
30
34
  "./testing": {
31
35
  "types": "./esm/testing.d.ts",
@@ -38,6 +42,7 @@
38
42
  "!**/*.{spec,test,unit,accept,integrate,system,perf,stress,study,stories}.*"
39
43
  ],
40
44
  "dependencies": {
45
+ "@just-web/css": "^0.4.0",
41
46
  "@repobuddy/test": "^1.0.0"
42
47
  },
43
48
  "devDependencies": {
@@ -66,6 +71,26 @@
66
71
  "vite": "^6.3.4",
67
72
  "vitest": "^3.1.2"
68
73
  },
74
+ "peerDependencies": {
75
+ "@storybook/blocks": ">= 8.6.12",
76
+ "@storybook/theming": ">= 8.6.12",
77
+ "storybook-addon-tag-badges": ">= 1.4.0",
78
+ "storybook-dark-mode": ">= 4.0.2"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@storybook/blocks": {
82
+ "optional": true
83
+ },
84
+ "@storybook/theming": {
85
+ "optional": true
86
+ },
87
+ "storybook-addon-tag-badges": {
88
+ "optional": true
89
+ },
90
+ "storybook-dark-mode": {
91
+ "optional": true
92
+ }
93
+ },
69
94
  "scripts": {
70
95
  "build": "tsc",
71
96
  "clean": "rimraf .turbo coverage esm storybook-static *.tsbuildinfo",
package/readme.md CHANGED
@@ -23,7 +23,7 @@ For example:
23
23
  import { defineLayoutParam } from '@repobuddy/storybook'
24
24
 
25
25
  export const MyStory: StoryObj = {
26
- parameters: defineLayoutParam('fullscreen')
26
+ parameters: defineLayoutParam('fullscreen')
27
27
  }
28
28
  ```
29
29
 
@@ -34,13 +34,13 @@ and also allow you to specify additional parameter types.
34
34
  import { defineParameters, type ActionsParam } from '@repobuddy/storybook'
35
35
 
36
36
  export const MyStory: StoryObj = {
37
- parameters: defineParameters<ActionsParam>({
38
- layout: 'fullscreen',
39
- // this is typed
40
- actions: {
41
- disable: true
42
- }
43
- })
37
+ parameters: defineParameters<ActionsParam>({
38
+ layout: 'fullscreen',
39
+ // this is typed
40
+ actions: {
41
+ disable: true
42
+ }
43
+ })
44
44
  }
45
45
  ```
46
46
 
@@ -59,7 +59,7 @@ addons.setConfig({
59
59
  })
60
60
  ```
61
61
 
62
- ### Tag Badges
62
+ ### `storybook-addon-tag-badges`
63
63
 
64
64
  If you use [`storybook-addon-tag-badges`][`storybook-addon-tag-badges`],
65
65
  we provide a different set of badges that uses emojis:
@@ -80,11 +80,50 @@ we provide a different set of badges that uses emojis:
80
80
  To use them, add them to your `.storybook/manager.ts`:
81
81
 
82
82
  ```ts
83
- import { tagBadges } from '@repobuddy/storybook/manager'
83
+ import { tagBadges } from '@repobuddy/storybook/storybook-addon-tag-badges'
84
84
  import { addons } from '@storybook/manager-api'
85
85
 
86
86
  addons.setConfig({ tagBadges })
87
87
  ```
88
88
 
89
+ You can also import only the one you need:
90
+
91
+ ```ts
92
+ import { newBadge } from '@repobuddy/storybook/storybook-addon-tag-badges'
93
+ import { defaultConfig } from 'storybook-addon-tag-badges'
94
+
95
+ addons.setConfig({ tagBadges: [newBadge, ...defaultConfig] })
96
+ ```
97
+
98
+ ### `storybook-dark-mode`
99
+
100
+ [`@repobuddy/storybook`][`@repobuddy/storybook`] provides a few utilities to work with [`storybook-dark-mode`][`storybook-dark-mode`].
101
+
102
+ ```ts
103
+ // .storybook/preview.tsx
104
+ import {
105
+ createDarkModeDocsContainer,
106
+ defineDarkModeParam,
107
+ withDarkMode
108
+ } from '@repobuddy/storybook/storybook-dark-mode'
109
+
110
+ export const preview: Preview = {
111
+ parameters: {
112
+ docs: {
113
+ container: createDarkModeDocsContainer()
114
+ },
115
+ darkMode: defineDarkModeParam({
116
+ classTarget: 'html',
117
+ darkClass: 'dark',
118
+ stylePreview: true
119
+ })
120
+ },
121
+ decorators: [withDarkMode({
122
+ bodyClass: 'dark:bg-black dark:text-white'
123
+ })]
124
+ }
125
+ ```
126
+
89
127
  [`@repobuddy/storybook`]: https://github.com/repobuddy/storybook
90
128
  [`storybook-addon-tag-badges`]: https://github.com/Sidnioulz/storybook-addon-tag-badges
129
+ [`storybook-dark-mode`]: https://github.com/hipstersmoothie/storybook-dark-mode
package/src/index.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export * from '@repobuddy/test'
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'
5
7
  export * from './parameters/define_layout_param.ts'
6
8
  export * from './parameters/define_parameters.ts'
7
- export * from './parameters/define_story_sort.ts'
8
9
  export * from './parameters/define_test_param.ts'
9
10
  export * from './parameters/define_viewport_param.ts'
11
+ export * from './parameters/story_sort.ts'
@@ -1,2 +1 @@
1
1
  export * from './brand_title.ts'
2
- export * from './tag_badges.ts'
@@ -1,16 +1,15 @@
1
1
  import type { BackgroundsParam, GlobalApiBackgroundsParam } from './define_backgrounds_param.ts'
2
2
  import type { DocsParam } from './define_docs_param.ts'
3
3
  import type { LayoutParam } from './define_layout_param.ts'
4
- import type { StorySortParam } from './define_story_sort.ts'
5
4
  import type { TestParam } from './define_test_param.ts'
6
5
  import type { ViewportParam } from './define_viewport_param.ts'
6
+ import type { StorySortParam } from './story_sort.ts'
7
7
 
8
8
  export type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgroundsParam> &
9
9
  Partial<DocsParam> &
10
10
  Partial<LayoutParam> &
11
- Partial<StorySortParam> &
12
11
  Partial<TestParam> &
13
- Partial<ViewportParam>
12
+ Partial<ViewportParam> & { options?: StorySortParam & Record<string, any> } & Record<string, any>
14
13
 
15
14
  /**
16
15
  * Defines parameters for Storybook stories, combining built-in parameters with custom ones.
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1 @@
1
+ export * from './tag_badges.ts'