Storybook-addon-props-fela
Document the props of your components in storybook.
react-storybook-addon-info ?
Why notQuite simple, because he doesn't handle fela correctly and i use it on my project.
Getting started
Install storybook-addon-props-fela
:
yarn add storybook-addon-props-fela
// OR
npm i --save storybook-addon-props-fela
Then in your storybook import and add the addon :
;; ;
Once you added the addon, a new method is available for your stories addWithProps
.
addWithProps
is the same as the default function of storybook add
except the fact that it takes a third parameter. This third parameters is the component from which you want the props.
Usage
To use the full power of this addon, your component need to provide propTypes
and defaultProps
.
The addon support flow and use it for the required property (it's quite a minimum support for now, i think we can do more with flow later).
;;; ;; const FelaProvider = ; const test = fontSize: 35 color; const Test = ;TestdefaultProps = color: '#333' ;TestpropsTypes = color: PropTypesstring; ; ; ;
If your component is enhanced with a decorator for example, you'll need to pass the rawComponent.
For example for a component like this:
;;;; ;const badge = position: 'absolute' top: 0 right: 0 opacity: 085 color: 'white' padding: '3px 10px' borderRadius: '20%/50%' transform: 'translate(50%)' lineHeight: 1 overflow: 'hidden' whiteSpace: 'nowrap'; const container = display: 'flex' position: 'relative' width: small ? 45 : tiny ? 25 : 70 height: small ? 45 : tiny ? 25 : 70; const Badge = ;const Container = ;const Avatar = <Container ...props> <DefaultAvatar ...border small tiny /> badge ? <Badge ...theme>badge</Badge> : null </Container>; AvatardefaultProps = border: true;AvatarpropTypes = avatar: PropTypesstring badge: PropTypesstring border: PropTypesbool small: PropTypesbool tiny: PropTypesbool; const enhance = R;Avatar;
you write your story like this :
;;; ... ;
API
addWithProps(kind, story, rawComponent)
Show the story with the props.