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
1. you can add global control to .storybook/preview.ts: globalTypes which adds URL parameter when you click the switch (all custom global controls changes URL params).
2. Then you can write custom global storybook decorator to .storybook/preview.ts: decorators with useEffect which will emit storybook-dark-mode action to sync dark state with your custom storybook global control value (see README):
import{useDarkMode}from'storybook-dark-mode';// . . .
decorators: [(Story,context)=>{// if we added "theme" global variable earlierconsttheme=context.globals.theme;constdarkMode=useDarkMode();useEffect(()=>{constdarkModeFromTheme=theme==='dark';if(darkModeFromTheme!=darkMode){channel.emit(UPDATE_DARK_MODE_EVENT_NAME);}},[theme]);return<Story/>;},// ...rest decorators]
(didn't test the snippet, just an idea. If you will succeed please share working code 🙂)
Is it possible to somehow link to a story that would have dark mode predefined? e.g via some kind of query parameter.
The text was updated successfully, but these errors were encountered: