import { ArrowsVertical } from '@phosphor-icons/react'; import type { Meta, StoryObj } from '@storybook/react'; import { Button } from '@views/components/common/Button'; import DialogProvider, { usePrompt } from '@views/components/common/DialogProvider/DialogProvider'; import Text from '@views/components/common/Text/Text'; import React, { useState } from 'react'; const meta = { title: 'Components/Common/DialogProvider', component: DialogProvider, parameters: { layout: 'centered', }, tags: ['autodocs'], args: {}, argTypes: {}, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { args: { children: undefined }, render: () => ( ), }; const InnerComponent = () => { const showDialog = usePrompt(); const myShow = () => { showDialog({ title: 'Dialog Title', description: 'Dialog Description', // eslint-disable-next-line react/no-unstable-nested-components buttons: close => ( ), }); }; return ( ); }; export const FiveDialogs: Story = { args: { children: undefined }, render: () => ( They'll open with 100ms delay ), }; const FiveDialogsInnerComponent = () => { const showDialog = usePrompt(); const myShow = () => { for (let i = 0; i < 5; i++) { setTimeout( () => showDialog({ title: `Dialog #${i}`, description: 'Deleting Main Schedule is permanent and will remove all added courses from that schedule.', // eslint-disable-next-line react/no-unstable-nested-components buttons: close => ( ), }), 100 * i ); } }; return ( ); }; export const NestedDialogs: Story = { args: { children: undefined }, render: () => ( ), }; const NestedDialogsInnerComponent = () => { const showDialog = usePrompt(); const myShow = () => { showDialog({ title: 'Dialog Title', description: 'Dialog Description', // eslint-disable-next-line react/no-unstable-nested-components buttons: close => ( <> ), }); }; return ( ); }; export const DialogWithOnClose: Story = { args: { children: undefined }, render: () => ( ), }; const DialogWithOnCloseInnerComponent = () => { const showDialog = usePrompt(); const [timesClosed, setTimesClosed] = useState(0); const myShow = () => { showDialog({ title: 'Dialog Title', description: 'Dialog Description', // eslint-disable-next-line react/no-unstable-nested-components buttons: close => ( ), onClose: () => { setTimesClosed(prev => prev + 1); }, }); }; return ( <>

You closed the button below {timesClosed} {timesClosed === 1 ? 'time' : 'times'}

); };