@storybook/addon-themes 8.3.0-alpha.4 → 8.3.0-alpha.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/manager.js +1 -1
- package/package.json +6 -6
package/dist/manager.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useParameter, useGlobals, addons, useAddonState, useChannel, types } from 'storybook/internal/manager-api';
|
2
2
|
import React from 'react';
|
3
|
-
import { styled } from 'storybook/internal/theming';
|
4
3
|
import { IconButton, WithTooltip, TooltipLinkList } from 'storybook/internal/components';
|
4
|
+
import { styled } from 'storybook/internal/theming';
|
5
5
|
import { PaintBrushIcon } from '@storybook/icons';
|
6
6
|
|
7
7
|
var PARAM_KEY="themes",ADDON_ID=`storybook/${PARAM_KEY}`,GLOBAL_KEY="theme",THEME_SWITCHER_ID=`${ADDON_ID}/theme-switcher`,DEFAULT_ADDON_STATE={themesList:[],themeDefault:void 0},DEFAULT_THEME_PARAMETERS={},THEMING_EVENTS={REGISTER_THEMES:`${ADDON_ID}/REGISTER_THEMES`};var IconButtonLabel=styled.div(({theme})=>({fontSize:theme.typography.size.s2-1})),hasMultipleThemes=themesList=>themesList.length>1,hasTwoThemes=themesList=>themesList.length===2,ThemeSwitcher=React.memo(function(){let{themeOverride,disable}=useParameter(PARAM_KEY,DEFAULT_THEME_PARAMETERS),[{theme:selected},updateGlobals,storyGlobals]=useGlobals(),fromLast=addons.getChannel().last(THEMING_EVENTS.REGISTER_THEMES),initializeThemeState=Object.assign({},DEFAULT_ADDON_STATE,{themesList:fromLast?.[0]?.themes||[],themeDefault:fromLast?.[0]?.defaultTheme||""}),[{themesList,themeDefault},updateState]=useAddonState(THEME_SWITCHER_ID,initializeThemeState),isLocked=GLOBAL_KEY in storyGlobals||!!themeOverride;useChannel({[THEMING_EVENTS.REGISTER_THEMES]:({themes,defaultTheme})=>{updateState(state=>({...state,themesList:themes,themeDefault:defaultTheme}));}});let themeName=selected||themeDefault,label="";if(isLocked?label="Story override":themeName&&(label=`${themeName} theme`),disable)return null;if(hasTwoThemes(themesList)){let currentTheme=selected||themeDefault,alternateTheme=themesList.find(theme=>theme!==currentTheme);return React.createElement(IconButton,{disabled:isLocked,key:THEME_SWITCHER_ID,active:!themeOverride,title:"Theme",onClick:()=>{updateGlobals({theme:alternateTheme});}},React.createElement(PaintBrushIcon,null),label?React.createElement(IconButtonLabel,null,label):null)}return hasMultipleThemes(themesList)?React.createElement(WithTooltip,{placement:"top",trigger:"click",closeOnOutsideClick:!0,tooltip:({onHide})=>React.createElement(TooltipLinkList,{links:themesList.map(theme=>({id:theme,title:theme,active:selected===theme,onClick:()=>{updateGlobals({theme}),onHide();}}))})},React.createElement(IconButton,{key:THEME_SWITCHER_ID,active:!themeOverride,title:"Theme",disabled:isLocked},React.createElement(PaintBrushIcon,null),label&&React.createElement(IconButtonLabel,null,label))):null});addons.register(ADDON_ID,()=>{addons.add(THEME_SWITCHER_ID,{title:"Themes",type:types.TOOL,match:({viewMode,tabId})=>!!(viewMode&&viewMode.match(/^(story|docs)$/))&&!tabId,render:ThemeSwitcher,paramKey:PARAM_KEY});});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/addon-themes",
|
3
|
-
"version": "8.3.0-alpha.
|
3
|
+
"version": "8.3.0-alpha.5",
|
4
4
|
"description": "Switch between multiple themes for you components in Storybook",
|
5
5
|
"keywords": [
|
6
6
|
"css",
|
@@ -29,9 +29,9 @@
|
|
29
29
|
"exports": {
|
30
30
|
".": {
|
31
31
|
"types": "./dist/index.d.ts",
|
32
|
-
"node": "./dist/index.js",
|
33
32
|
"import": "./dist/index.mjs",
|
34
|
-
"require": "./dist/index.js"
|
33
|
+
"require": "./dist/index.js",
|
34
|
+
"node": "./dist/index.js"
|
35
35
|
},
|
36
36
|
"./preview": {
|
37
37
|
"types": "./dist/preview.d.ts",
|
@@ -53,8 +53,8 @@
|
|
53
53
|
"!src/**/*"
|
54
54
|
],
|
55
55
|
"scripts": {
|
56
|
-
"check": "
|
57
|
-
"prep": "
|
56
|
+
"check": "jiti ../../../scripts/prepare/check.ts",
|
57
|
+
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
|
58
58
|
},
|
59
59
|
"dependencies": {
|
60
60
|
"ts-dedent": "^2.0.0"
|
@@ -64,7 +64,7 @@
|
|
64
64
|
"typescript": "^5.3.2"
|
65
65
|
},
|
66
66
|
"peerDependencies": {
|
67
|
-
"storybook": "^8.3.0-alpha.
|
67
|
+
"storybook": "^8.3.0-alpha.5"
|
68
68
|
},
|
69
69
|
"publishConfig": {
|
70
70
|
"access": "public"
|