Skip to content

Commit

Permalink
feat: finish integrating storybook (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
miketdonahue authored Dec 24, 2018
1 parent 64711dc commit 61497af
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .storybook/addons.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import 'storybook-readme/register';
import '@storybook/addon-knobs/register';
import '@storybook/addon-viewport/register';
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
import '@storybook/addon-options/register';
25 changes: 22 additions & 3 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import { configure } from '@storybook/react';
import React from 'react';
import { addDecorator, configure } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import { withViewport } from '@storybook/addon-viewport';
import { withOptions } from '@storybook/addon-options';

// automatically import all files ending in *.stories.js
const req = require.context('../src', true, /.stories.tsx$/);
// inject custom css to all stories
addDecorator(story => (
<div style={{ fontFamily: '"Roboto", sans-serif' }}>{story()}</div>
));

// setup global addons
addDecorator(withKnobs);
addDecorator(withViewport);
addDecorator(
withOptions({
name: 'Doc UI',
url: 'https://github.com/shockits/doc-ui',
})
);

// automatically import all storybook files
const req = require.context('../src', true, /.stories.(ts|tsx)$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
Expand Down
4 changes: 4 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<link
href="https://fonts.googleapis.com/css?family=Roboto:400,500,700"
rel="stylesheet"
/>
7 changes: 4 additions & 3 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const path = require('path');

module.exports = (baseConfig, env, config) => {
config.resolve.extensions.push('.ts', '.tsx');
config.module.rules.push({
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: require.resolve('awesome-typescript-loader'),
loaders: [
require.resolve('babel-loader'),
require.resolve('awesome-typescript-loader'),
],
});

return config;
Expand Down

0 comments on commit 61497af

Please sign in to comment.