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

Addon doesn't show well #97

Open
jlramosr opened this issue May 7, 2019 · 15 comments
Open

Addon doesn't show well #97

jlramosr opened this issue May 7, 2019 · 15 comments

Comments

@jlramosr
Copy link

jlramosr commented May 7, 2019

Hello!
my addon is showing of a strange way in my storybook v5.0.11 (the icons and functionality doesn't work well):

Captura de pantalla de 2019-05-07 12-16-03

What I'm doing bad?

I have another problem. When I create the MUI Theme, I use "override" to add a font with @font-face, but this font doesn't appear in my storybook component. What I have to do about that?

@usulpro
Copy link
Member

usulpro commented May 7, 2019

Hi @jlramosr

After we switched to the new alpha the UI of this addon wasn't finished yet, so for some sizes it could look weird. But should switch colors well though. It will be likely reworked in the next version.
If some functionality doesn't work as expected could you let me know details about that?

When you adding another font are you sure it properly download by components?

@jlramosr
Copy link
Author

jlramosr commented May 8, 2019

Hi @usulpro and thanks for the response.

Ok, I see the UI of the same way for all the window sizes and doing click on "clone Theme", "Clear Theme", etc, it doesn't work. I was using v3.9.3 of Material-UI, but with the new version (v.4-beta), this still happens. When I change the theme (I have two themes - dark and light - with different primary colors), the background color of my components it doesn't change. When I use my components outside, this behaviour is correct. I use v5.0.11 of storybook and I've tried with all your v.0.9.0-alpha versions.

Peek 08-05-2019 08-21

With regard to the fonts, the font downloaded on both themes with:

overrides: {
    MuiCssBaseline: {
      '@global': {
        '@font-face': MY_DOWNLOAD_FONT_ARRAY,
      },
    },
},
typography: {
  fontFamily: [ MY_DOWNLOADED_FONT, ... ]
}

it doesn't appear in the storybook, but outside the behaviour is correct and the font shows good.

Thanks again!

@usulpro
Copy link
Member

usulpro commented May 19, 2019

@jlramosr sorry for a long answer,
alpha-19 shows additional errors while theming creation, did you see any warnings in console?

@stoffeastrom
Copy link

@usulpro
I just cloned this https://github.com/indentlabs/notebook-ui and tested and I think it's the same problem? The console:
image

@usulpro
Copy link
Member

usulpro commented May 27, 2019

Yes - it's the same!
Could you please try

import { createMuiTheme } from '@material-ui/core/styles';

createMuiTheme(theme);

will it throw?

@stoffeastrom
Copy link

stoffeastrom commented May 27, 2019

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green
  },
  status: {
    danger: 'orange'
  }
});

const theme1 = createMuiTheme({
  palette: {
    primary: yellow,
    secondary: blue
  },
  status: {
    danger: 'orange'
  }
});

storiesOf('Button', module)
  .addDecorator(muiTheme([theme, theme1]))

and I still get that error when switching themes. Also changing colors in the color picker doesn't update the component e.g you get the same error on mouse over or changing color.

@stoffeastrom
Copy link

stoffeastrom commented May 28, 2019

If I do

storiesOf('Button', module)
  .addDecorator(muiTheme([dark, light]))
  .add('with text', a => (
    <Button variant="contained" color="primary">
        test button
    </Button>

e.g add variant="contained" it starts working (at least updating the color)

@usulpro
Copy link
Member

usulpro commented May 28, 2019

Great! Addon creates themes from objects you passing to muiTheme. So looks like the error comes when we trying to do createMuiTheme(theme) twice.

@usulpro
Copy link
Member

usulpro commented Jun 3, 2019

I suppose I can close this

@usulpro usulpro closed this as completed Jun 3, 2019
@Buzzkill-McSquare
Copy link

@usulpro I don't think this issue should be closed as the initial post (addon UI not matching what's presented in the README) is still active.

@usulpro usulpro reopened this Jun 5, 2019
@seanconnollydev
Copy link

I also wasn't able to edit the theme and didn't really understand how to use the UI. The UI displayed in the README is what I was hoping for.

@frankieali
Copy link
Contributor

frankieali commented Jul 9, 2019

I'm attempting to use this addon in my new project. I have the same issue as the original poster in that the latest code does not result in a UI as seen on the project landing page. I was really hoping for the Show Theme Editor toggle seen in the demo here.

Anyway, I was looking into why the latest version of this project was not working for me and it was because @storybook/addon-backgrounds has been updated. Instead of being initialized with addDecorator it's now initialized with addParameters.

Since the package.json looks for "@storybook/addon-backgrounds": "^5.0.6" it's fetching 5.1.9 which has this breaking change.

@frankieali
Copy link
Contributor

The demo in the README (seen on the project landing page) is version 0.8.11.

@usulpro
Copy link
Member

usulpro commented Jul 9, 2019

Yep, after Material-UI released v1 the structure of theme was changed. So I'm considering a new way of how to edit themes. At this moment it's possible to edit theme as a json object from addon panel

@kaiwa
Copy link

kaiwa commented Jul 15, 2019

I'm trying to set up alpha 20 with material-ui 3.9.3 and for me as well the component does not update when switching the theme.

I have two themes added in storybook's config.js:

addDecorator(muiTheme([
  ATheme
  BTheme,
]));

One of the themes is initially successfully applied to the component.

Both themes show up in the addon's theme selector and I can switch them.

When switching, the theme editor shows the selected theme correctly and I see a message is showing in the console with a changing themeInd:

message arrived at preview sm/storybook-addon-material-ui/material-event/back {themes: Array(2), themeInd: 1}

There are no errors besides the typography warning:

Warning: Material-UI: you are using the deprecated typography variants that will be removed in the next major release.
Please read the migration guide under https://material-ui.com/style/typography#migration-to-typography-v2

But switching the theme has no effect on the component (border color should change to theme.palette.primary.light in my example).

output

WULCAN added a commit to WULCAN/app.zetkin.org that referenced this issue Jun 26, 2024
The addon does not support Storybook 7 as it is still using default
export of @storybook/addons

The addon has not been developed since April 2023.

I don't see any of its functionality, other than applying the theme,
actually working with Storybook 6 either. The project it was forked
from has some open issues where others had similar problems.

react-theming/storybook-addon-material-ui#124
react-theming/storybook-addon-material-ui#97

I followed the guide from Ocotober 2022 for Material UI in Storybook to
activate our theme without storybook-addon-material-ui.

https://storybook.js.org/blog/material-ui-in-storybook/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants