import React, { type FC, Fragment, useEffect } from 'react'; import type { Channel } from 'storybook/internal/channels'; import { DocsContext } from '@storybook/blocks'; import { global } from '@storybook/global'; import type { Decorator, Loader, ReactRenderer } from '@storybook/react-vite'; // TODO add empty preview // import * as storysource from '@storybook/addon-storysource'; // import * as designs from '@storybook/addon-designs/preview'; import { definePreview } from '@storybook/react-vite'; import addonA11y from '@storybook/addon-a11y'; import addonDocs from '@storybook/addon-docs'; import addonTest from '@storybook/addon-test'; import addonThemes from '@storybook/addon-themes'; import { DocsContext as DocsContextProps, useArgs } from 'storybook/preview-api'; import type { PreviewWeb } from 'storybook/preview-api'; import { Global, ThemeProvider, convert, createReset, styled, themes, useTheme, } from 'storybook/theming'; import * as templatePreview from '../core/template/stories/preview'; import { DocsPageWrapper } from '../lib/blocks/src/components'; import '../renderers/react/template/components/index'; import { isChromatic } from './isChromatic'; const { document } = global; globalThis.CONFIG_TYPE = 'DEVELOPMENT'; const ThemeBlock = styled.div<{ side: 'left' | 'right'; layout: string }>( { position: 'absolute', top: 0, left: 0, right: '50vw', width: '50vw', height: '100vh', bottom: 0, overflow: 'auto', }, ({ layout }) => ({ padding: layout === 'fullscreen' ? 0 : '1rem', }), ({ theme }) => ({ background: theme.background.content, color: theme.color.defaultText, }), ({ side }) => side === 'left' ? { left: 0, right: '50vw', } : { right: 0, left: '50vw', } ); const ThemeStack = styled.div<{ layout: string }>( { position: 'relative', flex: 1, }, ({ theme }) => ({ background: theme.background.content, color: theme.color.defaultText, }), ({ layout }) => ({ padding: layout === 'fullscreen' ? 0 : '1rem', }) ); const PlayFnNotice = styled.div( { position: 'absolute', top: 0, left: 0, width: '100%', borderBottom: '1px solid #ccc', padding: '3px 8px', fontSize: '10px', fontWeight: 'bold', '> *': { display: 'block', }, }, ({ theme }) => ({ background: '#fffbd9', color: theme.color.defaultText, }) ); const StackContainer: FC> = ({ children, layout }) => (