2020-09-02 20:30:47 +03:00
|
|
|
import React from 'react';
|
2023-04-07 04:39:14 +03:00
|
|
|
import type { Preview } from '@storybook/react';
|
|
|
|
|
2020-09-02 20:30:47 +03:00
|
|
|
import { Container } from '../src';
|
|
|
|
import { listSchemes, listThemes } from '../src/utils/theme';
|
|
|
|
|
|
|
|
const withThemeProvider = (Story, context) => (
|
|
|
|
<Container
|
|
|
|
themeData={{
|
|
|
|
theme: context.globals.theme,
|
|
|
|
scheme: context.globals.scheme,
|
2021-11-06 20:28:35 +03:00
|
|
|
colorPreference: context.globals.color,
|
2020-09-02 20:30:47 +03:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Story {...context} />
|
|
|
|
</Container>
|
|
|
|
);
|
2023-04-07 04:39:14 +03:00
|
|
|
|
|
|
|
const preview: Preview = {
|
|
|
|
parameters: {
|
2024-04-01 23:48:58 +03:00
|
|
|
controls: {
|
|
|
|
matchers: {
|
|
|
|
color: /(background|color)$/i,
|
|
|
|
date: /Date$/i,
|
|
|
|
},
|
|
|
|
},
|
2023-04-07 04:39:14 +03:00
|
|
|
},
|
|
|
|
globalTypes: {
|
|
|
|
theme: {
|
|
|
|
name: 'Theme',
|
|
|
|
description: 'Global theme for components',
|
|
|
|
defaultValue: 'default',
|
|
|
|
toolbar: {
|
|
|
|
items: listThemes(),
|
|
|
|
showName: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
scheme: {
|
|
|
|
name: 'Color Scheme',
|
|
|
|
description: 'Global color scheme for components',
|
|
|
|
defaultValue: 'default',
|
|
|
|
toolbar: {
|
|
|
|
items: listSchemes(),
|
|
|
|
showName: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
color: {
|
|
|
|
name: 'Color',
|
|
|
|
description: 'Global color for components',
|
|
|
|
defaultValue: 'light',
|
|
|
|
toolbar: {
|
|
|
|
items: ['auto', 'light', 'dark'],
|
|
|
|
showName: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
decorators: [withThemeProvider],
|
|
|
|
};
|
|
|
|
|
|
|
|
export default preview;
|