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
My current workaround is to add classes myself via a script in preview-head.html:
<script>// storybook-addon-themes doesn't run in the preview itself, but adds// classes to the preview by reaching into the iframe. For standalone// views, we need to set default classes so we have a theme.if(document.documentElement.className===''){constthemes={light: 'theme-light',dark: 'theme-dark'};document.documentElement.className=themes[newURLSearchParams(document.location.search).get('theme')]||themes.light;}</script>
Hello @fvsch and thank you for reporting.
If the button (used to switch theme) is not rendered in the UI, the theme will not aply.
We can try to fix this, but I'm glad you found a workaround for now.
I would personnaly suggest to try the decorator.
When using the decorator, the logic is located inside it and because the decorator is available in standalone canvas mode, I think it would work without any additional workaround.
I have this addon running well for most use cases, but not when opening a canvas in a standalone tab so that the tab's URL is something like:
or:
In both cases, the classes I’ve declared for my default theme are not added to the root element (as configured). So no theme is applied.
Can anyone else reproduce this issue?
The text was updated successfully, but these errors were encountered: