@repobuddy/storybook 1.0.1 → 2.0.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.
Files changed (110) hide show
  1. package/cjs/components/show_html.d.ts +16 -0
  2. package/cjs/components/show_html.js +29 -0
  3. package/cjs/decorators/show_doc_source.d.ts +6 -0
  4. package/cjs/decorators/show_doc_source.js +38 -0
  5. package/cjs/index.d.ts +13 -0
  6. package/cjs/index.js +137 -0
  7. package/cjs/manager/brand_title.d.ts +35 -0
  8. package/cjs/manager/brand_title.js +12 -0
  9. package/cjs/manager/index.d.ts +1 -0
  10. package/cjs/manager/index.js +16 -0
  11. package/cjs/parameters/define_actions_param.d.ts +24 -0
  12. package/cjs/parameters/define_actions_param.js +11 -0
  13. package/cjs/parameters/define_backgrounds_param.d.ts +45 -0
  14. package/cjs/parameters/define_backgrounds_param.js +10 -0
  15. package/cjs/parameters/define_docs_param.d.ts +217 -0
  16. package/cjs/parameters/define_docs_param.js +11 -0
  17. package/cjs/parameters/define_layout_param.d.ts +20 -0
  18. package/cjs/parameters/define_layout_param.js +10 -0
  19. package/cjs/parameters/define_parameters.d.ts +39 -0
  20. package/cjs/parameters/define_parameters.js +9 -0
  21. package/cjs/parameters/define_test_param.d.ts +34 -0
  22. package/cjs/parameters/define_test_param.js +11 -0
  23. package/cjs/parameters/define_viewport_param.d.ts +78 -0
  24. package/cjs/parameters/define_viewport_param.js +11 -0
  25. package/cjs/parameters/story_sort.d.ts +27 -0
  26. package/cjs/parameters/story_sort.js +1 -0
  27. package/cjs/storybook-addon-tag-badges/index.d.ts +2 -0
  28. package/cjs/storybook-addon-tag-badges/index.js +16 -0
  29. package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +41 -0
  30. package/cjs/storybook-addon-tag-badges/tag_badges.js +179 -0
  31. package/cjs/storybook-addon-tag-badges/types.d.ts +9 -0
  32. package/cjs/storybook-addon-tag-badges/types.js +1 -0
  33. package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +26 -0
  34. package/cjs/storybook-dark-mode/dark_mode_docs_container.js +23 -0
  35. package/cjs/storybook-dark-mode/define_dark_mode.d.ts +54 -0
  36. package/cjs/storybook-dark-mode/define_dark_mode.js +11 -0
  37. package/cjs/storybook-dark-mode/index.d.ts +3 -0
  38. package/cjs/storybook-dark-mode/index.js +38 -0
  39. package/cjs/storybook-dark-mode/with_dark_mode.d.ts +22 -0
  40. package/cjs/storybook-dark-mode/with_dark_mode.js +54 -0
  41. package/cjs/testing/decorators/when_running_in_test.d.ts +5 -0
  42. package/cjs/testing/decorators/when_running_in_test.js +12 -0
  43. package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +3 -0
  44. package/cjs/testing/decorators/when_running_in_text.ctx.js +10 -0
  45. package/cjs/types.d.ts +41 -0
  46. package/cjs/types.js +1 -0
  47. package/cjs/variants/index.d.ts +1 -0
  48. package/cjs/variants/index.js +8 -0
  49. package/cjs/variants/package.json +3 -0
  50. package/cjs/variants/preset.d.ts +11 -0
  51. package/cjs/variants/preset.js +3 -0
  52. package/esm/components/show_html.d.ts +1 -1
  53. package/esm/components/show_html.js +17 -26
  54. package/esm/decorators/show_doc_source.js +26 -12
  55. package/esm/index.d.ts +1 -0
  56. package/esm/index.js +12 -12
  57. package/esm/manager/brand_title.js +2 -24
  58. package/esm/manager/index.d.ts +1 -1
  59. package/esm/parameters/define_actions_param.js +1 -9
  60. package/esm/parameters/define_backgrounds_param.js +1 -7
  61. package/esm/parameters/define_docs_param.d.ts +2 -2
  62. package/esm/parameters/define_docs_param.js +1 -28
  63. package/esm/parameters/define_layout_param.js +1 -15
  64. package/esm/parameters/define_parameters.d.ts +7 -7
  65. package/esm/parameters/define_parameters.js +1 -30
  66. package/esm/parameters/define_test_param.js +1 -17
  67. package/esm/parameters/define_viewport_param.js +1 -28
  68. package/esm/parameters/story_sort.js +0 -1
  69. package/esm/storybook-addon-tag-badges/index.d.ts +2 -2
  70. package/esm/storybook-addon-tag-badges/tag_badges.d.ts +1 -1
  71. package/esm/storybook-addon-tag-badges/tag_badges.js +153 -172
  72. package/esm/storybook-addon-tag-badges/types.d.ts +8 -7
  73. package/esm/storybook-addon-tag-badges/types.js +0 -1
  74. package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +2 -2
  75. package/esm/storybook-dark-mode/dark_mode_docs_container.js +19 -30
  76. package/esm/storybook-dark-mode/define_dark_mode.d.ts +3 -3
  77. package/esm/storybook-dark-mode/define_dark_mode.js +1 -17
  78. package/esm/storybook-dark-mode/index.d.ts +3 -3
  79. package/esm/storybook-dark-mode/with_dark_mode.js +36 -47
  80. package/esm/testing/decorators/when_running_in_test.js +3 -7
  81. package/esm/testing/decorators/when_running_in_text.ctx.d.ts +1 -2
  82. package/esm/testing/decorators/when_running_in_text.ctx.js +2 -2
  83. package/esm/types.d.ts +41 -0
  84. package/esm/types.js +0 -0
  85. package/esm/variants/index.d.ts +1 -0
  86. package/esm/variants/index.js +2 -0
  87. package/esm/variants/package.json +3 -0
  88. package/esm/variants/preset.d.ts +11 -0
  89. package/esm/variants/preset.js +1 -0
  90. package/package.json +51 -34
  91. package/readme.md +3 -3
  92. package/src/decorators/show_doc_source.tsx +30 -11
  93. package/src/index.ts +1 -0
  94. package/src/manager/index.ts +1 -1
  95. package/src/parameters/define_docs_param.ts +2 -2
  96. package/src/parameters/define_parameters.ts +6 -6
  97. package/src/storybook-addon-tag-badges/index.ts +2 -2
  98. package/src/storybook-addon-tag-badges/tag_badges.ts +1 -1
  99. package/src/storybook-addon-tag-badges/types.ts +8 -7
  100. package/src/storybook-dark-mode/dark_mode_docs_container.tsx +2 -2
  101. package/src/storybook-dark-mode/define_dark_mode.ts +3 -3
  102. package/src/storybook-dark-mode/index.ts +3 -3
  103. package/src/storybook-dark-mode/with_dark_mode.tsx +3 -2
  104. package/src/testing/decorators/when_running_in_test.tsx +1 -1
  105. package/src/types.ts +51 -0
  106. package/src/variants/index.ts +3 -0
  107. package/src/variants/package.json +3 -0
  108. package/src/variants/preset.ts +22 -0
  109. package/src/overview.mdx +0 -7
  110. package/src/storybook-dark-mode/dark_mode_docs_container.mdx +0 -33
