Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate new Storybook 5.3+ config & docs add-on #435

Merged
merged 3 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/templates/react-with-storybook.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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