Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable flow types in stories #1621

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Here are some featured storybooks that you can reference to see how Storybook wo

If you are using Typescript, make sure you have the type definitions installed via `yarn add @types/node @types/react @types/storybook__react --dev`.

## Flow

Flow types are supported out of the box with the default Babel configuration.

## Docs

- [Basics](https://storybook.js.org/basics/introduction)
Expand Down
1 change: 1 addition & 0 deletions app/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-preset-flow": "^6.23.0",
"mock-fs": "^4.3.0",
"nodemon": "^1.11.0",
"react": "^15.6.1",
Expand Down
1 change: 1 addition & 0 deletions app/react/src/server/config/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ module.exports = {
require.resolve('babel-preset-es2016'),
require.resolve('babel-preset-stage-0'),
require.resolve('babel-preset-react'),
require.resolve('babel-preset-flow'),
],
};
29 changes: 29 additions & 0 deletions examples/cra-kitchen-sink/src/components/FlowButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @flow
/* eslint-disable */
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;
9 changes: 9 additions & 0 deletions examples/cra-kitchen-sink/src/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import App from '../App';
import Logger from './Logger';
import Container from './Container';

import FlowButton from '../components/FlowButton';

const EVENTS = {
TEST_EVENT_1: 'test-event-1',
TEST_EVENT_2: 'test-event-2',
Expand Down Expand Up @@ -264,6 +266,13 @@ storiesOf('component.Button', module)
.add('first', () => <button>first button</button>)
.add('second', () => <button>first second</button>);

storiesOf('component.FlowButton', module).add(
'withInfo',
withInfo('This flow button should display propTypes and comments')(() =>
<FlowButton label="Flow Button" />
)
);

// Atomic

storiesOf('Cells/Molecules.Atoms/simple', module)
Expand Down