Skip to content

Commit

Permalink
build: move to new v.6 of storybook (#305)
Browse files Browse the repository at this point in the history
Signed-off-by: Nastya Rusina <nastya@union.ai>
  • Loading branch information
anrusina authored Mar 7, 2022
1 parent e6f9729 commit 78b265e
Show file tree
Hide file tree
Showing 24 changed files with 3,665 additions and 4,865 deletions.
33 changes: 18 additions & 15 deletions .storybook/StorybookContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import * as React from 'react';
import { QueryClientProvider } from 'react-query';
import { MemoryRouter } from 'react-router-dom';
import { ErrorBoundary } from '../src/components/common/ErrorBoundary';
import { createQueryClient } from '../src/components/data/queryCache';
import { muiTheme } from '../src/components/Theme/muiTheme';

const useStyles = makeStyles((theme: Theme) => ({
container: {
display: 'flex',
padding: theme.spacing(1)
}
container: {
display: 'flex',
padding: theme.spacing(1)
}
}));

export const StorybookContainer: React.FC = ({ children }) => {
const [queryClient] = React.useState(() => createQueryClient());
return (
<ThemeProvider theme={muiTheme}>
<CssBaseline />
<ErrorBoundary>
<QueryClientProvider client={queryClient}>
<div className={useStyles().container}>{children}</div>
</QueryClientProvider>
</ErrorBoundary>
</ThemeProvider>
);
const [queryClient] = React.useState(() => createQueryClient());
return (
<ThemeProvider theme={muiTheme}>
<CssBaseline />
<ErrorBoundary>
<MemoryRouter>
<QueryClientProvider client={queryClient}>
<div className={useStyles().container}>{children}</div>
</QueryClientProvider>
</MemoryRouter>
</ErrorBoundary>
</ThemeProvider>
);
};
2 changes: 0 additions & 2 deletions .storybook/addons.js

This file was deleted.

20 changes: 18 additions & 2 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
module.exports = {
stories: ['../src/components/**/*.stories.tsx'],
addons: ['@storybook/addon-knobs']
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
framework: '@storybook/react',
webpackFinal: async (config, { configType }) => {
config.resolve.modules = ['src', 'node_modules'];
config.module.rules = [
...config.module.rules,
{
// needed to ensure proper same level of typing between app and storybook built.
// without it we have troubles with exporting flyteidl types due to nested namespace nature of
// flyteidl.d.ts file.
test: /\.tsx?$/,
exclude: /node_modules/,
use: ['babel-loader', { loader: 'ts-loader', options: { transpileOnly: true } }]
}
];
return config;
}
};
1 change: 0 additions & 1 deletion .storybook/preview-head.html

This file was deleted.

38 changes: 16 additions & 22 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import '../src/protobuf';
import { withKnobs } from '@storybook/addon-knobs';
import { addDecorator } from '@storybook/react';
import * as React from 'react';
import StoryRouter from 'storybook-react-router';
import React from 'react';
import { StorybookContainer } from './StorybookContainer';

addDecorator(withKnobs);
addDecorator(StoryRouter());
addDecorator(Story => (
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/
}
}
};

export const decorators = [
Story => (
<StorybookContainer>
<Story />
<Story />
</StorybookContainer>
));

// Storybook executes this module in both bootstap phase (Node)
// and a story's runtime (browser). However, cannot call `setupWorker`
// in Node environment, so need to check if we're in a browser.
if (typeof global.process === 'undefined') {
const { worker } = require('./worker');

// Start the mocking when each story is loaded.
// Repetitive calls to the `.start()` method will check for an existing
// worker and reuse it.
worker.start();
}
)
];
241 changes: 0 additions & 241 deletions .storybook/public/mockServiceWorker.js

This file was deleted.

38 changes: 0 additions & 38 deletions .storybook/webpack.config.js

This file was deleted.

Loading

0 comments on commit 78b265e

Please sign in to comment.