You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pass selected theme to globals as is done in @storybook/addon-backgrounds. This way we can access the theme automatically in a decorator without having to use withTheme along with a custom theme Decorator prop.
// snippet from storybook/addons/backgrounds/src/containers/BackgroundSelector.tsx// ...const[globals,updateGlobals]=useGlobals();constglobalsBackgroundColor=globals[BACKGROUNDS_PARAM_KEY]?.value;constselectedBackgroundColor=useMemo(()=>{returngetBackgroundColorByName(globalsBackgroundColor,backgroundsConfig.values,backgroundsConfig.default);},[backgroundsConfig,globalsBackgroundColor]);if(Array.isArray(backgroundsConfig)){logger.warn('Addon Backgrounds api has changed in Storybook 6.0. Please refer to the migration guide: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md');}constonBackgroundChange=useCallback((value: string)=>{updateGlobals({[BACKGROUNDS_PARAM_KEY]: { ...globals[BACKGROUNDS_PARAM_KEY], value }});},[backgroundsConfig,globals,updateGlobals]);// ...
The text was updated successfully, but these errors were encountered:
Pass selected
theme
toglobals
as is done in@storybook/addon-backgrounds
. This way we can access thetheme
automatically in adecorator
without having to usewithTheme
along with a custom themeDecorator
prop.See example from backgrounds addon here
The text was updated successfully, but these errors were encountered: