Skip to content

Instantly share code, notes, and snippets.

@jeffcarbs
Created November 1, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeffcarbs/ef81004e53fc755bbb84a23146fb3a24 to your computer and use it in GitHub Desktop.
Save jeffcarbs/ef81004e53fc755bbb84a23146fb3a24 to your computer and use it in GitHub Desktop.
React Storybook - Kitchen Sink
import { configure } from '@kadira/storybook'
import 'lib/semantic-ui/semantic-ui.global.less'
// Our project follows the convention of co-locating components with their stories. For example:
// Component/
// Component.js
// Component.spec.js
// Component.stories.js
// index.js
const req = require.context('../src', true, /.stories.js$/)
/**
* @returns {void}
*/
function loadStories () {
// Load all stories
req.keys().forEach(req)
// Load the "Kitchen Sink" story
require('./KitchenSink.stories.js')
}
configure(loadStories, module)
// This is using Semantic-UI-React for a grid system but the rendering can be handled however you want.
import { getStorybook, storiesOf } from '@kadira/storybook'
import { Grid, Header } from 'semantic-ui-react'
// Avoid infinite loop
const KITCHEN_SINK_TITLE = 'Kitchen Sink'
const renderStory = (story) => (
<Grid.Row key={story.name} style={{ marginBottom: '1rem' }}>
<Grid.Column>
<Header as='h2' content={story.name} />
{story.render()}
</Grid.Column>
</Grid.Row>
)
const renderStoryGroup = (group) => (group.kind !== KITCHEN_SINK_TITLE &&
<Grid.Column key={group.kind}>
<Header as='h1' content={group.kind} />
{group.stories.map(renderStory)}
</Grid.Column>
)
storiesOf('Kitchen Sink', module)
.add('everything', () => (
<Grid padded columns={1}>
{getStorybook().map(renderStoryGroup)}
</Grid>
))
@anoopsinghbayes
Copy link

This looks interesting , can you suggest how to use this with angular SB , as i am stuck with how to render in angular
i can't wrap my head around how angular renders in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment