GithubHelp home page GithubHelp logo

Comments (5)

bareynol avatar bareynol commented on June 3, 2024

doing some digging into this myself. I'll see if I can fix it and submit a PR

from storybook-addon-material-ui.

bareynol avatar bareynol commented on June 3, 2024

It seems that when custom themes are passed in via .storybook/stories.js, only the object which specifies the MUI overrides are used:

https://github.com/react-theming/storybook-addon-material-ui/blob/version-1/.storybook/stories.js#L27

import { overridings as theme1 } from './.themes/customTheme1';
import { overridings as theme2 } from './.themes/customTheme2';
import themeF3, { overridings as theme3 } from './.themes/customTheme3';
import { overridings as theme4 } from './.themes/customTheme4';
import { overridings as theme5 } from './.themes/customTheme5';

...
  .addDecorator(muiTheme([theme1, theme2, theme3, theme4, theme5]))
...

overriding object can be found here: https://github.com/react-theming/storybook-addon-material-ui/blob/version-1/.storybook/.themes/customTheme1.js#L15


In the muiTheme() definition, while themes received are objects, the default lightBaseTheme and darkBaseTheme are created using createMuiTheme()

I believe this is presenting an issue in the FullTheme component and causing a crash because this component calls createMuiTheme() on the currently selected theme when sending it to the object inspector:

https://github.com/react-theming/storybook-addon-material-ui/blob/version-1/src/UI/FullTheme.js#L31

Calling createMuiTheme twice on a set of overrides causes the same error as listed above.

from storybook-addon-material-ui.

bareynol avatar bareynol commented on June 3, 2024

Removing createMuiTheme() on the default light/dark themes and adding palette: { type: 'light' } to the lightBaseTheme configuration did the following for me on a local build:

  1. stopped the app from crashing when selecting "full theme" in the addon panel
  2. fixed the default dark theme not being applied to components in storybook

from storybook-addon-material-ui.

bareynol avatar bareynol commented on June 3, 2024

I think part of my issue overall is that I was using material-ui/core v4, whereas, from what I can tell, this repo only supports Material-ui v3 (though that doesn't appear to be documented anywhere).

So it seems like this addon uses MuiThemeProvider as a decorator, and not the ThemeProvider introduced in v4.

from storybook-addon-material-ui.

rvillalba-novetta avatar rvillalba-novetta commented on June 3, 2024

Same observations here. Button on the right seems to imply that its v3 as well thought I wasn't sure at first. This should be documented in the README. Support for v4 would be great.
image

from storybook-addon-material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.