@compositor/kit-storybook

1.0.24 • Public • Published

Kit Storybook

Experimental

Create a Storybook dev environment with a folder of examples

npm i -g @compositor/kit-storybook

Usage

Run Kit Storybook against a folder of examples. Each example module should export a React element.

kit-storybook examples
// examples/Button.js example module
import React from 'react'
import { Button } from '../src'

export default (
  <Button>
    Hello
  </Button>
)

Core API

To use examples in an existing storybook, import the loadExamples function in your storybook config and pass an object of examples to render.

// storybook config
import path from 'path'
import { configure } from '@storybook/react'
import loadExamples from '@compositor/kit-storybook'

const req = require.context('../examples', false, /\.js$/)

const examples = req.keys().forEach(key => ({
  name: path.basename(key, path.extname(key)),
  example: req(key).default || req(key)
})

configure(() => {
  loadExamples(examples)
}, module)

MIT License

/@compositor/kit-storybook/

    Package Sidebar

    Install

    npm i @compositor/kit-storybook

    Weekly Downloads

    1

    Version

    1.0.24

    License

    MIT

    Unpacked Size

    5.05 kB

    Total Files

    11

    Last publish

    Collaborators

    • johno
    • jxnblk
    • mrmrs