@repobuddy/storybook 1.0.0 → 1.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.
|
@@ -15,14 +15,10 @@ export function withDarkMode(options) {
|
|
|
15
15
|
const dark = useDarkMode();
|
|
16
16
|
const target = darkMode.classTarget === 'html' ? document.documentElement : document.body;
|
|
17
17
|
if (dark) {
|
|
18
|
-
removeClass(target, darkMode.lightClass);
|
|
19
|
-
addClass(target, darkMode.darkClass);
|
|
20
18
|
removeStyle(target, darkMode.lightStyle);
|
|
21
19
|
addStyle(target, darkMode.darkStyle);
|
|
22
20
|
}
|
|
23
21
|
else {
|
|
24
|
-
removeClass(target, darkMode.darkClass);
|
|
25
|
-
addClass(target, darkMode.lightClass);
|
|
26
22
|
removeStyle(target, darkMode.darkStyle);
|
|
27
23
|
addStyle(target, darkMode.lightStyle);
|
|
28
24
|
}
|
|
@@ -45,16 +41,6 @@ function addClass(target, className) {
|
|
|
45
41
|
target.classList.add(...className);
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
|
-
function removeClass(target, className) {
|
|
49
|
-
if (!className)
|
|
50
|
-
return;
|
|
51
|
-
if (typeof className === 'string') {
|
|
52
|
-
target.classList.remove(...className.split(' '));
|
|
53
|
-
}
|
|
54
|
-
else if (Array.isArray(className)) {
|
|
55
|
-
target.classList.remove(...className);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
44
|
function addStyle(target, style) {
|
|
59
45
|
if (style) {
|
|
60
46
|
for (const [key, value] of Object.entries(toDOMStyle(style))) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"@vitest/browser": "^3.1.2",
|
|
58
58
|
"@vitest/coverage-v8": "^3.1.2",
|
|
59
59
|
"dedent": "^1.6.0",
|
|
60
|
-
"react": "^
|
|
61
|
-
"react-dom": "^
|
|
60
|
+
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
62
|
"rimraf": "^6.0.1",
|
|
63
63
|
"storybook": "^9.0.1",
|
|
64
64
|
"storybook-addon-tag-badges": "^2.0.0",
|
|
65
|
-
"storybook-addon-vis": "^1.1
|
|
65
|
+
"storybook-addon-vis": "^2.1.1",
|
|
66
66
|
"storybook-dark-mode2": "^5.0.2",
|
|
67
67
|
"tailwindcss": "^4.1.5",
|
|
68
68
|
"vite": "^6.3.4",
|
|
@@ -87,6 +87,9 @@
|
|
|
87
87
|
"sb": "storybook dev -p 6006",
|
|
88
88
|
"sb:build": "storybook build",
|
|
89
89
|
"test": "vitest run",
|
|
90
|
+
"test:dark": "vitest run --config=vitest.config.dark.ts",
|
|
91
|
+
"test:light": "vitest run --config=vitest.config.light.ts",
|
|
92
|
+
"test:theme": "vitest run --config=vitest.config.theme.ts",
|
|
90
93
|
"w": "vitest"
|
|
91
94
|
}
|
|
92
95
|
}
|
|
@@ -35,13 +35,9 @@ export function withDarkMode(
|
|
|
35
35
|
const dark = useDarkMode()
|
|
36
36
|
const target = darkMode.classTarget === 'html' ? document.documentElement : document.body
|
|
37
37
|
if (dark) {
|
|
38
|
-
removeClass(target, darkMode.lightClass)
|
|
39
|
-
addClass(target, darkMode.darkClass)
|
|
40
38
|
removeStyle(target, darkMode.lightStyle)
|
|
41
39
|
addStyle(target, darkMode.darkStyle)
|
|
42
40
|
} else {
|
|
43
|
-
removeClass(target, darkMode.darkClass)
|
|
44
|
-
addClass(target, darkMode.lightClass)
|
|
45
41
|
removeStyle(target, darkMode.darkStyle)
|
|
46
42
|
addStyle(target, darkMode.lightStyle)
|
|
47
43
|
}
|
|
@@ -64,15 +60,6 @@ function addClass(target: HTMLElement, className: string | string[] | undefined)
|
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
62
|
|
|
67
|
-
function removeClass(target: HTMLElement, className: string | string[] | undefined) {
|
|
68
|
-
if (!className) return
|
|
69
|
-
if (typeof className === 'string') {
|
|
70
|
-
target.classList.remove(...className.split(' '))
|
|
71
|
-
} else if (Array.isArray(className)) {
|
|
72
|
-
target.classList.remove(...className)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
63
|
function addStyle(target: HTMLElement, style: CSSProperties | undefined) {
|
|
77
64
|
if (style) {
|
|
78
65
|
for (const [key, value] of Object.entries(toDOMStyle(style)!)) {
|