@@ -1,208 +1,189 @@
1
- import { defaultConfig } from 'storybook-addon-tag-badges';
1
+ import { defaultConfig } from "storybook-addon-tag-badges/manager-helpers";
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
- * - ✏️ 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
3
  export const editorBadge = {
23
- tags: 'editor',
24
- badge: {
25
- text: '✏️',
26
- style: {
27
- backgroundColor: 'transparent',
28
- borderColor: 'transparent'
29
- },
30
- tooltip: 'Editor'
4
+ tags: "editor",
5
+ badge: {
6
+ text: "\u270F\uFE0F",
7
+ style: {
8
+ backgroundColor: "transparent",
9
+ borderColor: "transparent"
31
10
  },
32
- display: {
33
- sidebar: {
34
- type: 'story',
35
- skipInherited: false
36
- }
11
+ tooltip: "Editor"
12
+ },
13
+ display: {
14
+ sidebar: {
15
+ type: "story",
16
+ skipInherited: false
37
17
  }
18
+ }
38
19
  };
39
20
  export const newBadge = {
40
- tags: 'new',
41
- badge: {
42
- text: '🆕',
43
- style: {
44
- backgroundColor: 'transparent',
45
- borderColor: 'transparent'
46
- },
47
- tooltip: 'New'
48
- }
21
+ tags: "new",
22
+ badge: {
23
+ text: "\u{1F195}",
24
+ style: {
25
+ backgroundColor: "transparent",
26
+ borderColor: "transparent"
27
+ },
28
+ tooltip: "New"
29
+ }
49
30
  };
50
31
  export const betaBadge = {
51
- tags: 'beta',
52
- badge: {
53
- text: '🅱️',
54
- style: {
55
- backgroundColor: 'transparent',
56
- borderColor: 'transparent'
57
- },
58
- tooltip: 'Beta'
59
- }
32
+ tags: "beta",
33
+ badge: {
34
+ text: "\u{1F171}\uFE0F",
35
+ style: {
36
+ backgroundColor: "transparent",
37
+ borderColor: "transparent"
38
+ },
39
+ tooltip: "Beta"
40
+ }
60
41
  };
61
42
  export const propsBadge = {
62
- tags: 'props',
63
- badge: {
64
- text: '🔧',
65
- style: {
66
- backgroundColor: 'transparent',
67
- borderColor: 'transparent'
68
- },
69
- tooltip: 'Props'
70
- }
43
+ tags: "props",
44
+ badge: {
45
+ text: "\u{1F527}",
46
+ style: {
47
+ backgroundColor: "transparent",
48
+ borderColor: "transparent"
49
+ },
50
+ tooltip: "Props"
51
+ }
71
52
  };
72
53
  export const deprecatedBadge = {
73
- tags: 'deprecated',
74
- badge: {
75
- text: '🪦',
76
- style: {
77
- backgroundColor: 'transparent',
78
- borderColor: 'transparent'
79
- },
80
- tooltip: 'Deprecated'
81
- }
54
+ tags: "deprecated",
55
+ badge: {
56
+ text: "\u{1FAA6}",
57
+ style: {
58
+ backgroundColor: "transparent",
59
+ borderColor: "transparent"
60
+ },
61
+ tooltip: "Deprecated"
62
+ }
82
63
  };
83
64
  export const outdatedBadge = {
84
- tags: 'outdated',
85
- badge: {
86
- text: '⚠️',
87
- style: {
88
- backgroundColor: 'transparent',
89
- borderColor: 'transparent'
90
- },
91
- tooltip: 'Outdated'
92
- }
65
+ tags: "outdated",
66
+ badge: {
67
+ text: "\u26A0\uFE0F",
68
+ style: {
69
+ backgroundColor: "transparent",
70
+ borderColor: "transparent"
71
+ },
72
+ tooltip: "Outdated"
73
+ }
93
74
  };
94
75
  export const dangerBadge = {
95
- tags: 'danger',
96
- badge: {
97
- text: '🚨',
98
- style: {
99
- backgroundColor: 'transparent',
100
- borderColor: 'transparent'
101
- },
102
- tooltip: 'Dangerous'
103
- }
76
+ tags: "danger",
77
+ badge: {
78
+ text: "\u{1F6A8}",
79
+ style: {
80
+ backgroundColor: "transparent",
81
+ borderColor: "transparent"
82
+ },
83
+ tooltip: "Dangerous"
84
+ }
104
85
  };
105
86
  export const todoBadge = {
106
- tags: 'todo',
107
- badge: {
108
- text: '📋',
109
- style: {
110
- backgroundColor: 'transparent',
111
- borderColor: 'transparent'
112
- },
113
- tooltip: 'Todo'
114
- }
87
+ tags: "todo",
88
+ badge: {
89
+ text: "\u{1F4CB}",
90
+ style: {
91
+ backgroundColor: "transparent",
92
+ borderColor: "transparent"
93
+ },
94
+ tooltip: "Todo"
95
+ }
115
96
  };
116
97
  export const codeOnlyBadge = {
117
- tags: 'code-only',
118
- badge: {
119
- text: '📝',
120
- style: {
121
- backgroundColor: 'transparent',
122
- borderColor: 'transparent'
123
- },
124
- tooltip: 'Code Only'
125
- }
98
+ tags: "code-only",
99
+ badge: {
100
+ text: "\u{1F4DD}",
101
+ style: {
102
+ backgroundColor: "transparent",
103
+ borderColor: "transparent"
104
+ },
105
+ tooltip: "Code Only"
106
+ }
126
107
  };
127
108
  export const snapshotBadge = {
128
- tags: 'snapshot',
129
- badge: {
130
- text: '📸',
131
- style: {
132
- backgroundColor: 'transparent',
133
- borderColor: 'transparent'
134
- },
135
- tooltip: 'Snapshot Test'
109
+ tags: "snapshot",
110
+ badge: {
111
+ text: "\u{1F4F8}",
112
+ style: {
113
+ backgroundColor: "transparent",
114
+ borderColor: "transparent"
136
115
  },
137
- display: {
138
- sidebar: false,
139
- toolbar: ['story']
140
- }
116
+ tooltip: "Snapshot Test"
117
+ },
118
+ display: {
119
+ sidebar: false,
120
+ toolbar: ["story"]
121
+ }
141
122
  };
142
123
  export const unitBadge = {
143
- tags: 'unit',
144
- badge: {
145
- text: '🧪',
146
- style: {
147
- backgroundColor: 'transparent',
148
- borderColor: 'transparent'
149
- },
150
- tooltip: 'Unit Test'
124
+ tags: "unit",
125
+ badge: {
126
+ text: "\u{1F9EA}",
127
+ style: {
128
+ backgroundColor: "transparent",
129
+ borderColor: "transparent"
151
130
  },
152
- display: {
153
- sidebar: false
154
- }
131
+ tooltip: "Unit Test"
132
+ },
133
+ display: {
134
+ sidebar: false
135
+ }
155
136
  };
156
137
  export const integrationBadge = {
157
- tags: 'integration',
158
- badge: {
159
- text: '🔗',
160
- style: {
161
- backgroundColor: 'transparent',
162
- borderColor: 'transparent'
163
- },
164
- tooltip: 'Integration Test'
138
+ tags: "integration",
139
+ badge: {
140
+ text: "\u{1F517}",
141
+ style: {
142
+ backgroundColor: "transparent",
143
+ borderColor: "transparent"
165
144
  },
166
- display: {
167
- sidebar: false
168
- }
145
+ tooltip: "Integration Test"
146
+ },
147
+ display: {
148
+ sidebar: false
149
+ }
169
150
  };
170
151
  export const keyboardBadge = {
171
- tags: 'keyboard',
172
- badge: {
173
- text: '⌨️',
174
- style: {
175
- backgroundColor: 'transparent',
176
- borderColor: 'transparent'
177
- },
178
- tooltip: 'Keyboard Interaction'
179
- }
152
+ tags: "keyboard",
153
+ badge: {
154
+ text: "\u2328\uFE0F",
155
+ style: {
156
+ backgroundColor: "transparent",
157
+ borderColor: "transparent"
158
+ },
159
+ tooltip: "Keyboard Interaction"
160
+ }
180
161
  };
181
162
  export const internalBadge = {
182
- tags: 'internal',
183
- badge: {
184
- text: '🔒',
185
- style: {
186
- backgroundColor: 'transparent',
187
- borderColor: 'transparent'
188
- },
189
- tooltip: 'Internal'
190
- }
163
+ tags: "internal",
164
+ badge: {
165
+ text: "\u{1F512}",
166
+ style: {
167
+ backgroundColor: "transparent",
168
+ borderColor: "transparent"
169
+ },
170
+ tooltip: "Internal"
171
+ }
191
172
  };
192
173
  export const tagBadges = [
193
- editorBadge,
194
- unitBadge,
195
- integrationBadge,
196
- keyboardBadge,
197
- newBadge,
198
- betaBadge,
199
- deprecatedBadge,
200
- outdatedBadge,
201
- dangerBadge,
202
- propsBadge,
203
- todoBadge,
204
- codeOnlyBadge,
205
- internalBadge,
206
- snapshotBadge,
207
- versionBadge
174
+ editorBadge,
175
+ unitBadge,
176
+ integrationBadge,
177
+ keyboardBadge,
178
+ newBadge,
179
+ betaBadge,
180
+ deprecatedBadge,
181
+ outdatedBadge,
182
+ dangerBadge,
183
+ propsBadge,
184
+ todoBadge,
185
+ codeOnlyBadge,
186
+ internalBadge,
187
+ snapshotBadge,
188
+ versionBadge
208
189
  ];
@@ -1,8 +1,9 @@
1
1
  import type { Args, Meta as M, StoryObj as SBO } from '@storybook/react-vite';
2
- import type { TagNames } from './tag_badges.ts';
3
- export type Meta<TCmpOrArgs = Args> = Omit<M<TCmpOrArgs>, 'tags'> & {
4
- tags?: Array<TagNames | (string & {})> | undefined;
5
- };
6
- export type StoryObj<TMetaOrCmpOrArgs = Args> = Omit<SBO<TMetaOrCmpOrArgs>, 'tags'> & {
7
- tags?: Array<TagNames | (string & {})> | undefined;
8
- };
2
+ import type { ExtendMeta, ExtendStoryObj } from '../types.js';
3
+ import type { TagNames } from './tag_badges.js';
4
+ export type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, M<TCmpOrArgs>, {
5
+ tag: TagNames;
6
+ }>;
7
+ export type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, SBO<TMetaOrCmpOrArgs>, {
8
+ tag: TagNames;
9
+ }>;
@@ -1 +0,0 @@
1
- export {};
@@ -2,7 +2,7 @@ import { type DocsContextProps } from '@storybook/addon-docs/blocks';
2
2
  import { type PropsWithChildren } from 'react';
3
3
  import { type ThemeVars } from 'storybook/theming';
4
4
  /**
5
- * Creates a `DocsContainer` for `storybook` that works with `storybook-dark-mode2`.
5
+ * Creates a `DocsContainer` for `storybook` that works with `@storybook-community/storybook-dark-mode`.
6
6
  *
7
7
  * @see https://github.com/hipstersmoothie/storybook-dark-mode/issues/282
8
8
  *
@@ -23,4 +23,4 @@ export declare function createDarkModeDocsContainer(customThemes?: {
23
23
  dark?: ThemeVars | undefined;
24
24
  } | undefined): (props: PropsWithChildren<{
25
25
  context: DocsContextProps;
26
- }>) => import("react/jsx-runtime").JSX.Element;
26
+ }>) => import("react").JSX.Element;
@@ -1,32 +1,21 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { DocsContainer } from '@storybook/addon-docs/blocks';
3
- import { useEffect, useState } from 'react';
4
- import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode2';
5
- import { themes } from 'storybook/theming';
6
- /**
7
- * Creates a `DocsContainer` for `storybook` that works with `storybook-dark-mode2`.
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
- */
1
+ import { DARK_MODE_EVENT_NAME } from "@storybook-community/storybook-dark-mode";
2
+ import { DocsContainer } from "@storybook/addon-docs/blocks";
3
+ import { useEffect, useState } from "react";
4
+ import { themes } from "storybook/theming";
23
5
  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
- };
6
+ return function DarkModeDocsContainer(props) {
7
+ const [isDark, setDark] = useState(true);
8
+ useEffect(() => {
9
+ props.context.channel.on(DARK_MODE_EVENT_NAME, setDark);
10
+ return () => props.context.channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
11
+ }, [props.context.channel]);
12
+ return /* @__PURE__ */ React.createElement(
13
+ DocsContainer,
14
+ {
15
+ ...props,
16
+ theme: isDark ? customThemes?.dark ?? themes.dark : customThemes?.light ?? themes.light
17
+ },
18
+ props.children
19
+ );
20
+ };
32
21
  }
@@ -1,7 +1,7 @@
1
1
  import type { CSSProperties } from '@just-web/css';
2
- import type { ThemeVars } from 'storybook/internal/theming';
2
+ import type { ThemeVars } from 'storybook/theming';
3
3
  /**
4
- * Configuration parameters for `storybook-dark-mode2`.
4
+ * Configuration parameters for `@storybook-community/storybook-dark-mode`.
5
5
  */
6
6
  export interface DarkModeParam {
7
7
  /** The current theme ('dark' or 'light') */
@@ -34,7 +34,7 @@ export interface DarkModeParam {
34
34
  stylePreview?: boolean | undefined;
35
35
  }
36
36
  /**
37
- * Defines `storybook-dark-mode2` parameters for Storybook stories.
37
+ * Defines `@storybook-community/storybook-dark-mode` parameters for Storybook stories.
38
38
  *
39
39
  * @see https://storybook.js.org/addons/@storybook/addon-themes#dark-mode
40
40
  * @returns An object containing the dark mode parameter configuration
@@ -1,19 +1,3 @@
1
- /**
2
- * Defines `storybook-dark-mode2` 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
1
  export function defineDarkModeParam(darkMode) {
18
- return { darkMode };
2
+ return { darkMode };
19
3
  }
@@ -1,3 +1,3 @@
1
- export * from './dark_mode_docs_container.tsx';
2
- export * from './define_dark_mode.ts';
3
- export * from './with_dark_mode.tsx';
1
+ export * from './dark_mode_docs_container.js';
2
+ export * from './define_dark_mode.js';
3
+ export * from './with_dark_mode.js';
@@ -1,57 +1,46 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { toDOMStyle } from '@just-web/css';
3
- import { useDarkMode } from 'storybook-dark-mode2';
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
- */
1
+ import { toDOMStyle } from "@just-web/css";
2
+ import { useDarkMode } from "@storybook-community/storybook-dark-mode";
10
3
  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
- removeStyle(target, darkMode.lightStyle);
19
- addStyle(target, darkMode.darkStyle);
20
- }
21
- else {
22
- removeStyle(target, darkMode.darkStyle);
23
- addStyle(target, darkMode.lightStyle);
24
- }
25
- if (options?.bodyClass) {
26
- addClass(document.body, options.bodyClass);
27
- }
28
- if (options?.bodyStyle) {
29
- addStyle(document.body, options.bodyStyle);
30
- }
31
- return _jsx(Story, {});
32
- };
33
- }
34
- function addClass(target, className) {
35
- if (!className)
36
- return;
37
- if (typeof className === 'string') {
38
- target.classList.add(...className.split(' '));
4
+ return function darkModeDecorator(Story, { parameters }) {
5
+ const darkMode = parameters.darkMode;
6
+ if (!darkMode) return /* @__PURE__ */ React.createElement(Story, null);
7
+ const dark = useDarkMode();
8
+ const target = darkMode.classTarget === "html" ? document.documentElement : document.body;
9
+ if (dark) {
10
+ removeStyle(target, darkMode.lightStyle);
11
+ addStyle(target, darkMode.darkStyle);
12
+ } else {
13
+ removeStyle(target, darkMode.darkStyle);
14
+ addStyle(target, darkMode.lightStyle);
15
+ }
16
+ if (options?.bodyClass) {
17
+ addClass(document.body, options.bodyClass);
39
18
  }
40
- else if (Array.isArray(className)) {
41
- target.classList.add(...className);
19
+ if (options?.bodyStyle) {
20
+ addStyle(document.body, options.bodyStyle);
42
21
  }
22
+ return /* @__PURE__ */ React.createElement(Story, null);
23
+ };
24
+ }
25
+ function addClass(target, className) {
26
+ if (!className) return;
27
+ if (typeof className === "string") {
28
+ target.classList.add(...className.split(" "));
29
+ } else if (Array.isArray(className)) {
30
+ target.classList.add(...className);
31
+ }
43
32
  }
44
33
  function addStyle(target, style) {
45
- if (style) {
46
- for (const [key, value] of Object.entries(toDOMStyle(style))) {
47
- target.style.setProperty(key, value);
48
- }
34
+ if (style) {
35
+ for (const [key, value] of Object.entries(toDOMStyle(style))) {
36
+ target.style.setProperty(key, value);
49
37
  }
38
+ }
50
39
  }
51
40
  function removeStyle(target, style) {
52
- if (style) {
53
- for (const key of Object.keys(toDOMStyle(style))) {
54
- target.style.removeProperty(key);
55
- }
41
+ if (style) {
42
+ for (const key of Object.keys(toDOMStyle(style))) {
43
+ target.style.removeProperty(key);
56
44
  }
45
+ }
57
46
  }
@@ -1,10 +1,6 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  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
2
  export function whenRunningInTest(decoratorOrHandler) {
7
- return function RunInTest(Story, context) {
8
- return ctx.isRunningInTest() ? (decoratorOrHandler(Story, context) ?? _jsx(Story, {})) : _jsx(Story, {});
9
- };
3
+ return function RunInTest(Story, context) {
4
+ return ctx.isRunningInTest() ? decoratorOrHandler(Story, context) ?? /* @__PURE__ */ React.createElement(Story, null) : /* @__PURE__ */ React.createElement(Story, null);
5
+ };
10
6
  }
@@ -1,4 +1,3 @@
1
- import { isRunningInTest } from '@repobuddy/test';
2
1
  export declare const ctx: {
3
- isRunningInTest: typeof isRunningInTest;
2
+ isRunningInTest: any;
4
3
  };
@@ -1,4 +1,4 @@
1
- import { isRunningInTest } from '@repobuddy/test';
1
+ import { isRunningInTest } from "@repobuddy/test";
2
2
  export const ctx = {
3
- isRunningInTest
3
+ isRunningInTest
4
4
  };