Skip to content

Commit

Permalink
Integrate new Storybook config (#435)
Browse files Browse the repository at this point in the history
* Add new dependencies for Docs

* Update config

* Redefine demo component and story
  • Loading branch information
Kyle Holmberg authored and jaredpalmer committed Jan 21, 2020
1 parent ce3ff8e commit 1d8f123
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 42 deletions.
4 changes: 4 additions & 0 deletions src/templates/react-with-storybook.ts
Expand Up @@ -8,8 +8,12 @@ const storybookTemplate: Template = {
'@babel/core',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-info',
'@storybook/addon-docs',
'@storybook/addons',
'@storybook/react',
'react-docgen-typescript-loader',
'react-is',
'babel-loader',
'ts-loader',
],
Expand Down
2 changes: 0 additions & 2 deletions templates/react-with-storybook/.storybook/addons.ts

This file was deleted.

4 changes: 0 additions & 4 deletions templates/react-with-storybook/.storybook/config.ts

This file was deleted.

24 changes: 24 additions & 0 deletions templates/react-with-storybook/.storybook/main.js
@@ -0,0 +1,24 @@
module.exports = {
stories: ['../stories/**/*.stories.(ts|tsx)'],
addons: ['@storybook/addon-actions', '@storybook/addon-links', '@storybook/addon-docs'],
webpackFinal: async (config) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('ts-loader'),
options: {
transpileOnly: true,
},
},
{
loader: require.resolve('react-docgen-typescript-loader'),
},
],
});

config.resolve.extensions.push('.ts', '.tsx');

return config;
},
};
17 changes: 0 additions & 17 deletions templates/react-with-storybook/.storybook/webpack.config.js

This file was deleted.

13 changes: 9 additions & 4 deletions templates/react-with-storybook/src/index.tsx
@@ -1,6 +1,11 @@
import * as React from 'react';
import React, { FC, HTMLAttributes, ReactChild } from 'react';

// Delete me
export const Thing = () => {
return <div>the snozzberries taste like snozzberries</div>;
export interface Props extends HTMLAttributes<HTMLDivElement> {
children?: ReactChild;
}

// Please do not use types off of a default export module or else Storybook Docs will suffer.
// see: https://github.com/storybookjs/storybook/issues/9556
export const Thing: FC<Props> = ({ children }) => {
return <div>{children || `the snozzberries taste like snozzberries`}</div>;
};
12 changes: 0 additions & 12 deletions templates/react-with-storybook/stories/0-Welcome.stories.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions templates/react-with-storybook/stories/Thing.stories.tsx
@@ -0,0 +1,10 @@
import React from 'react';
import { Thing, Props } from '../src';

export default {
title: 'Welcome',
};

// By passing optional props to this story, you can control the props of the component when
// you consume the story in a test.
export const Default = (props?: Partial<Props>) => <Thing {...props} />;
6 changes: 3 additions & 3 deletions templates/react-with-storybook/test/blah.test.tsx
@@ -1,8 +1,8 @@
import * as React from 'react';
import React from 'react';
import * as ReactDOM from 'react-dom';
import { Thing } from '../src';
import { Default as Thing } from '../stories/Thing.stories';

describe('it', () => {
describe('Thing', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Thing />, div);
Expand Down

0 comments on commit 1d8f123

Please sign in to comment.