0.1.2 • Published 6 years ago

storybook-construct v0.1.2

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

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