Skip to content

Commit 61497af

Browse files
authored
feat: finish integrating storybook (#75)
1 parent 64711dc commit 61497af

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

.storybook/addons.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
import 'storybook-readme/register';
2+
import '@storybook/addon-knobs/register';
3+
import '@storybook/addon-viewport/register';
14
import '@storybook/addon-actions/register';
2-
import '@storybook/addon-links/register';
5+
import '@storybook/addon-options/register';

.storybook/config.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
import { configure } from '@storybook/react';
1+
import React from 'react';
2+
import { addDecorator, configure } from '@storybook/react';
3+
import { withKnobs } from '@storybook/addon-knobs';
4+
import { withViewport } from '@storybook/addon-viewport';
5+
import { withOptions } from '@storybook/addon-options';
26

3-
// automatically import all files ending in *.stories.js
4-
const req = require.context('../src', true, /.stories.tsx$/);
7+
// inject custom css to all stories
8+
addDecorator(story => (
9+
<div style={{ fontFamily: '"Roboto", sans-serif' }}>{story()}</div>
10+
));
11+
12+
// setup global addons
13+
addDecorator(withKnobs);
14+
addDecorator(withViewport);
15+
addDecorator(
16+
withOptions({
17+
name: 'Doc UI',
18+
url: 'https://github.com/shockits/doc-ui',
19+
})
20+
);
21+
22+
// automatically import all storybook files
23+
const req = require.context('../src', true, /.stories.(ts|tsx)$/);
524
function loadStories() {
625
req.keys().forEach(filename => req(filename));
726
}

.storybook/preview-head.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<link
2+
href="https://fonts.googleapis.com/css?family=Roboto:400,500,700"
3+
rel="stylesheet"
4+
/>

.storybook/webpack.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
const path = require('path');
2-
31
module.exports = (baseConfig, env, config) => {
42
config.resolve.extensions.push('.ts', '.tsx');
53
config.module.rules.push({
64
test: /\.(ts|tsx)$/,
75
exclude: /node_modules/,
8-
loader: require.resolve('awesome-typescript-loader'),
6+
loaders: [
7+
require.resolve('babel-loader'),
8+
require.resolve('awesome-typescript-loader'),
9+
],
910
});
1011

1112
return config;

0 commit comments

Comments
 (0)