react-component-permutations
v1.0.0-beta2
Published
Uses propTypes to create an array of React component props to display various permutations
Downloads
1,827
Maintainers
Readme
react-component-permutations
WIP
Uses propTypes to create an array of React component props to display various permutations.
npm i react-component-permutations
Usage
import fs from 'fs'
import getPermutations from 'react-component-permutations'
const src = fs.readFileSync('./components/Button.js', 'utf8')
const options = {}
const permutations = getPermutations(src, options)
Options
strings
- Array - strings to render forPropType.string
numbers
- Array - numbers to render forPropType.number
arrays
- Array - arrays to render forPropType.array
objects
- Array - objects to render forPropType.object
nodes
- Array - nodes to render forPropTypes.node
[key]
- Array - any prop name to add to the returned objects array
Demo
Given a button component with these propTypes
:
Button.propTypes = {
big: React.PropTypes.bool,
color: React.PropTypes.oneOf(colorKeys),
pill: React.PropTypes.bool,
outline: React.PropTypes.bool
}
The rendered result would look something like this:
http://jxnblk.com/react-component-permutations/demo
See the /demo
folder.
MIT License