@repobuddy/storybook 1.0.1 → 2.0.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/cjs/components/show_html.d.ts +16 -0
- package/cjs/components/show_html.js +29 -0
- package/cjs/decorators/show_doc_source.d.ts +6 -0
- package/cjs/decorators/show_doc_source.js +38 -0
- package/cjs/index.d.ts +13 -0
- package/cjs/index.js +137 -0
- package/cjs/manager/brand_title.d.ts +35 -0
- package/cjs/manager/brand_title.js +12 -0
- package/cjs/manager/index.d.ts +1 -0
- package/cjs/manager/index.js +16 -0
- package/cjs/parameters/define_actions_param.d.ts +24 -0
- package/cjs/parameters/define_actions_param.js +11 -0
- package/cjs/parameters/define_backgrounds_param.d.ts +45 -0
- package/cjs/parameters/define_backgrounds_param.js +10 -0
- package/cjs/parameters/define_docs_param.d.ts +217 -0
- package/cjs/parameters/define_docs_param.js +11 -0
- package/cjs/parameters/define_layout_param.d.ts +20 -0
- package/cjs/parameters/define_layout_param.js +10 -0
- package/cjs/parameters/define_parameters.d.ts +39 -0
- package/cjs/parameters/define_parameters.js +9 -0
- package/cjs/parameters/define_test_param.d.ts +34 -0
- package/cjs/parameters/define_test_param.js +11 -0
- package/cjs/parameters/define_viewport_param.d.ts +78 -0
- package/cjs/parameters/define_viewport_param.js +11 -0
- package/cjs/parameters/story_sort.d.ts +27 -0
- package/cjs/parameters/story_sort.js +1 -0
- package/cjs/storybook-addon-tag-badges/index.d.ts +2 -0
- package/cjs/storybook-addon-tag-badges/index.js +16 -0
- package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +41 -0
- package/cjs/storybook-addon-tag-badges/tag_badges.js +179 -0
- package/cjs/storybook-addon-tag-badges/types.d.ts +9 -0
- package/cjs/storybook-addon-tag-badges/types.js +1 -0
- package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +26 -0
- package/cjs/storybook-dark-mode/dark_mode_docs_container.js +23 -0
- package/cjs/storybook-dark-mode/define_dark_mode.d.ts +54 -0
- package/cjs/storybook-dark-mode/define_dark_mode.js +11 -0
- package/cjs/storybook-dark-mode/index.d.ts +3 -0
- package/cjs/storybook-dark-mode/index.js +38 -0
- package/cjs/storybook-dark-mode/with_dark_mode.d.ts +22 -0
- package/cjs/storybook-dark-mode/with_dark_mode.js +54 -0
- package/cjs/testing/decorators/when_running_in_test.d.ts +5 -0
- package/cjs/testing/decorators/when_running_in_test.js +12 -0
- package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +3 -0
- package/cjs/testing/decorators/when_running_in_text.ctx.js +10 -0
- package/cjs/types.d.ts +41 -0
- package/cjs/types.js +1 -0
- package/cjs/variants/index.d.ts +1 -0
- package/cjs/variants/index.js +8 -0
- package/cjs/variants/package.json +3 -0
- package/cjs/variants/preset.d.ts +11 -0
- package/cjs/variants/preset.js +3 -0
- package/esm/components/show_html.d.ts +1 -1
- package/esm/components/show_html.js +17 -26
- package/esm/decorators/show_doc_source.js +26 -12
- package/esm/index.d.ts +1 -0
- package/esm/index.js +12 -12
- package/esm/manager/brand_title.js +2 -24
- package/esm/manager/index.js +1 -1
- package/esm/parameters/define_actions_param.js +1 -9
- package/esm/parameters/define_backgrounds_param.js +1 -7
- package/esm/parameters/define_docs_param.d.ts +2 -2
- package/esm/parameters/define_docs_param.js +1 -28
- package/esm/parameters/define_layout_param.js +1 -15
- package/esm/parameters/define_parameters.d.ts +1 -1
- package/esm/parameters/define_parameters.js +1 -30
- package/esm/parameters/define_test_param.js +1 -17
- package/esm/parameters/define_viewport_param.js +1 -28
- package/esm/parameters/story_sort.js +0 -1
- package/esm/storybook-addon-tag-badges/index.js +1 -1
- package/esm/storybook-addon-tag-badges/tag_badges.d.ts +1 -1
- package/esm/storybook-addon-tag-badges/tag_badges.js +153 -172
- package/esm/storybook-addon-tag-badges/types.d.ts +7 -6
- package/esm/storybook-addon-tag-badges/types.js +0 -1
- package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +2 -2
- package/esm/storybook-dark-mode/dark_mode_docs_container.js +19 -30
- package/esm/storybook-dark-mode/define_dark_mode.d.ts +3 -3
- package/esm/storybook-dark-mode/define_dark_mode.js +1 -17
- package/esm/storybook-dark-mode/index.js +3 -3
- package/esm/storybook-dark-mode/with_dark_mode.js +36 -47
- package/esm/testing/decorators/when_running_in_test.js +4 -8
- package/esm/testing/decorators/when_running_in_text.ctx.d.ts +1 -2
- package/esm/testing/decorators/when_running_in_text.ctx.js +2 -2
- package/esm/types.d.ts +41 -0
- package/esm/types.js +0 -0
- package/esm/variants/index.d.ts +1 -0
- package/esm/variants/index.js +2 -0
- package/esm/variants/package.json +3 -0
- package/esm/variants/preset.d.ts +11 -0
- package/esm/variants/preset.js +1 -0
- package/package.json +51 -34
- package/readme.md +3 -3
- package/src/decorators/show_doc_source.tsx +30 -11
- package/src/index.ts +1 -0
- package/src/parameters/define_docs_param.ts +2 -2
- package/src/storybook-addon-tag-badges/tag_badges.ts +1 -1
- package/src/storybook-addon-tag-badges/types.ts +7 -6
- package/src/storybook-dark-mode/dark_mode_docs_container.tsx +2 -2
- package/src/storybook-dark-mode/define_dark_mode.ts +3 -3
- package/src/storybook-dark-mode/with_dark_mode.tsx +2 -1
- package/src/types.ts +51 -0
- package/src/variants/index.ts +3 -0
- package/src/variants/package.json +3 -0
- package/src/variants/preset.ts +22 -0
- package/src/overview.mdx +0 -7
- package/src/storybook-dark-mode/dark_mode_docs_container.mdx +0 -33
|
@@ -1,208 +1,189 @@
|
|
|
1
|
-
import { defaultConfig } from
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
tooltip: 'Editor'
|
|
4
|
+
tags: "editor",
|
|
5
|
+
badge: {
|
|
6
|
+
text: "\u270F\uFE0F",
|
|
7
|
+
style: {
|
|
8
|
+
backgroundColor: "transparent",
|
|
9
|
+
borderColor: "transparent"
|
|
31
10
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
116
|
+
tooltip: "Snapshot Test"
|
|
117
|
+
},
|
|
118
|
+
display: {
|
|
119
|
+
sidebar: false,
|
|
120
|
+
toolbar: ["story"]
|
|
121
|
+
}
|
|
141
122
|
};
|
|
142
123
|
export const unitBadge = {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
131
|
+
tooltip: "Unit Test"
|
|
132
|
+
},
|
|
133
|
+
display: {
|
|
134
|
+
sidebar: false
|
|
135
|
+
}
|
|
155
136
|
};
|
|
156
137
|
export const integrationBadge = {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
145
|
+
tooltip: "Integration Test"
|
|
146
|
+
},
|
|
147
|
+
display: {
|
|
148
|
+
sidebar: false
|
|
149
|
+
}
|
|
169
150
|
};
|
|
170
151
|
export const keyboardBadge = {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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 { ExtendMeta, ExtendStoryObj } from '../types.ts';
|
|
2
3
|
import type { TagNames } from './tag_badges.ts';
|
|
3
|
-
export type Meta<TCmpOrArgs = Args> =
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export type StoryObj<TMetaOrCmpOrArgs = Args> =
|
|
7
|
-
|
|
8
|
-
}
|
|
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
|
|
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
|
|
26
|
+
}>) => import("react").JSX.Element;
|
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DocsContainer } from
|
|
3
|
-
import { useEffect, useState } from
|
|
4
|
-
import {
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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/
|
|
2
|
+
import type { ThemeVars } from 'storybook/theming';
|
|
3
3
|
/**
|
|
4
|
-
* Configuration parameters for
|
|
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
|
|
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
|
-
|
|
2
|
+
return { darkMode };
|
|
19
3
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./dark_mode_docs_container.
|
|
2
|
-
export * from "./define_dark_mode.
|
|
3
|
-
export * from "./with_dark_mode.
|
|
1
|
+
export * from "./dark_mode_docs_container.tsx";
|
|
2
|
+
export * from "./define_dark_mode.ts";
|
|
3
|
+
export * from "./with_dark_mode.tsx";
|
|
@@ -1,57 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 {
|
|
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
|
-
*/
|
|
1
|
+
import { ctx } from "./when_running_in_text.ctx.ts";
|
|
6
2
|
export function whenRunningInTest(decoratorOrHandler) {
|
|
7
|
-
|
|
8
|
-
|
|
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
|
}
|