42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import '@mantine/core/styles.css';
|
|
|
|
import type { Decorator } from '@storybook/react-vite';
|
|
|
|
import { MantineProvider } from '@mantine/core';
|
|
import { ModalsProvider } from '@mantine/modals';
|
|
|
|
import { GlobalStateStoreProvider } from '../src/GlobalStateStore';
|
|
|
|
export const PreviewDecorator: Decorator = (Story, context) => {
|
|
const { parameters } = context;
|
|
|
|
// Allow stories to opt-out of GlobalStateStore provider
|
|
const useGlobalStore = parameters.globalStore !== false;
|
|
|
|
// Use 100% for fullscreen layout, 100vh otherwise
|
|
const isFullscreen = parameters.layout === 'fullscreen';
|
|
const containerStyle = {
|
|
height: isFullscreen ? '100%' : '100vh',
|
|
width: isFullscreen ? '100%' : '100vw',
|
|
};
|
|
|
|
return (
|
|
<MantineProvider>
|
|
|
|
<ModalsProvider>
|
|
{useGlobalStore ? (
|
|
<GlobalStateStoreProvider fetchOnMount={false}>
|
|
<div style={containerStyle}>
|
|
<Story />
|
|
</div>
|
|
</GlobalStateStoreProvider>
|
|
) : (
|
|
<div style={containerStyle}>
|
|
<Story />
|
|
</div>
|
|
)}
|
|
</ModalsProvider>
|
|
</MantineProvider>
|
|
);
|
|
};
|