"use client" import type React from "react" import { useState } from "react" import { createPortal } from "react-dom" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { ComponentContainer } from "@/components/ui/component-container" import { X } from "lucide-react" // Custom Modal Component function CustomModal({ isOpen, onClose, title, description, children, footer, }: { isOpen: boolean onClose: () => void title: string description?: string children: React.ReactNode footer?: React.ReactNode }) { if (!isOpen) return null return createPortal(
{/* Overlay */}
{/* Modal Content */}
{/* Close Button */} {/* Header */}

{title}

{description &&

{description}

}
{/* Content */}
{children}
{/* Footer */} {footer &&
{footer}
}
, document.body, ) } export function ModalsSection() { const [basicDialogOpen, setBasicDialogOpen] = useState(false) const [alertDialogOpen, setAlertDialogOpen] = useState(false) const [controlledDialogOpen, setControlledDialogOpen] = useState(false) const basicDialogCode = `import { useState } from "react" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" export function BasicDialog() { return ( Edit Profile Make changes to your profile here. Click save when you're done.
) }` const alertDialogCode = `import { useState } from "react" import { Button } from "@/components/ui/button" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog" export function AlertDialogDemo() { return ( Are you absolutely sure? This action cannot be undone. This will permanently delete your account and remove your data from our servers. Cancel Continue ) }` const controlledDialogCode = `import { useState } from "react" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog" export function ControlledDialog() { const [open, setOpen] = useState(false) return ( <> Controlled Dialog This dialog's state is controlled programmatically.

This dialog can be opened and closed using state.

) }` return (

Modals

setBasicDialogOpen(false)} title="Edit Profile" description="Make changes to your profile here. Click save when you're done." footer={ } >
setAlertDialogOpen(false)} title="Are you absolutely sure?" description="This action cannot be undone. This will permanently delete your account and remove your data from our servers." footer={ <> } >

Please confirm that you want to delete your account. This action is irreversible.

setControlledDialogOpen(false)} title="Controlled Dialog" description="This dialog's state is controlled programmatically." footer={} >

This dialog can be opened and closed using state.

) }