import { useState } from "react"; import type { Meta, StoryObj } from "@storybook/react-vite"; import { useArgs } from "storybook/preview-api"; import { CloseIcon } from "../icons"; import { Dialog, EDialogWidth } from "./root"; const meta = { title: "Components/Dialog", component: Dialog, subcomponents: { DialogPanel: Dialog.Panel, DialogTitle: Dialog.Title, }, args: { children: null, open: false, onOpenChange: () => {}, }, parameters: { layout: "centered", }, tags: ["autodocs"], render(args) { const [{ open }, updateArgs] = useArgs(); const setOpen = (value: boolean) => updateArgs({ open: value }); return ( <> {open && (
Dialog Title

This is the dialog content. You can put any content here.

)} ); }, } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { args: { children: null, }, }; export const TopPosition: Story = { render(args) { const [open, setOpen] = useState(args.open); return ( <> {open && (
Top Positioned Dialog

This dialog appears at the top of the screen instead of centered.

)} ); }, }; export const SmallWidth: Story = { render(args) { const [open, setOpen] = useState(args.open); return ( <> {open && (
Small Dialog

This is a small dialog.

)} ); }, }; export const LargeWidth: Story = { render(args) { const [open, setOpen] = useState(args.open); return ( <> {open && (
Large Dialog

This is a large dialog with more horizontal space for content.

)} ); }, }; export const WithCloseButton: Story = { render(args) { const [open, setOpen] = useState(args.open); return ( <> {open && (
Dialog with Close Button

This dialog has a close button in the header.

)} ); }, }; export const ConfirmationDialog: Story = { render(args) { const [open, setOpen] = useState(args.open); const handleConfirm = () => { alert("Confirmed!"); setOpen(false); }; return ( <> {open && (
Confirm Deletion

Are you sure you want to delete this item? This action cannot be undone.

)} ); }, }; export const FormDialog: Story = { render(args) { const [open, setOpen] = useState(args.open); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); alert("Form submitted!"); setOpen(false); }; return ( <> {open && (
Create New Item