Skip to content

Commit 2832b7a

Browse files
authored
chore: move all stories from src directory. (#715)
chore: clean tsconfig.json; feat: updated webpack config to export a function to achieve full-control mode, instead of deprecated Extend Mode;
1 parent 8c35bc9 commit 2832b7a

File tree

106 files changed

+238
-233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+238
-233
lines changed

.storybook/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ setOptions({
1212
sidebarAnimations: false,
1313
});
1414

15-
const req = require.context('../src/', true, /.*\.(stories|story)\.(js|jsx|ts|tsx)?$/);
15+
const req = require.context('../stories/', true, /\.story\.tsx?$/);
1616

1717
const loadStories = () => {
1818
req.keys().forEach((filename) => req(filename));

.storybook/webpack.config.js

+33-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
const path = require('path');
2-
const {compilerOptions} = require('../tsconfig.json');
2+
const { compilerOptions } = require('../tsconfig.json');
33
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
44

5-
const SRC_PATH = path.join(__dirname, '../src');
5+
const basedir = path.join(__dirname, '..');
66

7-
module.exports = {
8-
module: {
9-
rules: [
10-
{
11-
test: /\.md?$/,
12-
loader: "markdown-loader",
13-
},
14-
{
15-
test: /\.tsx?$/,
16-
loader: 'ts-loader',
17-
include: [
18-
SRC_PATH,
19-
],
20-
options: {
21-
transpileOnly: true, // use transpileOnly mode to speed-up compilation
22-
compilerOptions: {
23-
...compilerOptions,
24-
declaration: false,
25-
},
7+
module.exports = async ({ config, mode }) => {
8+
config.module.rules.push(
9+
{
10+
test: /\.md?$/,
11+
loader: "markdown-loader",
12+
},
13+
{
14+
test: /\.tsx?$/,
15+
loader: 'ts-loader',
16+
include: [
17+
path.join(basedir, 'src'),
18+
path.join(basedir, 'stories'),
19+
],
20+
options: {
21+
transpileOnly: true, // use transpileOnly mode to speed-up compilation
22+
compilerOptions: {
23+
...compilerOptions,
24+
declaration: false,
2625
},
27-
}
28-
]
29-
},
30-
resolve: {
31-
extensions: ['.ts', '.tsx', '.js', '.jsx'],
32-
enforceExtension: false
33-
},
34-
plugins: [new ForkTsCheckerWebpackPlugin()],
26+
},
27+
},
28+
);
29+
30+
config.plugins.push(new ForkTsCheckerWebpackPlugin());
31+
32+
config.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx'];
33+
config.resolve.enforceExtension = false;
34+
35+
// disable the hint about too big bundle
36+
config.performance.hints = false;
37+
38+
return config;
3539
};

src/comps/__stories__/UseKey.story.tsx stories/comps/UseKey.story.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import UseKey from '../UseKey';
3+
import UseKey from '../../src/comps/UseKey';
44

55
storiesOf('Components|<UseKey>', module).add('Demo', () => (
66
<div>

src/__stories__/createBreakpoint.story.tsx stories/createBreakpoint.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { withKnobs } from '@storybook/addon-knobs';
22
import { storiesOf } from '@storybook/react';
33
import React from 'react';
4-
import { createBreakpoint } from '..';
4+
import { createBreakpoint } from '../src';
55
import ShowDocs from './util/ShowDocs';
66

77
const useBreakpointA = createBreakpoint();
@@ -23,7 +23,7 @@ const Demo = () => {
2323

2424
storiesOf('sensors|createBreakpoint', module)
2525
.addDecorator(withKnobs)
26-
.add('Docs', () => <ShowDocs md={require('../../docs/createBreakpoint.md')} />)
26+
.add('Docs', () => <ShowDocs md={require('../docs/createBreakpoint.md')} />)
2727
.add('Demo', () => {
2828
return <Demo />;
2929
});

src/__stories__/createMemo.story.tsx stories/createMemo.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { createMemo } from '..';
3+
import { createMemo } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const fibonacci = n => {
@@ -22,5 +22,5 @@ const Demo = () => {
2222
};
2323

2424
storiesOf('State|createMemo', module)
25-
.add('Docs', () => <ShowDocs md={require('../../docs/createMemo.md')} />)
25+
.add('Docs', () => <ShowDocs md={require('../docs/createMemo.md')} />)
2626
.add('Demo', () => <Demo />);

src/__stories__/createReducer.story.tsx stories/createReducer.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from 'react';
33
import logger from 'redux-logger';
44
import thunk from 'redux-thunk';
55

6-
import { createReducer } from '..';
6+
import { createReducer } from '../src';
77
import ShowDocs from './util/ShowDocs';
88

99
const useThunkReducer = createReducer(thunk, logger);
@@ -53,5 +53,5 @@ const Demo = ({ initialCount = 1 }) => {
5353
};
5454

5555
storiesOf('State|createReducer', module)
56-
.add('Docs', () => <ShowDocs md={require('../../docs/createReducer.md')} />)
56+
.add('Docs', () => <ShowDocs md={require('../docs/createReducer.md')} />)
5757
.add('Demo', () => <Demo />);

src/__stories__/useAsync.story.tsx stories/useAsync.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { number, withKnobs } from '@storybook/addon-knobs';
22
import { storiesOf } from '@storybook/react';
33
import * as React from 'react';
4-
import { useAsync } from '..';
4+
import { useAsync } from '../src';
55
import ShowDocs from './util/ShowDocs';
66

77
const Demo = ({ delay }) => {
@@ -35,7 +35,7 @@ const Demo = ({ delay }) => {
3535

3636
storiesOf('Side effects|useAsync', module)
3737
.addDecorator(withKnobs)
38-
.add('Docs', () => <ShowDocs md={require('../../docs/useAsync.md')} />)
38+
.add('Docs', () => <ShowDocs md={require('../docs/useAsync.md')} />)
3939
.add('Demo', () => {
4040
const delay = number('delay', 1000, { range: true, min: 100, max: 5000, step: 100 });
4141
return <Demo delay={delay} />;

src/__stories__/useAsyncFn.story.tsx stories/useAsyncFn.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useAsyncFn } from '..';
3+
import { useAsyncFn } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -33,5 +33,5 @@ const Demo = () => {
3333
};
3434

3535
storiesOf('Side effects|useAsyncFn', module)
36-
.add('Docs', () => <ShowDocs md={require('../../docs/useAsyncFn.md')} />)
36+
.add('Docs', () => <ShowDocs md={require('../docs/useAsyncFn.md')} />)
3737
.add('Demo', () => <Demo />);

src/__stories__/useAsyncRetry.story.tsx stories/useAsyncRetry.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { number, withKnobs } from '@storybook/addon-knobs';
22
import { storiesOf } from '@storybook/react';
33
import * as React from 'react';
4-
import { useAsyncRetry } from '..';
4+
import { useAsyncRetry } from '../src';
55
import ShowDocs from './util/ShowDocs';
66

77
const Demo = ({ delay }) => {
@@ -36,7 +36,7 @@ const Demo = ({ delay }) => {
3636

3737
storiesOf('Side effects|useAsyncRetry', module)
3838
.addDecorator(withKnobs)
39-
.add('Docs', () => <ShowDocs md={require('../../docs/useAsyncRetry.md')} />)
39+
.add('Docs', () => <ShowDocs md={require('../docs/useAsyncRetry.md')} />)
4040
.add('Demo', () => {
4141
const delay = number('delay', 1000, { range: true, min: 100, max: 5000, step: 100 });
4242
return <Demo delay={delay} />;

src/__stories__/useAudio.story.tsx stories/useAudio.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useAudio } from '..';
3+
import { useAudio } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -30,5 +30,5 @@ const Demo = () => {
3030
};
3131

3232
storiesOf('UI|useAudio', module)
33-
.add('Docs', () => <ShowDocs md={require('../../docs/useAudio.md')} />)
33+
.add('Docs', () => <ShowDocs md={require('../docs/useAudio.md')} />)
3434
.add('Demo', () => <Demo />);

src/__stories__/useBattery.story.tsx stories/useBattery.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useBattery } from '..';
3+
import { useBattery } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -37,5 +37,5 @@ const Demo = () => {
3737
};
3838

3939
storiesOf('Sensors|useBattery', module)
40-
.add('Docs', () => <ShowDocs md={require('../../docs/useBattery.md')} />)
40+
.add('Docs', () => <ShowDocs md={require('../docs/useBattery.md')} />)
4141
.add('Demo', () => <Demo />);

src/__stories__/useBeforeUnload.story.tsx stories/useBeforeUnload.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useBeforeUnload, useToggle } from '..';
3+
import { useBeforeUnload, useToggle } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -16,5 +16,5 @@ const Demo = () => {
1616
};
1717

1818
storiesOf('Side effects|useBeforeUnload', module)
19-
.add('Docs', () => <ShowDocs md={require('../../docs/useBeforeUnload.md')} />)
19+
.add('Docs', () => <ShowDocs md={require('../docs/useBeforeUnload.md')} />)
2020
.add('Demo', () => <Demo />);

src/__stories__/useBoolean.story.tsx stories/useBoolean.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useBoolean } from '..';
3+
import { useBoolean } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -17,5 +17,5 @@ const Demo = () => {
1717
};
1818

1919
storiesOf('State|useBoolean', module)
20-
.add('Docs', () => <ShowDocs md={require('../../docs/useToggle.md')} />)
20+
.add('Docs', () => <ShowDocs md={require('../docs/useToggle.md')} />)
2121
.add('Demo', () => <Demo />);

src/__stories__/useClickAway.story.tsx stories/useClickAway.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { action } from '@storybook/addon-actions';
22
import { storiesOf } from '@storybook/react';
33
import * as React from 'react';
44
import { useRef } from 'react';
5-
import { useClickAway } from '..';
5+
import { useClickAway } from '../src';
66
import ShowDocs from './util/ShowDocs';
77

88
const Demo = () => {
@@ -22,5 +22,5 @@ const Demo = () => {
2222
};
2323

2424
storiesOf('UI|useClickAway', module)
25-
.add('Docs', () => <ShowDocs md={require('../../docs/useClickAway.md')} />)
25+
.add('Docs', () => <ShowDocs md={require('../docs/useClickAway.md')} />)
2626
.add('Demo', () => <Demo />);

src/__stories__/useCopyToClipboard.story.tsx stories/useCopyToClipboard.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useCopyToClipboard } from '..';
3+
import { useCopyToClipboard } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -30,5 +30,5 @@ const Demo = () => {
3030
};
3131

3232
storiesOf('Side-effects|useCopyToClipboard', module)
33-
.add('Docs', () => <ShowDocs md={require('../../docs/useCopyToClipboard.md')} />)
33+
.add('Docs', () => <ShowDocs md={require('../docs/useCopyToClipboard.md')} />)
3434
.add('Demo', () => <Demo />);

src/__stories__/useCounter.story.tsx stories/useCounter.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useCounter } from '..';
3+
import { useCounter } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -42,5 +42,5 @@ const Demo = () => {
4242
};
4343

4444
storiesOf('State|useCounter', module)
45-
.add('Docs', () => <ShowDocs md={require('../../docs/useCounter.md')} />)
45+
.add('Docs', () => <ShowDocs md={require('../docs/useCounter.md')} />)
4646
.add('Demo', () => <Demo />);

src/__stories__/useCss.story.tsx stories/useCss.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useCss } from '..';
3+
import { useCss } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -16,5 +16,5 @@ const Demo = () => {
1616
};
1717

1818
storiesOf('UI|useCss', module)
19-
.add('Docs', () => <ShowDocs md={require('../../docs/useCss.md')} />)
19+
.add('Docs', () => <ShowDocs md={require('../docs/useCss.md')} />)
2020
.add('Demo', () => <Demo />);

src/__stories__/useDebounce.story.tsx stories/useDebounce.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useDebounce } from '..';
3+
import { useDebounce } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -38,5 +38,5 @@ const Demo = () => {
3838
};
3939

4040
storiesOf('Side effects|useDebounce', module)
41-
.add('Docs', () => <ShowDocs md={require('../../docs/useDebounce.md')} />)
41+
.add('Docs', () => <ShowDocs md={require('../docs/useDebounce.md')} />)
4242
.add('Demo', () => <Demo />);

src/__stories__/useDeepCompareEffect.story.tsx stories/useDeepCompareEffect.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useCounter, useDeepCompareEffect } from '..';
3+
import { useCounter, useDeepCompareEffect } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -29,5 +29,5 @@ const Demo = () => {
2929
};
3030

3131
storiesOf('Lifecycle|useDeepCompareEffect', module)
32-
.add('Docs', () => <ShowDocs md={require('../../docs/useDeepCompareEffect.md')} />)
32+
.add('Docs', () => <ShowDocs md={require('../docs/useDeepCompareEffect.md')} />)
3333
.add('Demo', () => <Demo />);

src/__stories__/useDefault.story.tsx stories/useDefault.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useDefault } from '..';
3+
import { useDefault } from '../src';
44
import ShowDocs from './util/ShowDocs';
55

66
const Demo = () => {
@@ -18,5 +18,5 @@ const Demo = () => {
1818
};
1919

2020
storiesOf('State|useDefault', module)
21-
.add('Docs', () => <ShowDocs md={require('../../docs/useDefault.md')} />)
21+
.add('Docs', () => <ShowDocs md={require('../docs/useDefault.md')} />)
2222
.add('Demo', () => <Demo />);

src/__stories__/useDrop.story.tsx stories/useDrop.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { action } from '@storybook/addon-actions';
22
import { storiesOf } from '@storybook/react';
33
import * as React from 'react';
4-
import { useDrop } from '..';
4+
import { useDrop } from '../src';
55
import ShowDocs from './util/ShowDocs';
66

77
const Demo = () => {
@@ -50,5 +50,5 @@ const Demo = () => {
5050
};
5151

5252
storiesOf('UI|useDrop', module)
53-
.add('Docs', () => <ShowDocs md={require('../../docs/useDrop.md')} />)
53+
.add('Docs', () => <ShowDocs md={require('../docs/useDrop.md')} />)
5454
.add('Demo', () => <Demo />);

src/__stories__/useDropArea.story.tsx stories/useDropArea.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { action } from '@storybook/addon-actions';
22
import { storiesOf } from '@storybook/react';
33
import * as React from 'react';
4-
import { useDropArea } from '..';
4+
import { useDropArea } from '../src';
55
import ShowDocs from './util/ShowDocs';
66

77
const Demo = () => {
@@ -52,5 +52,5 @@ const Demo = () => {
5252
};
5353

5454
storiesOf('UI|useDropArea', module)
55-
.add('Docs', () => <ShowDocs md={require('../../docs/useDrop.md')} />)
55+
.add('Docs', () => <ShowDocs md={require('../docs/useDrop.md')} />)
5656
.add('Default', () => <Demo />);

src/__stories__/useEffectOnce.story.tsx stories/useEffectOnce.story.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { storiesOf } from '@storybook/react';
22
import * as React from 'react';
3-
import { useEffectOnce } from '..';
3+
import { useEffectOnce } from '../src';
44
import ConsoleStory from './util/ConsoleStory';
55
import ShowDocs from './util/ShowDocs';
66

@@ -17,5 +17,5 @@ const Demo = () => {
1717
};
1818

1919
storiesOf('Lifecycle|useEffectOnce', module)
20-
.add('Docs', () => <ShowDocs md={require('../../docs/useEffectOnce.md')} />)
20+
.add('Docs', () => <ShowDocs md={require('../docs/useEffectOnce.md')} />)
2121
.add('Demo', () => <Demo />);

0 commit comments

Comments
 (0)