diff --git a/src/components/ui/Modal.tsx b/src/components/ui/Modal.tsx index 5dc66df..bf02df0 100644 --- a/src/components/ui/Modal.tsx +++ b/src/components/ui/Modal.tsx @@ -1,13 +1,15 @@ "use client"; -import React, { useEffect } from 'react'; -import { FiX } from 'react-icons/fi'; + +import React from "react"; +import { Modal as HeroModal } from "@heroui/react"; +import { FiX } from "react-icons/fi"; export interface ModalProps { isOpen: boolean; onClose: () => void; title?: React.ReactNode; description?: React.ReactNode; - size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'; + size?: "sm" | "md" | "lg" | "xl" | "2xl" | "full"; children: React.ReactNode; footer?: React.ReactNode; closeOnOverlayClick?: boolean; @@ -16,12 +18,12 @@ export interface ModalProps { } const sizeStyles = { - sm: 'max-w-md', - md: 'max-w-lg', - lg: 'max-w-2xl', - xl: 'max-w-4xl', - '2xl': 'max-w-6xl', - full: 'max-w-[95vw] h-[90vh]', + sm: "max-w-md", + md: "max-w-lg", + lg: "max-w-2xl", + xl: "max-w-4xl", + "2xl": "max-w-6xl", + full: "max-w-[95vw] h-[90vh]", }; export const Modal: React.FC = ({ @@ -29,101 +31,74 @@ export const Modal: React.FC = ({ onClose, title, description, - size = 'md', + size = "md", children, footer, closeOnOverlayClick = true, showCloseButton = true, - className = '', + className = "", }) => { - // ESC key handler and body scroll lock - useEffect(() => { - if (!isOpen) return; - - const handleKeyDown = (e: KeyboardEvent) => { - if (e.key === 'Escape') { - onClose(); - } - }; - - const originalOverflow = document.body.style.overflow; - document.body.style.overflow = 'hidden'; - window.addEventListener('keydown', handleKeyDown); - - return () => { - document.body.style.overflow = originalOverflow; - window.removeEventListener('keydown', handleKeyDown); - }; - }, [isOpen, onClose]); - - if (!isOpen) return null; - return ( -
- {/* Backdrop */} -
{ - if (closeOnOverlayClick) onClose(); + + { + if (!open) { + onClose(); + } }} - className="fixed inset-0 bg-slate-950/70 backdrop-blur-md transition-opacity animate-fadeIn" - /> + variant="blur" + className="fixed inset-0 bg-slate-950/70 backdrop-blur-md transition-opacity animate-fadeIn"> + + - {/* Modal Dialog Card */} -
- {/* Header */} - {(title || description || showCloseButton) && ( -
-
- {title && ( -

- {title} -

- )} - {description && ( -

- {description} -

- )} -
+ {/* Header */} + {(title || description || showCloseButton) && ( + +
+ {title && ( + + {title} + + )} + {description && ( +

{description}

+ )} +
- {showCloseButton && ( - + {showCloseButton && ( + + + + )} +
)} -
- )} - {/* Body Content */} -
- {children} -
+ {/* Body Content */} + {children} - {/* Footer */} - {footer && ( -
- {footer} -
- )} -
-
+ {/* Footer */} + {footer && ( + + {footer} + + )} + + + + ); };