Created
October 5, 2019 13:07
-
-
Save chinhnguyen/a4a985a1b9bbd018118396590e768fb4 to your computer and use it in GitHub Desktop.
Override storybook add to make it work with material UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { storiesOf as storybookStoriesOf } from '@storybook/react'; | |
import { StylesProvider } from '@material-ui/styles'; | |
const generateClassName = (rule, styleSheet) => `${styleSheet.options.classNamePrefix}-${rule.key}`; | |
export default function storiesOf(kind, module) { | |
let stories = storybookStoriesOf(kind, module) | |
let _add = stories.add | |
//add: (storyName: string, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>; | |
stories.add = (storyName, storyFn, parameters) => | |
_add(storyName, () => ( | |
<StylesProvider generateClassName={generateClassName}> | |
{storyFn()} | |
</StylesProvider> | |
), parameters) | |
return stories | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment