// // Copyright 2022 DXOS.org // import { type Meta, type StoryObj } from '@storybook/react-vite'; import React from 'react'; import { random } from '@dxos/random'; import { withTheme } from '../../testing'; import { Button } from '../Button'; import { Input } from '../Input'; import { ScrollArea } from '../ScrollArea'; import { Dialog, type DialogContentProps } from './Dialog'; type StoryArgs = Pick & Partial<{ title: string; description: string; openTrigger: string; closeTrigger: string; blockAlign: 'start' | 'center'; }>; /** * Standard Dialog with non-scrolling content in Dialog.Body. * Dialog.Body propagates the Column grid via subgrid. Children auto-center via --dx-col. */ const DefaultStory = ({ size, title, description, openTrigger, closeTrigger, blockAlign }: StoryArgs) => { return ( {title} {closeTrigger && ( )} {description} ); }; /** * Dialog with a ScrollArea child inside Dialog.Body. * The ScrollArea breaks out of Body's gutter padding via `--gutter` * and applies its own asymmetric padding (accounting for scrollbar width). */ const ScrollingStory = ({ size, title, description, openTrigger, closeTrigger, blockAlign }: StoryArgs) => { return ( {title} {closeTrigger && ( )} {description} ); }; const meta = { title: 'ui/react-ui-core/components/Dialog', component: Dialog as any, render: DefaultStory, decorators: [withTheme()], } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { args: { title: 'Dialog title', description: random.lorem.paragraph(1), openTrigger: 'Open', closeTrigger: 'Close', blockAlign: 'start', }, }; export const Small: Story = { args: { title: 'Dialog title', description: random.lorem.paragraph(1), openTrigger: 'Open', closeTrigger: 'Close', blockAlign: 'center', size: 'sm', }, }; export const Medium: Story = { args: { title: 'Dialog title', description: random.lorem.paragraph(1), openTrigger: 'Open', closeTrigger: 'Close', blockAlign: 'center', size: 'md', }, }; export const Large: Story = { args: { title: 'Dialog title', description: random.lorem.paragraph(2), openTrigger: 'Open Dialog', closeTrigger: 'Close', blockAlign: 'center', size: 'lg', }, }; export const ExtraLarge: Story = { args: { title: 'Dialog title', description: random.lorem.paragraph(2), openTrigger: 'Open Dialog', closeTrigger: 'Close', blockAlign: 'center', size: 'xl', }, }; export const Scrolling: Story = { render: ScrollingStory, args: { title: 'Dialog title', description: random.lorem.paragraph(20), openTrigger: 'Open Dialog', closeTrigger: 'Close', blockAlign: 'center', size: 'md', }, };