Skip to content

Commit

Permalink
docgen info works without ts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielduan committed Aug 1, 2017
1 parent 5f3134d commit 5dbf9b9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 23 deletions.
27 changes: 27 additions & 0 deletions examples/cra-kitchen-sink/src/components/DocgenButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import PropTypes from 'prop-types';

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

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

DocgenButton.propTypes = {
/** Boolean indicating whether the button should render as disabled */
disabled: PropTypes.bool,
/** button label. */
label: PropTypes.string.isRequired,
/** onClick handler */
onClick: PropTypes.func,
/** component styles */
style: PropTypes.shape,
};

export default DocgenButton;
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
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?: {}
/** Boolean indicating whether 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) => (
const TypedButton = ({ disabled, label, style, onClick }: PropsType) =>
<button disabled={disabled} style={style} onClick={onClick}>
{label}
</button>
);
</button>;

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

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

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

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

storiesOf('AddonInfo.DocgenButton', module).addWithInfo('DocgenButton', 'Some Description', () =>
<DocgenButton onClick={action('clicked')} label="Docgen Button" />
);

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

Expand Down

0 comments on commit 5dbf9b9

Please sign in to comment.