storybook-construct
v0.1.2
Published
A suite of helper functions to help compose your stories with docs and knobs
Downloads
8
Maintainers
Readme
Storybook Construct
A set of helper functions that enable quicker writing of docs and knobs
This addon is currently only compatible with React for now.
Install
IMPORTANT
This package requires installation of:
Install and configure those first then continue here
npm install --dev storybook-construct
or
yarn add --dev storybook-construct
Usage
import React from 'react'
import { storiesOf } from '@storybook/react'
import * as knob from '@storybook/addon-knobs'
import constructStoryComponent, { createKnob } from 'storybook-construct'
const MyStoryComponent = () => (/* React code */)
export default storiesOf('Your Story', module).add(
'<Story Name>',
constructStoryComponent(MyStoryComponent, require('path/to/docs.md'), {
/* ...props */
knobs: {
/* Your knobs */
myNewKnob: createKnob(knob.text, 'Knob name', 'Default Value')
}
})
)
constructStoryComponent(Component, docs, props)
Create a story that uses withDocs
from storybook-readme
createKnob(knobFunction, ...knobParams)
Takes a knob function as first argument and all remaining arguments are that knobs params