Spaces:
Sleeping
Sleeping
| import React, { ReactNode } from 'react'; | |
| import { X } from 'lucide-react'; | |
| import { Button } from './ui/button'; | |
| interface CustomModalProps { | |
| isOpen: boolean; | |
| onClose: () => void; | |
| title?: string; | |
| children: ReactNode; | |
| maxWidth?: string; | |
| showCloseButton?: boolean; | |
| } | |
| const CustomModal: React.FC<CustomModalProps> = ({ | |
| isOpen, | |
| onClose, | |
| title, | |
| children, | |
| maxWidth = 'max-w-4xl', | |
| showCloseButton = true, | |
| }) => { | |
| if (!isOpen) return null; | |
| return ( | |
| <div | |
| className="fixed inset-0 z-[9999] overflow-y-auto bg-black bg-opacity-50 flex items-center justify-center p-3" | |
| onClick={onClose} | |
| > | |
| <div | |
| className={`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${maxWidth} w-full max-h-[90vh] overflow-auto`} | |
| onClick={(e) => e.stopPropagation()} | |
| > | |
| {(title || showCloseButton) && ( | |
| <div className="flex items-center justify-between py-2 px-3 border-b dark:border-gray-700"> | |
| {title && <h3 className="text-base font-semibold">{title}</h3>} | |
| {showCloseButton && ( | |
| <Button | |
| variant="ghost" | |
| size="icon" | |
| onClick={onClose} | |
| className="h-7 w-7 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700" | |
| > | |
| <X className="h-4 w-4" /> | |
| </Button> | |
| )} | |
| </div> | |
| )} | |
| <div className="p-3">{children}</div> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| export default CustomModal; |