import { action } from 'storybook/actions'; import { Meta, StoryObj } from '@storybook/react-webpack5'; import { ScreenMode, ThemeProvider } from '@wise/components-theming'; import { useState } from 'react'; import { Button, Modal, ModalProps } from '..'; import { CommonProps, Scroll } from '../common'; import { lorem10, lorem100, lorem1000 } from '../test-utils'; import { withVariantConfig } from '../../.storybook/helpers'; const meta: Meta = { component: Modal, tags: ['!autodocs', '!manifest'], title: 'Dialogs/Modal/Tests', args: { size: 'md', position: 'center', open: false, }, parameters: { chromatic: { delay: 2000, }, }, }; export default meta; type Story = StoryObj; export interface StoryContentProps { args: CommonProps & ModalProps; screenMode?: ScreenMode; viewMode?: string; } const StoryContent = ({ args, screenMode, viewMode }: StoryContentProps) => { const [open, setOpen] = useState(viewMode !== 'docs'); return ( <> {lorem100} ) } open={open} disableDimmerClickToClose={args.disableDimmerClickToClose} onClose={() => { setOpen(false); action('Modal closed')(); }} /> ); }; export const BasicMobile: Story = { args: { title: 'Title', body: lorem10, scroll: Scroll.VIEWPORT, footer: ( ), }, render: (args, context) => , ...withVariantConfig(['mobile']), }; export const ContentScrollMobile: Story = { args: { title: lorem10, body: lorem1000, scroll: Scroll.CONTENT, }, render: (args, context) => , ...withVariantConfig(['mobile']), }; export const ViewportScrollMobile: Story = { args: { title: lorem10, body: lorem1000, scroll: Scroll.VIEWPORT, }, render: (args, context) => , ...withVariantConfig(['mobile']), }; export const WithoutTitleMobile: Story = { args: { body: lorem1000, scroll: Scroll.CONTENT, }, render: (args, context) => , ...withVariantConfig(['mobile']), }; export const WithThemeProviderInContentMobile: Story = { args: { title: lorem10, body: lorem100, scroll: Scroll.VIEWPORT, footer: ( ), }, render: (args, { globals: { screenMode }, viewMode }) => ( // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment ), ...withVariantConfig(['mobile']), };