Skip to content

Commit 0121d2c

Browse files
committed
Migrate to storybook 6
1 parent 952874a commit 0121d2c

File tree

9 files changed

+1141
-1497
lines changed

9 files changed

+1141
-1497
lines changed

.storybook/main.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
11
module.exports = {
22
stories: [
33
'../docs/start.stories.mdx',
4-
'../docs/**/*.stories.([tj]sx|mdx)',
5-
'../src/**/*.stories.([tj]sx|mdx)'
4+
'../src/**/*.stories.@([tj]sx|mdx)',
5+
'../docs/**/*.stories.@([tj]sx|mdx)'
66
],
77
addons: [
8-
'@storybook/preset-typescript',
98
'@storybook/addon-actions/register',
10-
'@storybook/addon-storysource',
11-
'@storybook/addon-docs'
12-
],
13-
webpackFinal: async config => {
14-
config.module.rules.push({
15-
test: /\.(ts|tsx)$/,
16-
use: [
17-
{
18-
loader: require.resolve('babel-loader'),
19-
options: {
20-
presets: [['react-app', { flow: false, typescript: true }]]
21-
}
22-
},
23-
{
24-
loader: require.resolve('react-docgen-typescript-loader'),
25-
},
26-
],
27-
});
28-
config.resolve.extensions.push('.ts', '.tsx');
29-
return config;
30-
},
9+
'@storybook/addon-storysource',
10+
{
11+
name: '@storybook/addon-docs',
12+
options: {
13+
configureJSX: true,
14+
},
15+
}
16+
]
3117
};

docs/antd-integration.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Meta, Description, Source } from '@storybook/addon-docs/blocks';
22
import Readme from '../README.md';
33

4-
<Meta title="Usage|Integrations/Ant Design" />
4+
<Meta title="Integrations/Ant Design" />
55

66
# Ant Design integration
77
This page shows how an input and a preview component with Ant Design (`>= 4`) can be built and connected to this component.

docs/material-integration.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta, Description, Source } from '@storybook/addon-docs/blocks';
22

3-
<Meta title="Usage|Integrations/Material UI" />
3+
<Meta title="Integrations/Material UI" />
44

55
# Material UI integration
66
This page shows how an input and a preview component with Material UI can be built and connected to this component. It's possible to put everything into one file.

docs/start.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Meta, Description } from '@storybook/addon-docs/blocks';
22
import Readme from '../README.md';
33

4-
<Meta title="Start|ReadMe" />
4+
<Meta title="Start" />
55

66
<Description markdown={Readme} />

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
"@emotion/core": "^10.0.28",
1717
"@emotion/styled": "^10.0.27",
1818
"@rollup/plugin-typescript": "^5.0.2",
19-
"@storybook/addon-actions": "^5.3.19",
20-
"@storybook/addon-docs": "^5.3.19",
21-
"@storybook/addon-info": "^5.3.19",
22-
"@storybook/addon-links": "^5.3.19",
23-
"@storybook/addon-storysource": "^5.3.19",
24-
"@storybook/addons": "^5.3.19",
25-
"@storybook/preset-typescript": "^3.0.0",
26-
"@storybook/react": "^5.3.19",
27-
"@testing-library/jest-dom": "^5.11.0",
28-
"@testing-library/react": "^10.4.6",
19+
"@storybook/addon-actions": "^6.0.0-rc.5",
20+
"@storybook/addon-docs": "^6.0.0-rc.5",
21+
"@storybook/addon-links": "^6.0.0-rc.5",
22+
"@storybook/addon-storysource": "^6.0.0-rc.5",
23+
"@storybook/addons": "^6.0.0-rc.5",
24+
"@storybook/react": "^6.0.0-rc.5",
25+
"@testing-library/jest-dom": "^5.11.1",
26+
"@testing-library/react": "^10.4.7",
2927
"@testing-library/react-hooks": "^3.3.0",
3028
"@types/jest": "^26.0.4",
3129
"@types/node": "^14.0.23",
@@ -41,7 +39,7 @@
4139
"eslint-plugin-react": "^7.20.3",
4240
"jest": "^26.1.0",
4341
"prettier": "^2.0.5",
44-
"react-docgen-typescript-loader": "^3.7.2",
42+
"react-docgen": "^5.3.0",
4543
"react-is": "^16.13.1",
4644
"react-test-renderer": "^16.13.1",
4745
"rollup": "^2.21.0",

src/DSVImport.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { action } from '@storybook/addon-actions';
44
import styled from '@emotion/styled';
55

66
export default {
7-
title: 'Usage|Components/DSVImport',
7+
title: 'Components/DSVImport',
88
component: DSVImport,
99
parameters: {
1010
componentSubtitle: 'Wrapping component'
@@ -28,7 +28,7 @@ export const BasicUsage = () => {
2828
</DSVImport>
2929
);
3030
};
31-
BasicUsage.story = { name: 'Basic usage' };
31+
BasicUsage.story = { name: 'Basic usage', parameters: { docs: { storyDescription: 'Hello' } } };
3232

3333
export const UsingOnChangeCallback = () => {
3434
const columns: ColumnType<BasicType>[] = [

src/DSVImport.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,29 @@ const EventListener = <T extends GenericColumnType>(props: EventListenerProps<T>
3232
return null;
3333
};
3434

35-
export interface Props<T> {
35+
export type Props<T> = {
36+
/**
37+
* Description of the expected columns
38+
*/
3639
columns: ColumnType<T>[];
40+
/**
41+
* Callback which is called after parsing the input
42+
*/
3743
onChange?: (value: T[]) => void;
44+
/**
45+
* Callback which is called if there are validation errors
46+
*/
3847
onValidation?: (errors: ValidationError<T>[]) => void;
48+
/**
49+
* Globally applied transformers
50+
*/
3951
transformers?: Transformer[];
40-
}
52+
};
4153

4254
/**
43-
* Joho
44-
* @param props Joho
55+
* Hello
4556
*/
46-
export const DSVImport = <T extends GenericColumnType>(props: PropsWithChildren<Props<T>>) => {
57+
export function DSVImport<T extends GenericColumnType>(props: PropsWithChildren<Props<T>>) {
4758
const DSVImportContext = getDSVImportContext<T>();
4859
const initialValues: State<T> = { columns: props.columns, transformers: props.transformers };
4960
const [state, dispatch] = useReducer(createReducer<T>(), initialValues);
@@ -61,4 +72,4 @@ export const DSVImport = <T extends GenericColumnType>(props: PropsWithChildren<
6172
{props.children}
6273
</DSVImportContext.Provider>
6374
);
64-
};
75+
}

src/middlewares/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const applyMiddlewares = <T, A>(state: State<T>, dispatch: Dispatch<A>, .
1818
nextMiddlewares.forEach((m, i) => {
1919
m(state, next(without(nextMiddlewares, i)), value);
2020
});
21-
}
21+
};
2222

2323
call(middlewares, action);
2424
};

0 commit comments

Comments
 (0)