Skip to content

Commit

Permalink
Add TypedButton example showcasing Flowtype & React Docgen docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Ribeiro authored and danielduan committed Aug 1, 2017
1 parent 7d083a1 commit f449e16
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ type PropsType = {
};

/** Button component description */
const Button = ({ disabled, label, style, onClick }: PropType) => (
const Button = ({ disabled, label, style, onClick }: PropsType) => (
<button disabled={disabled} onClick={onClick}>
{label}
</button>
Expand Down
10 changes: 10 additions & 0 deletions examples/cra-kitchen-sink/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": ["env", "stage-0", "react"],
"plugins": [
["transform-runtime", {
"polyfill": false,
"regenerator": true
}],
"react-docgen"
]
}
28 changes: 28 additions & 0 deletions examples/cra-kitchen-sink/src/TypedButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @flow
import React from 'react';

type PropsType = {
/** Boolean indicating wether the button should render as disabled */
disabled?: boolean,
/** button label. */
label: string,
/** onClick handler */
onClick?: Function,
/** component styles */
style?: {}
};

/** Button component description */
const TypedButton = ({ disabled, label, style, onClick }: PropsType) => (
<button disabled={disabled} style={style} onClick={onClick}>
{label}
</button>
);

TypedButton.defaultProps = {
disabled: false,
onClick: () => {},
style: {},
};

export default TypedButton;
10 changes: 10 additions & 0 deletions examples/cra-kitchen-sink/src/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Button, Welcome } from '@storybook/react/demo';
import App from '../App';
import Logger from './Logger';
import Container from './Container';
import TypedButton from '../TypedButton';

const EVENTS = {
TEST_EVENT_1: 'test-event-1',
Expand Down Expand Up @@ -145,6 +146,15 @@ storiesOf('Button', module)
)
);

storiesOf('TypedButton', module)
.addWithInfo('TypedButton',
'Some Description',
() => <TypedButton
onClick={action('clicked')}
label="Typed Button"
/>,
)

storiesOf('App', module).add('full app', () => <App />);

storiesOf('Centered Button', module)
Expand Down

0 comments on commit f449e16

Please sign in to comment.