mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
2e83b22591
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5658 GitOrigin-RevId: a962f85e53396cd1d2cd64f46b91d3c042641ab3
84 lines
2.2 KiB
JavaScript
84 lines
2.2 KiB
JavaScript
import React from 'react';
|
|
import { Provider } from 'react-redux';
|
|
import produce from 'immer';
|
|
import addons from '@storybook/addons';
|
|
import { DocsContainer, DocsPage } from '@storybook/addon-docs';
|
|
import { initialize, mswDecorator } from 'msw-storybook-addon';
|
|
import theme from './theme';
|
|
import '../src/theme/tailwind.css';
|
|
import { store } from '../src/store';
|
|
import '../src/components/Common/Common.module.scss';
|
|
import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';
|
|
import 'react-loading-skeleton/dist/skeleton.css';
|
|
|
|
const channel = addons.getChannel();
|
|
initialize();
|
|
|
|
export const parameters = {
|
|
actions: { argTypesRegex: '^on.*' },
|
|
options: {
|
|
storySort: {
|
|
order: ['Design system', 'Dev', 'Components', 'Hooks'],
|
|
},
|
|
},
|
|
controls: {
|
|
matchers: {
|
|
color: /(background|color)$/i,
|
|
date: /Date$/,
|
|
},
|
|
},
|
|
docs: {
|
|
container: props => {
|
|
// Sync Docs dark mode with Storybook Manager
|
|
const [isDark, setDark] = React.useState();
|
|
|
|
React.useEffect(() => {
|
|
channel.on(DARK_MODE_EVENT_NAME, setDark);
|
|
return () => channel.removeListener(DARK_MODE_EVENT_NAME, setDark);
|
|
}, [channel, setDark]);
|
|
|
|
return (
|
|
<div className={(isDark ? 'dark' : 'light') + ' hasura-tailwind-on'}>
|
|
<DocsContainer
|
|
{...props}
|
|
context={{
|
|
...props.context,
|
|
storyById: id => {
|
|
return produce(props.context.storyById(id), draft => {
|
|
draft.parameters.docs.theme = isDark
|
|
? theme.dark
|
|
: theme.light;
|
|
});
|
|
},
|
|
}}
|
|
>
|
|
{props.children}
|
|
</DocsContainer>
|
|
</div>
|
|
);
|
|
},
|
|
page: DocsPage,
|
|
},
|
|
darkMode: {
|
|
dark: { ...theme.dark },
|
|
light: { ...theme.light },
|
|
},
|
|
};
|
|
|
|
export const decorators = [
|
|
(fn, c) => <Provider store={store}>{fn(c)}</Provider>,
|
|
mswDecorator,
|
|
Story => {
|
|
document.body.classList.add('hasura-tailwind-on');
|
|
return <div className={'bg-legacybg'}>{Story()}</div>;
|
|
},
|
|
];
|
|
|
|
export const argTypes = {
|
|
disableSnapshotTesting: {
|
|
table: {
|
|
disable: true,
|
|
},
|
|
},
|
|
};
|