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

MuiThemeProvider not Working with Separate Storybook Project #107

Open
chriszwickerocteris opened this issue Aug 21, 2019 · 3 comments
Open
Labels

Comments

@chriszwickerocteris
Copy link

I have a setup with one storybook project containing stories from different projects in a monorepo. When using storybook-addon-material-ui, my theme does not get injected into a themed component, but rather the default theme gets used.

I've created a temporary workaround by patching muiTheme.js and UI/MuiDecorator.js to allow passing an additional option themeProvider and using that instead of the imported MuiThemeProvider. In my stories, I then specifically import MuiThemeProvider from node_modules in the project my target component is defined in and pass it to muiTheme in addDecorator.

Maybe there is a better solution for the problem? If not, it would be great if you could integrate my changes (I'm currently patching the transpiled JS files using patch-package, but happy to provide a PR if that helps!).

@chriszwickerocteris
Copy link
Author

An even better alternative might be an option to specify the (relative) path to the project from which to use @material-ui/core. This would avoid having to install the package into the separate storybook project. Would be a bit more complicated, though ;-)

@usulpro
Copy link
Member

usulpro commented Aug 25, 2019

Hey @chriszwickerocteris

If I right understand you faced a case when you need to provide your own ThemeProvider to this addon? It looks interesting and opens possibility to use the addon with other theming systems.
Maybe I miss something in your specific case but I'd be happy if you show your idea in terms of addon API or start a PR. 👍

@chriszwickerocteris
Copy link
Author

Sorry, missed your reply. I'll try to find the time to create a PR (soon, hopefully)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants