Init template

This commit is contained in:
Vitaly Rtishchev
2023-05-28 10:55:11 +04:00
commit f63101a095
28 changed files with 11915 additions and 0 deletions

10
.storybook/main.ts Normal file
View File

@ -0,0 +1,10 @@
import type { StorybookConfig } from '@storybook/nextjs';
const config: StorybookConfig = {
stories: ['../components/**/*.(stories|story).@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-essentials', 'storybook-dark-mode', '@storybook/addon-styling'],
framework: {
name: '@storybook/nextjs',
options: {},
},
};
export default config;

25
.storybook/preview.tsx Normal file
View File

@ -0,0 +1,25 @@
import '@mantine/core/styles.css';
import React, { useEffect } from 'react';
import { addons } from '@storybook/preview-api';
import { DARK_MODE_EVENT_NAME } from 'storybook-dark-mode';
import { MantineProvider, useMantineColorScheme } from '@mantine/core';
import { theme } from '../theme';
const channel = addons.getChannel();
function ColorSchemeWrapper({ children }: { children: React.ReactNode }) {
const { setColorScheme } = useMantineColorScheme();
const handleColorScheme = (value: boolean) => setColorScheme(value ? 'dark' : 'light');
useEffect(() => {
channel.on(DARK_MODE_EVENT_NAME, handleColorScheme);
return () => channel.off(DARK_MODE_EVENT_NAME, handleColorScheme);
}, [channel]);
return <>{children}</>;
}
export const decorators = [
(renderStory: any) => <ColorSchemeWrapper>{renderStory()}</ColorSchemeWrapper>,
(renderStory: any) => <MantineProvider theme={theme}>{renderStory()}</MantineProvider>,
];