• This repository has been archived on 05/Jan/2023
  • Stars
    star
    217
  • Rank 182,446 (Top 4 %)
  • Language
    JavaScript
  • Created about 8 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🧠 This Storybook plugin uses @storybook/addon-knobs but creates the knobs automatically based on PropTypes.

Smart knobs addon for Storybook

This Storybook plugin uses @storybook/addon-knobs but creates the knobs automatically based on PropTypes, Flow and Typescript.

Installation:

npm i storybook-addon-smart-knobs --save-dev

Usage:

import React from 'react'
import PropTypes from 'prop-types'
import { storiesOf } from '@storybook/react'
import { withKnobs } from '@storybook/addon-knobs'
import { withSmartKnobs } from 'storybook-addon-smart-knobs'

const Button = ({ children, onClick }) => (
  <button onClick={ onClick }>{ children }</button>
)

Button.propTypes = {
  children: PropTypes.node,
  onClick: PropTypes.func
}

storiesOf('Button')
  .addDecorator(withSmartKnobs(options))
  .addDecorator(withKnobs)
  .add('simple', () => <Button>Smart knobed button</Button>)

Options

  • ignoreProps

    Type: Array

    Will not automatically create knobs for props whose name is in this array. Example:

      .withSmartKnobs({ ignoreProps: ['numberProp'] })
      .add('example', () => <div numberProp={date('date', date)} />) 

Configuration:

This plugin has a peer dependency on babel-plugin-react-docgen . As a result, babel-plugin-react-docgen needs to be added to your Storybook Babel configuration.

For a standard Storybook configuration, add react-docgen to your plugins in an appropriate .babelrc file.

If you have created a webpack.config.js file for Storybook, you may need to configure the plugin in there.

module.exports = (baseConfig, env, defaultConfig) => {
  defaultConfig.module.rules[0].use[0].options.plugins = [
    require.resolve('babel-plugin-react-docgen'),
  ]

  return defaultConfig
}

Typescript:

Use react-docgen-typescript-loader to generate docgen info from Typescript types. This docgen info will be used to automatically create knobs.

More Repositories

1

react-treebeard

React Tree View Component. Data-Driven, Fast, Efficient and Customisable.
JavaScript
1,688
star
2

storybook-deployer

Deploy your storybook as a static site
JavaScript
894
star
3

react-cdk

under development - React Component Development Kit with Storybook
JavaScript
576
star
4

react-native-storybook

REPO/PACKAGE MOVED - UI Component Dev Environment for React Native
JavaScript
486
star
5

storyshots

REPO/PACKAGE MOVED - Jest Snapshot testing for React Storybook
JavaScript
351
star
6

storybook-addon-knobs

REPO/PACKAGE MOVED - Edit React props dynamically using the Storybook UI
JavaScript
189
star
7

storybook-addon-jest

REPO/PACKAGE MOVED - React storybook addon that show component jest report
JavaScript
172
star
8

react-storybook-addon-info

REPO/PACKAGE MOVED - A storybook addon to show additional information for your stories.
JavaScript
154
star
9

getstorybook

REPO/PACKAGE MOVED - Easiest way to add Storybook support to your project
JavaScript
95
star
10

addon-backgrounds

REPO/PACKAGE MOVED - A Storybook addon to customize the background of your preview
JavaScript
74
star
11

storybook-ui

REPO/PACKAGE MOVED - Core Storybook UI
JavaScript
52
star
12

storybook-addon-a11y

REPO/PACKAGE MOVED - Storybook addon to help, improving accessibility within you're react components.
JavaScript
37
star
13

storybook-addon-notes

DEPRECATED - Write notes for your Storybook stories
JavaScript
33
star
14

storybook-addon-options

REPO/PACKAGE MOVED - Storybook UI Options Addon
JavaScript
30
star
15

storybook-addon-graphql

REPO/PACKAGE MOVED - Storybook addon to display the GraphiQL IDE
JavaScript
20
star
16

storybook-addon-actions

REPO/PACKAGE MOVED - Action logger addon for storybook
JavaScript
19
star
17

storybook-addon-links

REPO/PACKAGE MOVED - Story links addon for storybook
JavaScript
11
star
18

storybooks.github.io

REPO MOVED: Storybook documentation site
JavaScript
10
star
19

generate-page-webpack-plugin

generate a html-page for every webpack entrypoint
JavaScript
7
star
20

getstorybook.io

REPO/DOCS MOVED - getstorybook.io website - developer's home for storybook
JavaScript
7
star
21

react-storybook-decorator-centered

REPO/PACKAGE MOVED - Storybook decorator to render the component at screen center
JavaScript
6
star
22

storybook-addon-comments

REPO/PACKAGE MOVED - Comments Addon
JavaScript
5
star
23

riot

Storybook framework support for riot
TypeScript
4
star
24

mithril

Storybook framework support for mithril
JavaScript
3
star
25

storybook-addons

REPO/PACKAGE MOVED - Storybook addons store
JavaScript
3
star
26

storybook-package

https://www.npmjs.com/package/storybook
JavaScript
3
star
27

deprecated-addons

JavaScript
2
star
28

aurelia

Storybook framework support for aurelia
TypeScript
2
star
29

rax

Storybook framework support for rax
JavaScript
1
star
30

marionette

Storybook framework support for marionette
JavaScript
1
star
31

storybook-channel-firebase

DEPRECATED - storybook firebase channel
JavaScript
1
star
32

storybook-database-local

DEPRECATED - storybook database on local machine
JavaScript
1
star
33

storybook-channel-websocket

REPO/PACKAGE MOVED - Websocket Channel
JavaScript
1
star
34

storybook-addon-devel

DEPRECATED - storybook addon developer tool
JavaScript
1
star
35

actor-js-lerna

A https://www.dependencies.io actor for updating JS monorepo dependencies using Lerna.
JavaScript
1
star