import type { Meta, StoryObj } from '@storybook/react-vite' import React, { useState } from 'react' import { DocsTemplate } from '../../../.storybook' import ModalComponent from './Modal' import Button from '../Button/Button' import { toast } from '../Toast/Toast' const meta: Meta = { title: 'Components/Modal', component: ModalComponent, argTypes: { children: { control: false }, headerContent: { control: false }, footerContent: { control: false }, closeCallout: { control: false }, confirmation: { control: false }, }, parameters: { design: { type: 'figma', url: 'https://www.figma.com/design/RvhKD82948FMQnh5MyCi0o/Web-Design-System?node-id=13985-12006&p=f&t=9R4mlUY42yEaNlLp-0', }, docs: { page: () => ( The Modal component provides a versatile overlay screen that holds information, prompts, or additional content, overlaying the main application interface. It is commonly used to display important messages, alerts, forms, or other interactive content while temporarily blocking interaction with the underlying application. } infoBullets={[ Utilize the Modal component to display critical information or interactive content that requires user attention without navigating away from the current context. , Include various types of content within the Modal, such as text, forms, images, videos, or other custom components, based on the specific use case. , ]} /> ), }, }, } export default meta type Story = StoryObj const Modal = (args: any) => { const [visible, setVisible] = useState(false) return ( <> setVisible(false)} /> ) } const Template: Story = { render: (args) => , } const commonArgs = { headerContent: 'Modal Header', children: (
Modal content goes here
), footerContent:
Footer content goes here
, noContentPadding: false, } export const Basic: Story = { ...Template, args: commonArgs, } export const NoContentPadding: Story = { ...Template, args: { ...commonArgs, noContentPadding: true, headerContent: 'No Content Padding Modal', children: (
This modal content ignores the built-in padding on the left and right sides of the content container. The light blue background helps visualize that the content now spans the full width of its container. This is useful when the content itself needs to manage its own padding or when a full-bleed effect is desired for certain child elements like images or banners.
), }, } export const WithoutFooter: Story = { ...Template, args: { ...commonArgs, footerContent: null, }, } export const WithoutHeader: Story = { ...Template, args: { ...commonArgs, hideHeader: true, }, } export const BasicHideCloseIcon: Story = { ...Template, args: { ...commonArgs, hideCloseIcon: true, disableOutsideClick: true, footerContent: ({ close }) => (
), children: (
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
), }, } export const LargeContent: Story = { ...Template, args: { ...commonArgs, headerContent: 'Scrollable Modal', children: (
{Array.from({ length: 32 }).map((_, i) => (
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
))}
), }, } export const Confirmation: Story = { ...Template, args: { ...commonArgs, headerContent: 'Confirmation Modal', confirmation: { type: 'black', header: 'Are you sure?', body: 'This will perform some action. Would you like to continue?', confirmCallout: () => { toast({ message: 'You clicked confirm!', type: 'success' }) }, cancelCallout: () => { toast({ message: 'You clicked cancel!', type: 'info' }) }, }, }, } export const DestructiveConfirmation: Story = { ...Template, args: { ...commonArgs, confirmation: { type: 'red', header: 'Are you sure?', body: 'This will perform some action. Would you like to continue?', confirmCallout: () => { toast({ message: 'You clicked confirm!', type: 'success' }) }, cancelCallout: () => { toast({ message: 'You clicked cancel!', type: 'info' }) }, }, }, } export const SmallSize: Story = { ...Template, args: { ...commonArgs, size: 'sm', headerContent: 'Small Modal', }, } export const MediumSize: Story = { ...Template, args: { ...commonArgs, size: 'md', headerContent: 'Medium Modal', }, } export const LargeSize: Story = { ...Template, args: { ...commonArgs, size: 'lg', headerContent: 'Large Modal', }, } export const ExtraLargeSize: Story = { ...Template, args: { ...commonArgs, size: 'xl', headerContent: 'Extra Large Modal', }, } ExtraLargeSize.storyName = 'XL Size' export const FullWidth: Story = { ...Template, args: { ...commonArgs, fullWidth: true, headerContent: 'Full Width Modal', }, }