Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit e15ed2e

Browse files
committed
Update storybook config and add loading stories
1 parent 8f7c884 commit e15ed2e

File tree

9 files changed

+338
-47
lines changed

9 files changed

+338
-47
lines changed

.storybook/addons.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import '@storybook/addon-actions/register';
22
import '@storybook/addon-links/register';
3+
import '@storybook/addon-knobs/register';

.storybook/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { configure } from '@storybook/react';
22

3+
import 'antd/dist/antd.css';
4+
import '../src/index.css';
5+
6+
// automatically import all files ending in *.stories.tsx
7+
const req = require.context('../src', true, /\.stories\.tsx$/);
8+
39
function loadStories() {
4-
require('../src/stories');
10+
req.keys().forEach(req);
511
}
612

713
configure(loadStories, module);

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "0.1.0",
55
"private": true,
66
"dependencies": {
7+
"@storybook/addon-knobs": "^5.1.9",
78
"@types/classnames": "^2.2.8",
89
"@types/dva": "^1.1.0",
910
"@types/enzyme": "^3.9.4",
@@ -16,8 +17,9 @@
1617
"@types/react-dom": "^16.8.4",
1718
"@types/react-infinite-scroller": "^1.2.1",
1819
"@types/react-loadable": "^5.5.1",
19-
"@types/redux-form": "^8.1.4",
2020
"@types/redux-logger": "^3.0.7",
21+
"@types/storybook__addon-knobs": "^5.0.2",
22+
"@types/storybook__react": "^4.0.2",
2123
"antd": "^3.19.8",
2224
"axios": "^0.19.0",
2325
"classnames": "^2.2.6",
@@ -55,7 +57,7 @@
5557
"staging": "cross-env REACT_APP_BUILD=staging react-app-rewired start",
5658
"test": "react-app-rewired test",
5759
"jest": "CI=true react-app-rewired test",
58-
"tslint": "tslint --fix 'src/**/*.ts*'",
60+
"tslint": "tslint --fix 'src/**/*.(ts|tsx)'",
5961
"mock": "json-server mock/db.js",
6062
"storybook": "start-storybook -p 9009 -s public",
6163
"build-storybook": "build-storybook -s public"
@@ -66,7 +68,7 @@
6668
}
6769
},
6870
"lint-staged": {
69-
"*.ts*": [
71+
"*.(ts|tsx)": [
7072
"npm run check"
7173
]
7274
},
@@ -81,6 +83,7 @@
8183
],
8284
"devDependencies": {
8385
"@storybook/addon-actions": "^5.1.9",
86+
"@storybook/addon-info": "^5.1.9",
8487
"@storybook/addon-links": "^5.1.9",
8588
"@storybook/addons": "^5.1.9",
8689
"@storybook/react": "^5.1.9",

src/App.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ beforeAll(() => {
1616
app.router(() => ({}));
1717
app.start();
1818
wrapper = shallow(
19-
<StaticRouter context={{}}>
20-
<App store={app._store} location={{pathname: '/app/dashboard'}} />
21-
</StaticRouter>
19+
<StaticRouter context={{}}>
20+
<App store={app._store} location={{pathname: '/app/dashboard'}} />
21+
</StaticRouter>
2222
);
2323
});
2424

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
3+
import { storiesOf } from '@storybook/react';
4+
5+
import Loading from './Loading';
6+
7+
storiesOf('Loading', module)
8+
.add('default', () => <Loading />);

src/components/Loading/Loading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
import styles from './Loading.module.scss';
55

66
export default function Loading() {
7-
const antIcon = <Icon type="loading" style={{ fontSize: 24 }} spin />;
7+
const antIcon = <Icon type="loading" style={{ fontSize: 40 }} spin />;
88

99
return (
1010
<div className={styles.loading}>

src/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import dva from 'dva';
22
import createLoading from 'dva-loading';
33
import * as React from 'react';
4-
import { reducer as formReducer } from 'redux-form';
54
import { createLogger } from 'redux-logger';
65

76
import { Env, EnvType } from './env';
@@ -25,10 +24,6 @@ const app: any = dva({
2524

2625
onAction: middleware,
2726

28-
// 其他第三方 Reducer 配置
29-
extraReducers: {
30-
form: formReducer,
31-
},
3227
});
3328

3429
// 第三方插件

src/stories/index.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)