@vueless/storybook 0.0.75-beta.10 → 0.0.75-beta.12
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/.storybook/addons/storybook-dark-mode/Tool.tsx +270 -0
- package/.storybook/addons/storybook-dark-mode/constants.ts +2 -0
- package/.storybook/addons/storybook-dark-mode/index.tsx +20 -0
- package/.storybook/addons/storybook-dark-mode/preset/manager.tsx +26 -0
- package/.storybook/decorators/vue3SourceDecorator.js +1 -1
- package/.storybook/index.css +2 -0
- package/.storybook/main.js +4 -3
- package/.storybook/manager-head.html +177 -177
- package/.storybook/manager.js +1 -1
- package/.storybook/preview.js +1 -1
- package/.storybook/themes/themeDark.js +1 -1
- package/.storybook/themes/themeLight.js +1 -1
- package/.storybook/themes/themeLightDocs.js +1 -1
- package/.storybook/vite.config.js +4 -4
- package/package.json +8 -14
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { global } from "@storybook/global";
|
|
3
|
+
import { themes, ThemeVars } from "storybook/theming";
|
|
4
|
+
import { IconButton } from "storybook/internal/components";
|
|
5
|
+
import { MoonIcon, SunIcon } from "@storybook/icons";
|
|
6
|
+
import {
|
|
7
|
+
STORY_CHANGED,
|
|
8
|
+
SET_STORIES,
|
|
9
|
+
DOCS_RENDERED,
|
|
10
|
+
} from "storybook/internal/core-events";
|
|
11
|
+
import { API, useParameter } from "storybook/manager-api";
|
|
12
|
+
import equal from "fast-deep-equal";
|
|
13
|
+
import { DARK_MODE_EVENT_NAME, UPDATE_DARK_MODE_EVENT_NAME } from "./constants";
|
|
14
|
+
|
|
15
|
+
const { document, window } = global as { document: Document; window: Window };
|
|
16
|
+
const modes = ["light", "dark"] as const;
|
|
17
|
+
type Mode = (typeof modes)[number];
|
|
18
|
+
|
|
19
|
+
interface DarkModeStore {
|
|
20
|
+
/** The class target in the preview iframe */
|
|
21
|
+
classTarget: string;
|
|
22
|
+
/** The current mode the storybook is set to */
|
|
23
|
+
current: Mode;
|
|
24
|
+
/** The dark theme for storybook */
|
|
25
|
+
dark: ThemeVars;
|
|
26
|
+
/** The dark class name for the preview iframe */
|
|
27
|
+
darkClass: string | string[];
|
|
28
|
+
/** The light theme for storybook */
|
|
29
|
+
light: ThemeVars;
|
|
30
|
+
/** The light class name for the preview iframe */
|
|
31
|
+
lightClass: string | string[];
|
|
32
|
+
/** Apply mode to iframe */
|
|
33
|
+
stylePreview: boolean;
|
|
34
|
+
/** Persist if the user has set the theme */
|
|
35
|
+
userHasExplicitlySetTheTheme: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const STORAGE_KEY = "sb-addon-themes-3";
|
|
39
|
+
export const prefersDark = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
40
|
+
|
|
41
|
+
const defaultParams: Required<Omit<DarkModeStore, "current">> = {
|
|
42
|
+
classTarget: "body",
|
|
43
|
+
dark: themes.dark,
|
|
44
|
+
darkClass: ["dark"],
|
|
45
|
+
light: themes.light,
|
|
46
|
+
lightClass: ["light"],
|
|
47
|
+
stylePreview: false,
|
|
48
|
+
userHasExplicitlySetTheTheme: false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Persist the dark mode settings in localStorage */
|
|
52
|
+
export const updateStore = (newStore: DarkModeStore) => {
|
|
53
|
+
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(newStore));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** Add the light/dark class to an element */
|
|
57
|
+
const toggleDarkClass = (
|
|
58
|
+
el: Element,
|
|
59
|
+
{
|
|
60
|
+
current,
|
|
61
|
+
darkClass = defaultParams.darkClass,
|
|
62
|
+
lightClass = defaultParams.lightClass,
|
|
63
|
+
}: DarkModeStore,
|
|
64
|
+
) => {
|
|
65
|
+
if (current === "dark") {
|
|
66
|
+
el.classList.remove(...arrayify(lightClass));
|
|
67
|
+
el.classList.add(...arrayify(darkClass));
|
|
68
|
+
} else {
|
|
69
|
+
el.classList.remove(...arrayify(darkClass));
|
|
70
|
+
el.classList.add(...arrayify(lightClass));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Coerce a string to a single item array, or return an array as-is */
|
|
75
|
+
const arrayify = (classes: string | string[]): string[] => {
|
|
76
|
+
const arr: string[] = [];
|
|
77
|
+
return arr.concat(classes).map((item) => item);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Update the preview iframe class */
|
|
81
|
+
const updatePreview = (store: DarkModeStore) => {
|
|
82
|
+
const iframe = document.getElementById(
|
|
83
|
+
"storybook-preview-iframe",
|
|
84
|
+
) as HTMLIFrameElement;
|
|
85
|
+
|
|
86
|
+
if (!iframe) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const iframeDocument =
|
|
91
|
+
iframe.contentDocument || iframe.contentWindow?.document;
|
|
92
|
+
const target = iframeDocument?.querySelector<HTMLElement>(store.classTarget);
|
|
93
|
+
|
|
94
|
+
if (!target) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
toggleDarkClass(target, store);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** Update the manager iframe class */
|
|
102
|
+
const updateManager = (store: DarkModeStore) => {
|
|
103
|
+
const manager = document.querySelector(store.classTarget);
|
|
104
|
+
|
|
105
|
+
if (!manager) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
toggleDarkClass(manager, store);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** Update changed dark mode settings and persist to localStorage */
|
|
113
|
+
export const store = (
|
|
114
|
+
userTheme: Partial<DarkModeStore> = {},
|
|
115
|
+
): DarkModeStore => {
|
|
116
|
+
const storedItem = window.localStorage.getItem(STORAGE_KEY);
|
|
117
|
+
|
|
118
|
+
if (typeof storedItem === "string") {
|
|
119
|
+
const stored = JSON.parse(storedItem) as DarkModeStore;
|
|
120
|
+
|
|
121
|
+
if (userTheme) {
|
|
122
|
+
if (userTheme.dark && !equal(stored.dark, userTheme.dark)) {
|
|
123
|
+
stored.dark = userTheme.dark;
|
|
124
|
+
updateStore(stored);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (userTheme.light && !equal(stored.light, userTheme.light)) {
|
|
128
|
+
stored.light = userTheme.light;
|
|
129
|
+
updateStore(stored);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return stored;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return { ...defaultParams, ...userTheme } as DarkModeStore;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// On initial load, set the dark mode class on the manager
|
|
140
|
+
// This is needed if you're using mostly CSS overrides to styles the storybook
|
|
141
|
+
// Otherwise the default theme is set in src/preset/manager.tsx
|
|
142
|
+
updateManager(store());
|
|
143
|
+
|
|
144
|
+
interface DarkModeProps {
|
|
145
|
+
/** The storybook API */
|
|
146
|
+
api: API;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A toolbar icon to toggle between dark and light themes in storybook */
|
|
150
|
+
export function DarkMode({ api }: DarkModeProps) {
|
|
151
|
+
const [isDark, setDark] = React.useState(prefersDark.matches);
|
|
152
|
+
const darkModeParams = useParameter<Partial<DarkModeStore>>("darkMode", {});
|
|
153
|
+
const { current: defaultMode, stylePreview, ...params } = darkModeParams;
|
|
154
|
+
const channel = api.getChannel();
|
|
155
|
+
// Save custom themes on init
|
|
156
|
+
const userHasExplicitlySetTheTheme = React.useMemo(
|
|
157
|
+
() => store(params).userHasExplicitlySetTheTheme,
|
|
158
|
+
[params],
|
|
159
|
+
);
|
|
160
|
+
/** Set the theme in storybook, update the local state, and emit an event */
|
|
161
|
+
const setMode = React.useCallback(
|
|
162
|
+
(mode: Mode) => {
|
|
163
|
+
const currentStore = store();
|
|
164
|
+
api.setOptions({ theme: currentStore[mode] });
|
|
165
|
+
setDark(mode === "dark");
|
|
166
|
+
api.getChannel().emit(DARK_MODE_EVENT_NAME, mode === "dark");
|
|
167
|
+
updateManager(currentStore);
|
|
168
|
+
if (stylePreview) {
|
|
169
|
+
updatePreview(currentStore);
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
[api, stylePreview],
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
/** Update the theme settings in localStorage, react, and storybook */
|
|
176
|
+
const updateMode = React.useCallback(
|
|
177
|
+
(mode?: Mode) => {
|
|
178
|
+
const currentStore = store();
|
|
179
|
+
const current =
|
|
180
|
+
mode || (currentStore.current === "dark" ? "light" : "dark");
|
|
181
|
+
updateStore({ ...currentStore, current });
|
|
182
|
+
setMode(current);
|
|
183
|
+
},
|
|
184
|
+
[setMode],
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
/** Update the theme based on the color preference */
|
|
188
|
+
function prefersDarkUpdate(event: MediaQueryListEvent) {
|
|
189
|
+
if (userHasExplicitlySetTheTheme || defaultMode) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
updateMode(event.matches ? "dark" : "light");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Render the current theme */
|
|
197
|
+
const renderTheme = React.useCallback(() => {
|
|
198
|
+
const { current = "light" } = store();
|
|
199
|
+
setMode(current);
|
|
200
|
+
}, [setMode]);
|
|
201
|
+
|
|
202
|
+
/** Handle the user event and side effects */
|
|
203
|
+
const handleIconClick = () => {
|
|
204
|
+
updateMode();
|
|
205
|
+
const currentStore = store();
|
|
206
|
+
updateStore({ ...currentStore, userHasExplicitlySetTheTheme: true });
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/** When storybook params change update the stored themes */
|
|
210
|
+
React.useEffect(() => {
|
|
211
|
+
const currentStore = store();
|
|
212
|
+
// Ensure we use the stores `current` value first to persist
|
|
213
|
+
// themeing between page loads and story changes.
|
|
214
|
+
updateStore({
|
|
215
|
+
...currentStore,
|
|
216
|
+
...darkModeParams,
|
|
217
|
+
current: currentStore.current || darkModeParams.current,
|
|
218
|
+
});
|
|
219
|
+
renderTheme();
|
|
220
|
+
}, [darkModeParams, renderTheme]);
|
|
221
|
+
React.useEffect(() => {
|
|
222
|
+
channel.on(STORY_CHANGED, renderTheme);
|
|
223
|
+
channel.on(SET_STORIES, renderTheme);
|
|
224
|
+
channel.on(DOCS_RENDERED, renderTheme);
|
|
225
|
+
prefersDark.addListener(prefersDarkUpdate);
|
|
226
|
+
return () => {
|
|
227
|
+
channel.removeListener(STORY_CHANGED, renderTheme);
|
|
228
|
+
channel.removeListener(SET_STORIES, renderTheme);
|
|
229
|
+
channel.removeListener(DOCS_RENDERED, renderTheme);
|
|
230
|
+
prefersDark.removeListener(prefersDarkUpdate);
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
React.useEffect(() => {
|
|
234
|
+
channel.on(UPDATE_DARK_MODE_EVENT_NAME, updateMode);
|
|
235
|
+
return () => {
|
|
236
|
+
channel.removeListener(UPDATE_DARK_MODE_EVENT_NAME, updateMode);
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
// Storybook's first render doesn't have the global user params loaded so we
|
|
240
|
+
// need the effect to run whenever defaultMode is updated
|
|
241
|
+
React.useEffect(() => {
|
|
242
|
+
// If a users has set the mode this is respected
|
|
243
|
+
if (userHasExplicitlySetTheTheme) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (defaultMode) {
|
|
248
|
+
updateMode(defaultMode);
|
|
249
|
+
} else if (prefersDark.matches) {
|
|
250
|
+
updateMode("dark");
|
|
251
|
+
}
|
|
252
|
+
}, [defaultMode, updateMode, userHasExplicitlySetTheTheme]);
|
|
253
|
+
return (
|
|
254
|
+
<IconButton
|
|
255
|
+
key="dark-mode"
|
|
256
|
+
title={
|
|
257
|
+
isDark ? "Change theme to light mode" : "Change theme to dark mode"
|
|
258
|
+
}
|
|
259
|
+
onClick={handleIconClick}
|
|
260
|
+
>
|
|
261
|
+
{isDark ? (
|
|
262
|
+
<SunIcon aria-hidden="true" />
|
|
263
|
+
) : (
|
|
264
|
+
<MoonIcon aria-hidden="true" />
|
|
265
|
+
)}
|
|
266
|
+
</IconButton>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export default DarkMode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { addons, useState, useEffect } from "storybook/preview-api";
|
|
2
|
+
import { DARK_MODE_EVENT_NAME } from "./constants";
|
|
3
|
+
import { store } from "./Tool";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns the current state of storybook's dark-mode
|
|
7
|
+
*/
|
|
8
|
+
export function useDarkMode(): boolean {
|
|
9
|
+
const [isDark, setIsDark] = useState(store().current === "dark");
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const chan = addons.getChannel();
|
|
13
|
+
chan.on(DARK_MODE_EVENT_NAME, setIsDark);
|
|
14
|
+
return () => chan.off(DARK_MODE_EVENT_NAME, setIsDark);
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
return isDark;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export * from "./constants";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { addons } from "storybook/manager-api";
|
|
2
|
+
import { Addon_TypesEnum } from "storybook/internal/types";
|
|
3
|
+
import { themes } from "storybook/theming";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
|
|
6
|
+
import Tool, { prefersDark, store } from "../Tool";
|
|
7
|
+
|
|
8
|
+
const currentStore = store();
|
|
9
|
+
const currentTheme =
|
|
10
|
+
currentStore.current || (prefersDark.matches && "dark") || "light";
|
|
11
|
+
|
|
12
|
+
addons.setConfig({
|
|
13
|
+
theme: {
|
|
14
|
+
...themes[currentTheme],
|
|
15
|
+
...currentStore[currentTheme],
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
addons.register("storybook/dark-mode", (api) => {
|
|
20
|
+
addons.add("storybook/dark-mode", {
|
|
21
|
+
title: "dark mode",
|
|
22
|
+
type: Addon_TypesEnum.TOOL,
|
|
23
|
+
match: ({ viewMode }) => viewMode === "story" || viewMode === "docs",
|
|
24
|
+
render: () => <Tool api={api} />,
|
|
25
|
+
});
|
|
26
|
+
});
|
package/.storybook/index.css
CHANGED
|
@@ -267,10 +267,12 @@ body {
|
|
|
267
267
|
|
|
268
268
|
.dark .sb-anchor > p > a {
|
|
269
269
|
color: #4ade80; /* text-green-400 */
|
|
270
|
+
text-decoration: underline dashed #4ade80;
|
|
270
271
|
}
|
|
271
272
|
|
|
272
273
|
.light .sb-anchor > p > a {
|
|
273
274
|
color: #16a34a; /* text-green-600 */
|
|
275
|
+
text-decoration: underline dashed #16a34a;
|
|
274
276
|
}
|
|
275
277
|
|
|
276
278
|
.sb-bar,
|
package/.storybook/main.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
|
|
1
3
|
/** @type { import('@storybook/vue3-vite').StorybookConfig } */
|
|
2
4
|
export default {
|
|
3
5
|
stories: [
|
|
@@ -8,10 +10,9 @@ export default {
|
|
|
8
10
|
// "../src/**/docs.mdx",
|
|
9
11
|
],
|
|
10
12
|
addons: [
|
|
13
|
+
"@storybook/addon-docs",
|
|
11
14
|
"@storybook/addon-links",
|
|
12
|
-
"
|
|
13
|
-
"@storybook/addon-interactions",
|
|
14
|
-
"storybook-dark-mode",
|
|
15
|
+
resolve(__dirname, "./addons/storybook-dark-mode/preset/manager.tsx"),
|
|
15
16
|
"@storybook/addon-themes",
|
|
16
17
|
],
|
|
17
18
|
framework: {
|
|
@@ -23,183 +23,183 @@ Custom dark mode related vueless loader.
|
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
25
|
<style>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
26
|
+
/* -------------------- Prevent showing users default storybook theme styles -------------------- */
|
|
27
|
+
|
|
28
|
+
html.dark {
|
|
29
|
+
background: #111827;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#root {
|
|
33
|
+
visibility: hidden;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#sb-vueless-loader {
|
|
37
|
+
top: 0;
|
|
38
|
+
left: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
position: fixed;
|
|
43
|
+
background: inherit;
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
z-index: 999;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.light #sb-vueless-loader {
|
|
50
|
+
background: #f1f5f9;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.dark #sb-vueless-loader {
|
|
54
|
+
background: #111827;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sb-vueless-loader-img-dark,
|
|
58
|
+
.sb-vueless-loader-img-light {
|
|
59
|
+
display: none;
|
|
60
|
+
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.light .sb-vueless-loader-img-light {
|
|
64
|
+
display: block;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.dark .sb-vueless-loader-img-dark {
|
|
68
|
+
display: block;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@keyframes pulse {
|
|
72
|
+
0%, 100% {
|
|
73
|
+
opacity: 1;
|
|
74
|
+
}
|
|
75
|
+
50% {
|
|
76
|
+
opacity: .5;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* -------------------- Storybook config tooltip -------------------- */
|
|
81
|
+
|
|
82
|
+
div[data-testid="tooltip"] {
|
|
83
|
+
border-radius: 8px;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
div[data-testid="tooltip"] a[id]:hover,
|
|
88
|
+
div[data-testid="tooltip"] button[id]:hover {
|
|
89
|
+
background-color: rgb(17 24 39 / 5%) !important;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.dark div[data-testid="tooltip"] a[id]:hover,
|
|
93
|
+
.dark div[data-testid="tooltip"] button[id]:hover {
|
|
94
|
+
background-color: rgb(255 255 255 / 5%) !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* -------------------- Storybook sidebar -------------------- */
|
|
98
|
+
|
|
99
|
+
.dark .sidebar-container {
|
|
100
|
+
background: #020713;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sidebar-header img {
|
|
104
|
+
width: 150px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sidebar-header a:focus {
|
|
108
|
+
border: 1px solid transparent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.sidebar-item {
|
|
112
|
+
border-radius: 6px !important;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.dark .sidebar-item:hover {
|
|
116
|
+
background: #101828 !important;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.dark .sidebar-item[data-selected="true"],
|
|
120
|
+
.dark .sidebar-item[data-selected="true"]:hover {
|
|
121
|
+
background: #1f2937 !important;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.search-field,
|
|
125
|
+
.search-result-item {
|
|
126
|
+
border-radius: 8px !important;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.sidebar-item,
|
|
130
|
+
.search-result-item {
|
|
131
|
+
text-transform: capitalize;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.light .sidebar-item svg[type="component"],
|
|
135
|
+
.light .search-result-item svg[type="component"],
|
|
136
|
+
.dark .search-result-item mark {
|
|
137
|
+
color: #10b981;
|
|
138
|
+
font-weight: 600;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.dark .sidebar-item svg[type="component"],
|
|
142
|
+
.dark .search-result-item svg[type="component"],
|
|
143
|
+
.light .search-result-item mark {
|
|
144
|
+
color: #059669;
|
|
145
|
+
font-weight: 600;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.light .sidebar-item svg[type="document"],
|
|
149
|
+
.light .sidebar-item svg[type="story"],
|
|
150
|
+
.light .search-result-item svg[type="document"],
|
|
151
|
+
.light .search-result-item svg[type="story"] {
|
|
152
|
+
color: #9ca3af;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.dark .sidebar-item svg[type="document"],
|
|
156
|
+
.dark .sidebar-item svg[type="story"],
|
|
157
|
+
.dark .search-result-item svg[type="document"],
|
|
158
|
+
.dark .search-result-item svg[type="story"] {
|
|
159
|
+
color: #4b5563;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.light .search-result-item--label {
|
|
163
|
+
color: #6b7280; /* text-gray-600 */
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.dark .search-result-item--label {
|
|
167
|
+
color: #a8abb0; /* text-gray-400 */
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
#sidebar-bottom-wrapper {
|
|
171
|
+
display: none;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* -------------------- Storybook args -------------------- */
|
|
175
|
+
|
|
176
|
+
.dark,
|
|
177
|
+
.dark #panel-tab-content div,
|
|
178
|
+
.dark .docblock-argstable-body > tr > td {
|
|
179
|
+
background: #030712 !important;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.light,
|
|
183
|
+
.light #panel-tab-content div,
|
|
184
|
+
.light .docblock-argstable-body > tr > td {
|
|
185
|
+
background: #f9fafb !important;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.dark .docblock-argstable-head > tr {
|
|
189
|
+
background: #1e293b !important;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.dark .docblock-argstable-body tr > td textarea,
|
|
193
|
+
.dark .docblock-argstable-body tr > td select,
|
|
194
|
+
.dark .docblock-argstable-body tr > td:last-child button:not([tabindex="-1"]) {
|
|
195
|
+
background: #111827;
|
|
196
|
+
border: solid 1px #1f2937;
|
|
197
|
+
box-shadow: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.light .docblock-argstable-body tr > td:last-child button:not([tabindex="-1"]) {
|
|
201
|
+
background: white;
|
|
202
|
+
}
|
|
203
203
|
</style>
|
|
204
204
|
|
|
205
205
|
<script>
|
package/.storybook/manager.js
CHANGED
package/.storybook/preview.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Vueless, TailwindCSS } from "vueless/plugin-vite";
|
|
|
6
6
|
import { STORYBOOK_ENV } from "vueless/constants.js";
|
|
7
7
|
|
|
8
8
|
export default defineConfig({
|
|
9
|
-
plugins: [Vue(), TailwindCSS(), Vueless({ env: STORYBOOK_ENV
|
|
9
|
+
plugins: [Vue(), TailwindCSS(), Vueless({ env: STORYBOOK_ENV })],
|
|
10
10
|
optimizeDeps: {
|
|
11
11
|
include: [
|
|
12
12
|
"cva",
|
|
@@ -14,10 +14,10 @@ export default defineConfig({
|
|
|
14
14
|
"@tailwindcss/forms",
|
|
15
15
|
"prettier2",
|
|
16
16
|
"prettier2/parser-html",
|
|
17
|
-
"@storybook/blocks",
|
|
18
|
-
"
|
|
17
|
+
"@storybook/addon-docs/blocks",
|
|
18
|
+
"storybook/theming/create",
|
|
19
19
|
"@storybook/addon-themes",
|
|
20
|
-
"@storybook/
|
|
20
|
+
"@storybook/vue3-vite",
|
|
21
21
|
],
|
|
22
22
|
},
|
|
23
23
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueless/storybook",
|
|
3
|
-
"version": "0.0.75-beta.
|
|
3
|
+
"version": "0.0.75-beta.12",
|
|
4
4
|
"description": "Simplifies Storybook configuration for Vueless UI library.",
|
|
5
5
|
"homepage": "https://vueless.com",
|
|
6
6
|
"author": "Johnny Grid",
|
|
@@ -26,23 +26,16 @@
|
|
|
26
26
|
"release:major": "release-it major --ci --npm.publish --git.tag --github.release"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@storybook/addon-
|
|
30
|
-
"@storybook/addon-
|
|
31
|
-
"@storybook/addon-
|
|
32
|
-
"@storybook/
|
|
33
|
-
"@storybook/blocks": "^8.6.14",
|
|
34
|
-
"@storybook/manager-api": "^8.6.14",
|
|
35
|
-
"@storybook/test": "^8.6.14",
|
|
36
|
-
"@storybook/theming": "^8.6.14",
|
|
37
|
-
"@storybook/vue3": "^8.6.14",
|
|
38
|
-
"@storybook/vue3-vite": "^8.6.14",
|
|
29
|
+
"@storybook/addon-docs": "9.0.4",
|
|
30
|
+
"@storybook/addon-links": "9.0.4",
|
|
31
|
+
"@storybook/addon-themes": "9.0.4",
|
|
32
|
+
"@storybook/vue3-vite": "9.0.4",
|
|
39
33
|
"chokidar": "^4.0.3",
|
|
40
34
|
"esbuild": "^0.25.5",
|
|
41
35
|
"globby": "^14.1.0",
|
|
42
36
|
"mkdirp": "^3.0.1",
|
|
43
37
|
"prettier2": "npm:prettier@2.8.8",
|
|
44
|
-
"storybook": "
|
|
45
|
-
"storybook-dark-mode": "^4.0.2",
|
|
38
|
+
"storybook": "9.0.4",
|
|
46
39
|
"vue-docgen-api": "^4.79.2"
|
|
47
40
|
},
|
|
48
41
|
"devDependencies": {
|
|
@@ -62,7 +55,8 @@
|
|
|
62
55
|
"vue-docgen-api": {
|
|
63
56
|
"vue": "latest",
|
|
64
57
|
"vue-template-compiler": "latest"
|
|
65
|
-
}
|
|
58
|
+
},
|
|
59
|
+
"storybook": "$storybook"
|
|
66
60
|
},
|
|
67
61
|
"resolutions": {
|
|
68
62
|
"jackspeak": "2.3.6"
|