-
-
Save gangstaJS/dcbbcbdde470c3b07c2559da384e0e61 to your computer and use it in GitHub Desktop.
react-storybook samples
This file contains hidden or 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
/** | |
* dynamically loading all stories with .stories.js extension | |
*/ | |
import { configure } from '@kadira/storybook'; | |
require('es6-promise').polyfill(); | |
import 'babel-polyfill'; | |
const stories = require.context('../app/js/components', true, /.stories.js$/); | |
function loadStories() { | |
stories.keys().forEach(filename => stories(filename)); | |
} | |
configure(loadStories, module); |
This file contains hidden or 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
/** | |
* using redux-mock-store | |
* using redux provider | |
* using stories decorators | |
*/ | |
import React from 'react'; | |
import { storiesOf } from '@kadira/storybook'; | |
import { MenuToggle } from '../header/MenuToggle'; | |
import Header from '../header/Header'; | |
import { Provider } from 'react-redux'; | |
import configureStore from 'redux-mock-store'; | |
const mockStore = configureStore(); | |
const store = mockStore({ | |
ui: { | |
isMenuOpened: true, | |
}, | |
}); | |
storiesOf('Header', module) | |
.addDecorator(getStory => <Provider store={store}>{getStory()}</Provider>) | |
.add('with text', () => { | |
const config = { | |
version: 'standard', | |
config: {}, | |
isLoggedIn: true, | |
user: { | |
access: 'buyer', | |
}, | |
}; | |
return <Header {...config} />; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment