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

addDecorator question. #28

Closed
PaulieScanlon opened this issue Jun 17, 2019 · 1 comment
Closed

addDecorator question. #28

PaulieScanlon opened this issue Jun 17, 2019 · 1 comment

Comments

@PaulieScanlon
Copy link

PaulieScanlon commented Jun 17, 2019

Hey, i love this addon it's really great. My config is as follows

addDecorator(withThemesProvider(themes));

Which works great but i'd also like to add something like this

addDecorator(story => <Main>{story}</Main>)

and have main also respond to the theme changes when the UI buttons are clicked... but if i do it this way Main as a decorator has no access to the theme... any ideas?

As a work around i've done this

const stories = storiesOf("Buttons/ButtonAction", module).addDecorator(
  story => <Main>{story()}</Main>
);

stories.add("usage", () => <ButtonAction>Button Action</ButtonAction>, {
  info: "This is a buttonAction"
});

which works fine but Main will show up in my story source which is kinda not what i want.

Screenshot 2019-06-17 at 10 37 42

@echoulen
Copy link
Owner

echoulen commented Jul 12, 2019

source code

export const withThemesProvider = (themes: Theme[]) => (story): JSX.Element => {
  return <ThemesProvider themes={List(themes)}>{story()}</ThemesProvider>;
};

try to custom your decorator

import ThemesProvider from "storybook-addon-styled-component-theme";
import {List} from "immutable"

export const withCustomThemesProvider = (themes: Theme[]) => (story): JSX.Element => {
  return <ThemesProvider themes={List(themes)}><!-- custom here --></ThemesProvider>;
};

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

2 participants