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

Support for Storybook v7 #61

Open
kirandash opened this issue Apr 10, 2023 · 2 comments
Open

Support for Storybook v7 #61

kirandash opened this issue Apr 10, 2023 · 2 comments

Comments

@kirandash
Copy link

In storybook v7, addDecorator has been removed.

@VincentVW
Copy link

For anyone hitting this issue, I tried the new way of adding decorators as described here but its throwing errors so this library does not work with storybook 7 yet.

As alternative, you could look into this styled components recipe on storybook documentation, where they use @storybook/addon-styling to add a styled components theme:

Add a decorator to stories in .storybook/preview.js

import { Preview } from '@storybook/react';
import { withThemeFromJSXProvider } from '@storybook/addon-styling';
import { createGlobalStyle, ThemeProvider } from 'styled-components';

import { theme1, theme2 } from './themes';


const GlobalStyles = createGlobalStyle`
  // some global style if needed
`;

const preview: Preview = {
  decorators: [
    withThemeFromJSXProvider({
      themes: {
        theme1,
        theme2,
      },
      defaultTheme: 'theme1',
      Provider: ThemeProvider,
      GlobalStyles,
    }),
  ],
};

export default preview;

Add to .storybook/main.js

module.exports = {
  ...
  addons: [
    ...
    "@storybook/addon-styling"
  ]
};

@arange
Copy link

arange commented Jun 8, 2023

For anyone hitting this issue, I tried the new way of adding decorators as described here but its throwing errors so this library does not work with storybook 7 yet.

As alternative, you could look into this styled components recipe on storybook documentation, where they use @storybook/addon-styling to add a styled components theme:

Add a decorator to stories in .storybook/preview.js

import { Preview } from '@storybook/react';
import { withThemeFromJSXProvider } from '@storybook/addon-styling';
import { createGlobalStyle, ThemeProvider } from 'styled-components';

import { theme1, theme2 } from './themes';


const GlobalStyles = createGlobalStyle`
  // some global style if needed
`;

const preview: Preview = {
  decorators: [
    withThemeFromJSXProvider({
      themes: {
        theme1,
        theme2,
      },
      defaultTheme: 'theme1',
      Provider: ThemeProvider,
      GlobalStyles,
    }),
  ],
};

export default preview;

Add to .storybook/main.js

module.exports = {
  ...
  addons: [
    ...
    "@storybook/addon-styling"
  ]
};

That is awesome, thanks Vincent you saved my day!

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

3 participants