Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting theme classes from inside story #59

Open
sney-js opened this issue Jun 17, 2021 · 1 comment
Open

Setting theme classes from inside story #59

sney-js opened this issue Jun 17, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@sney-js
Copy link

sney-js commented Jun 17, 2021

Suppose one of my theme class is theme-twitter. Using the dropdown from this plugin works great.

However, I also have a button inside my story that can add/remove theme-twitter from dom on body tag. The moment the class gets added, this plugin removes the added class from the body.

I understand I can provide root, or body etc, but I want to keep body tag. I want to be able to modify body classes from within story without this plugin overwriting it as it sees fit. How can I achieve that?

@tonai
Copy link
Owner

tonai commented Jul 28, 2021

If the logic of adding the updating the body class is inside the component, you might not want to change it to adapt the behaviour for storybook.
Then this way, it is probably incompatible.

One possible way would be to extract the logic from your component and add a onThemeChange props in your component.
In your app the logic will be handled by the parent.
In Storybook it will be handled by a wrapper component that will update the theme in the addon.
For now it is not possible to set the theme from outside, but if this feature is added, you will should also need to adapt your component.

@tonai tonai added enhancement New feature or request question Further information is requested labels Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants