-
Notifications
You must be signed in to change notification settings - Fork 130
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
[v1] How to keep custom theme selected while browsing stories #87
Comments
Hi! @pandaiolo thank you for your attention to this issue. Indeed, keeping selected theme for each story is the feature which is not implemented yet. And it's on the first place in my roadmap, but I didn't start it yet 😄 PR is really welcome. Would you mind submitting it? Don't worry about your solution I'll check it and continue if it's necessary. (I guess we would like to use |
@usulpro that's great! I used that So I was wondering why the theme was reset, and because I am new to storybook, I am not sure exactly, but I suspect MUI decorator are reloaded each time, that's right? So it would fire a new store, with its initial value, each time, that's right? Hence some kind of variable in the global scope seem necessary? I have yet to figure out more details on how your addon work. |
Yes, story component did mount each time when selecting new story.
...hm I trying to remember how it was implemented in previous version of addon. Do you need to keep one same theme while browsing stories or you want to remember different themes, one for each story? If it helps you can find how it was implemented here: storybook-addon-material-ui/src/containers/PanelContainer.js Lines 195 to 197 in 84907ea
|
Hum, that's a good option. Yes, my use case is to keep the same set of themes, select a specific one that I want to check on different component/stories |
Possibly you could start this feature? I'll join a bit later this week 😄 |
I had a look but not totally obvious to me where to start. I probably won't have time to get this done in the short term. |
Had some issues with original workaround when selecting first theme (index 0), so played around a bit (without going deeper in addons source code as I'm quite new to storybook as such). Here's my
|
I don't know if i'm doing this correctly, but it seemed to me that when switching to another story, the theme is reset to index 0. It means that to review a theme for a bunch of components, I have to switch story / reselect said theme each time.
We have more than a hundred themes for while-label customers, so the process is a bit cumbersome.
I have hacked a hacky workaround for this, under the form of an addon, as following:
It is far from perfect but it is the most stable I've came up with, even though theme at index 0 flashes at each new story, before selecting the required theme.
Basically, it always switches off the theme 0 to either theme 1 or user requested theme, each time there is a new story visited.
(I tried without immediately switching to theme != 0, but it was buggy because I could tell if theme 0 was a reset or user selected... and I did not have that much time to figure it out)
Anyway, is it a feature that you would consider for the addon? Would you like a PR? Any specific implementation design you have in mind, if so?
Or I just missed an option? :-)
Thanks!
The text was updated successfully, but these errors were encountered: