Skip to content

Commit 1d8f123

Browse files
Kyle Holmbergjaredpalmer
Kyle Holmberg
authored andcommitted
Integrate new Storybook config (#435)
* Add new dependencies for Docs * Update config * Redefine demo component and story
1 parent ce3ff8e commit 1d8f123

File tree

9 files changed

+50
-42
lines changed

9 files changed

+50
-42
lines changed

src/templates/react-with-storybook.ts

+4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ const storybookTemplate: Template = {
88
'@babel/core',
99
'@storybook/addon-actions',
1010
'@storybook/addon-links',
11+
'@storybook/addon-info',
12+
'@storybook/addon-docs',
1113
'@storybook/addons',
1214
'@storybook/react',
15+
'react-docgen-typescript-loader',
16+
'react-is',
1317
'babel-loader',
1418
'ts-loader',
1519
],

templates/react-with-storybook/.storybook/addons.ts

-2
This file was deleted.

templates/react-with-storybook/.storybook/config.ts

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
stories: ['../stories/**/*.stories.(ts|tsx)'],
3+
addons: ['@storybook/addon-actions', '@storybook/addon-links', '@storybook/addon-docs'],
4+
webpackFinal: async (config) => {
5+
config.module.rules.push({
6+
test: /\.(ts|tsx)$/,
7+
use: [
8+
{
9+
loader: require.resolve('ts-loader'),
10+
options: {
11+
transpileOnly: true,
12+
},
13+
},
14+
{
15+
loader: require.resolve('react-docgen-typescript-loader'),
16+
},
17+
],
18+
});
19+
20+
config.resolve.extensions.push('.ts', '.tsx');
21+
22+
return config;
23+
},
24+
};

templates/react-with-storybook/.storybook/webpack.config.js

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import * as React from 'react';
1+
import React, { FC, HTMLAttributes, ReactChild } from 'react';
22

3-
// Delete me
4-
export const Thing = () => {
5-
return <div>the snozzberries taste like snozzberries</div>;
3+
export interface Props extends HTMLAttributes<HTMLDivElement> {
4+
children?: ReactChild;
5+
}
6+
7+
// Please do not use types off of a default export module or else Storybook Docs will suffer.
8+
// see: https://github.com/storybookjs/storybook/issues/9556
9+
export const Thing: FC<Props> = ({ children }) => {
10+
return <div>{children || `the snozzberries taste like snozzberries`}</div>;
611
};

templates/react-with-storybook/stories/0-Welcome.stories.tsx

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import { Thing, Props } from '../src';
3+
4+
export default {
5+
title: 'Welcome',
6+
};
7+
8+
// By passing optional props to this story, you can control the props of the component when
9+
// you consume the story in a test.
10+
export const Default = (props?: Partial<Props>) => <Thing {...props} />;

templates/react-with-storybook/test/blah.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import * as ReactDOM from 'react-dom';
3-
import { Thing } from '../src';
3+
import { Default as Thing } from '../stories/Thing.stories';
44

5-
describe('it', () => {
5+
describe('Thing', () => {
66
it('renders without crashing', () => {
77
const div = document.createElement('div');
88
ReactDOM.render(<Thing />, div);

0 commit comments

Comments
 (0)