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

chore(storybook): update v1 syntax to use Storybook v6 #568

Merged
Merged
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
9 changes: 0 additions & 9 deletions .storybook/config.js

This file was deleted.

21 changes: 21 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');

module.exports = {
stories: ['../stories/*.stories.tsx'],
addons: ['@storybook/addon-essentials'],
typescript: {
check: false, // typecheck separately
reactDocgen: false, // substantially improves performance: https://github.com/storybookjs/storybook/issues/22164#issuecomment-1603627308
},
webpackFinal: async (config, {configType}) => {
config.devtool = false; // perf per: https://github.com/storybookjs/storybook/issues/19736#issuecomment-1478103817
config.module.rules.push({
test: /\.scss$/,
exclude: /node_modules/,
include: path.resolve(__dirname, '../'),
sideEffects: true, // get side-effect styles to load per: https://github.com/storybookjs/storybook/issues/4690#issuecomment-435909433
loader: 'style-loader!raw-loader!sass-loader'
});
return config;
},
};
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// import '../src/styles/main.scss'; -- this seems to not work and also makes the Storybook freeze for multiple minutes 😕
26 changes: 0 additions & 26 deletions .storybook/webpack.config.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"storybook": "6.5.0-beta.1",
"style-loader": "^2.0.0",
"ts-jest": "^26.5.6",
"ts-loader": "^8.3.0",
"ts-node": "^10.9.1",
"webfonts-generator": "^0.4.0",
"webpack": "^4.46.0"
Expand Down
17 changes: 11 additions & 6 deletions stories/data-loader.tsx → stories/data-loader.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';

import { App } from './utils';
Expand All @@ -9,10 +8,14 @@ function loadData(input: string): Promise<string> {
return new Promise((resolve) => window.setTimeout(() => resolve(`hello ${input}`), 50));
}

storiesOf('Data Loader', module)
.add('loading data asynchronously', () => {
const [input, setInput] = React.useState('world');
return <App>
export default {
title: 'Data Loader',
};

export const LoadingDataAsynchronously = () => {
const [input, setInput] = React.useState('world');
return (
<App>
{() => (
<React.Fragment>
<input value={input} onChange={(e) => setInput(e.target.value)}/>
Expand All @@ -26,4 +29,6 @@ storiesOf('Data Loader', module)
</React.Fragment>
)}
</App>
});
);
};
LoadingDataAsynchronously.storyName = 'loading data asynchronously';
24 changes: 18 additions & 6 deletions stories/dropdown.tsx → stories/dropdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';

import { DropDown } from '../src/components/dropdown/dropdown';
import { DropDownMenu } from '../src/components/dropdown-menu';

storiesOf('Dropdown', module)
.add('default', () => <DropDown anchor={() => <a>Click me</a>}><p>Dropdown content here</p></DropDown>)
.add('menu', () => (
export default {
title: 'Dropdown',
};

export const Default = () => (<DropDown anchor={() => <a>Click me</a>}><p>Dropdown content here</p></DropDown>);
Default.storyName = 'default';

export const Menu = () => {
return (
<DropDown isMenu={true} anchor={() => <a>Click me</a>}>
<ul>
<li><a>menu item 1</a></li>
<li><a>menu item 2</a></li>
</ul>
</DropDown>
)).add('menu wrapper', () => (
);
}
Menu.storyName = 'menu';

export const MenuWrapper = () => {
return (
<DropDownMenu anchor={() => <a>Click me</a>} items={[{
title: 'menu item 1',
action: () => window.alert('Clicked!'),
}]} />
));
);
}
MenuWrapper.storyName = 'menu wrapper';
15 changes: 10 additions & 5 deletions stories/forms.tsx → stories/forms.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { Form, Text } from 'react-form';

import { FormField, FormSelect } from '../src/components/form-field/form-field';

storiesOf('Forms', module)
.add('default', () => (
export default {
title: 'Forms',
};

export const Default = () => {
return (
<Form>
{(api) => (
<form style={{padding: '1em'}}>
Expand All @@ -16,9 +19,11 @@ storiesOf('Forms', module)
<FormField label='Password' formApi={api} field='passwordField' component={Text} componentProps={{type: 'password'}} />
</div>
<div className='argo-form-row'>
<FormField label='Select' formApi={api} field='selectField' component={FormSelect} componentProps={{options: ['option1', 'option2']}} />
<FormField label='Select' formApi={api} field='selectField' component={FormSelect} componentProps={{options: ['option1', 'option2']}} />
</div>
</form>
)}
</Form>
));
);
}
Default.storyName = 'default';
10 changes: 0 additions & 10 deletions stories/index.stories.tsx

This file was deleted.

10 changes: 7 additions & 3 deletions stories/logs-viewer.tsx → stories/logs-viewer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { Observable } from 'rxjs';

import { LogsViewer } from '../src/components/logs-viewer/logs-viewer';

storiesOf('LogsViewer', module).add('default', () => (
export default {
title: 'LogsViewer',
};

export const Default = () => (
<div>
<LogsViewer source={{
key: 'test',
Expand All @@ -15,4 +18,5 @@ storiesOf('LogsViewer', module).add('default', () => (
shouldRepeat: () => false,
}}/>
</div>
));
);
Default.storyName = 'default';
36 changes: 20 additions & 16 deletions stories/notifications.tsx → stories/notifications.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';

import { NotificationType } from '../src/components/notifications/notifications';
Expand All @@ -15,20 +14,25 @@ function getMessage() {
return messages[Math.floor(Math.random() * messages.length)];
}

storiesOf('Notifications', module)
.add('default', () => (
export default {
title: 'Notifications',
};

export const Default = () => {
return (
<App>
{(apis) => (
[
{type: NotificationType.Success, title: 'Success'},
{type: NotificationType.Warning, title: 'Warning'},
{type: NotificationType.Error, title: 'Error'},
].map((item) => (
<button key={item.type} className='argo-button argo-button--base'
onClick={() => apis.notifications.show({type: item.type, content: <div>{getMessage()}</div>})}>
{item.title}
</button>
))
)}
{(apis) => [
{type: NotificationType.Success, title: 'Success'},
{type: NotificationType.Warning, title: 'Warning'},
{type: NotificationType.Error, title: 'Error'},
].map((item) => (
<button key={item.type} className='argo-button argo-button--base' onClick={() =>
apis.notifications.show({type: item.type, content: <div>{getMessage()}</div>})
}>
{item.title}
</button>
))}
</App>
));
);
}
Default.storyName = 'default';
Loading