@storybook/addon-themes 10.1.0-alpha.1 → 10.1.0-alpha.10
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/dist/manager.js +27 -44
- package/dist/postinstall.js +6 -6
- package/package.json +3 -3
package/dist/manager.js
CHANGED
|
@@ -14,13 +14,9 @@ import { addons as addons2, types } from "storybook/manager-api";
|
|
|
14
14
|
|
|
15
15
|
// src/theme-switcher.tsx
|
|
16
16
|
import React from "react";
|
|
17
|
-
import {
|
|
17
|
+
import { Button, Select } from "storybook/internal/components";
|
|
18
18
|
import { PaintBrushIcon } from "@storybook/icons";
|
|
19
19
|
import { addons, useAddonState, useChannel, useGlobals, useParameter } from "storybook/manager-api";
|
|
20
|
-
import { styled } from "storybook/theming";
|
|
21
|
-
var IconButtonLabel = styled.div(({ theme }) => ({
|
|
22
|
-
fontSize: theme.typography.size.s2 - 1
|
|
23
|
-
}));
|
|
24
20
|
var hasMultipleThemes = /* @__PURE__ */ __name((themesList) => themesList.length > 1, "hasMultipleThemes");
|
|
25
21
|
var hasTwoThemes = /* @__PURE__ */ __name((themesList) => themesList.length === 2, "hasTwoThemes");
|
|
26
22
|
var ThemeSwitcher = React.memo(/* @__PURE__ */ __name(function ThemeSwitcher2() {
|
|
@@ -49,69 +45,56 @@ var ThemeSwitcher = React.memo(/* @__PURE__ */ __name(function ThemeSwitcher2()
|
|
|
49
45
|
}));
|
|
50
46
|
}
|
|
51
47
|
});
|
|
52
|
-
const
|
|
48
|
+
const currentTheme = selected || themeDefault;
|
|
49
|
+
let ariaLabel = "";
|
|
53
50
|
let label = "";
|
|
51
|
+
let tooltip = "";
|
|
54
52
|
if (isLocked) {
|
|
55
53
|
label = "Story override";
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
ariaLabel = "Theme set by story parameters";
|
|
55
|
+
tooltip = "Theme set by story parameters";
|
|
56
|
+
} else if (currentTheme) {
|
|
57
|
+
label = `${currentTheme} theme`;
|
|
58
|
+
ariaLabel = "Theme";
|
|
59
|
+
tooltip = "Change theme";
|
|
58
60
|
}
|
|
59
61
|
if (disable) {
|
|
60
62
|
return null;
|
|
61
63
|
}
|
|
62
64
|
if (hasTwoThemes(themesList)) {
|
|
63
|
-
const currentTheme = selected || themeDefault;
|
|
64
65
|
const alternateTheme = themesList.find((theme) => theme !== currentTheme);
|
|
65
66
|
return React.createElement(
|
|
66
|
-
|
|
67
|
+
Button,
|
|
67
68
|
{
|
|
69
|
+
ariaLabel,
|
|
70
|
+
tooltip,
|
|
71
|
+
variant: "ghost",
|
|
68
72
|
disabled: isLocked,
|
|
69
73
|
key: THEME_SWITCHER_ID,
|
|
70
|
-
active: !themeOverride,
|
|
71
|
-
title: "Theme",
|
|
72
74
|
onClick: () => {
|
|
73
75
|
updateGlobals({ theme: alternateTheme });
|
|
74
76
|
}
|
|
75
77
|
},
|
|
76
78
|
React.createElement(PaintBrushIcon, null),
|
|
77
|
-
label
|
|
79
|
+
label
|
|
78
80
|
);
|
|
79
81
|
}
|
|
80
82
|
if (hasMultipleThemes(themesList)) {
|
|
81
83
|
return React.createElement(
|
|
82
|
-
|
|
84
|
+
Select,
|
|
83
85
|
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
active: selected === theme,
|
|
95
|
-
onClick: /* @__PURE__ */ __name(() => {
|
|
96
|
-
updateGlobals({ theme });
|
|
97
|
-
onHide();
|
|
98
|
-
}, "onClick")
|
|
99
|
-
}))
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
}
|
|
86
|
+
icon: React.createElement(PaintBrushIcon, null),
|
|
87
|
+
ariaLabel,
|
|
88
|
+
disabled: isLocked,
|
|
89
|
+
key: THEME_SWITCHER_ID,
|
|
90
|
+
defaultOptions: currentTheme,
|
|
91
|
+
options: themesList.map((theme) => ({
|
|
92
|
+
title: theme,
|
|
93
|
+
value: theme
|
|
94
|
+
})),
|
|
95
|
+
onSelect: (selected2) => updateGlobals({ theme: selected2 })
|
|
103
96
|
},
|
|
104
|
-
|
|
105
|
-
IconButton,
|
|
106
|
-
{
|
|
107
|
-
key: THEME_SWITCHER_ID,
|
|
108
|
-
active: !themeOverride,
|
|
109
|
-
title: "Theme",
|
|
110
|
-
disabled: isLocked
|
|
111
|
-
},
|
|
112
|
-
React.createElement(PaintBrushIcon, null),
|
|
113
|
-
label && React.createElement(IconButtonLabel, null, label)
|
|
114
|
-
)
|
|
97
|
+
label
|
|
115
98
|
);
|
|
116
99
|
}
|
|
117
100
|
return null;
|
package/dist/postinstall.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_tw4bunchjjq from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_tw4bunchjjq from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_tw4bunchjjq from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_tw4bunchjjq.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_tw4bunchjjq.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_tw4bunchjjq.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-themes",
|
|
3
|
-
"version": "10.1.0-alpha.
|
|
3
|
+
"version": "10.1.0-alpha.10",
|
|
4
4
|
"description": "Storybook Themes addon: Switch between themes from the toolbar",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"typescript": "^5.8.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"storybook": "^10.1.0-alpha.
|
|
70
|
+
"storybook": "^10.1.0-alpha.10"
|
|
71
71
|
},
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae17",
|
|
76
76
|
"storybook": {
|
|
77
77
|
"displayName": "Themes",
|
|
78
78
|
"unsupportedFrameworks": [
|