50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import { X } from 'lucide-react';
|
|
import './Modal.css';
|
|
|
|
interface ModalProps {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
title: string;
|
|
children: React.ReactNode;
|
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
}
|
|
|
|
const Modal: React.FC<ModalProps> = ({
|
|
isOpen,
|
|
onClose,
|
|
title,
|
|
children,
|
|
size = 'md'
|
|
}) => {
|
|
if (!isOpen) return null;
|
|
|
|
const handleBackdropClick = (e: React.MouseEvent) => {
|
|
if (e.target === e.currentTarget) {
|
|
onClose();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="modal-overlay" onClick={handleBackdropClick}>
|
|
<div className={`modal-container modal-${size}`}>
|
|
<div className="modal-header">
|
|
<h2 className="modal-title">{title}</h2>
|
|
<button
|
|
className="modal-close-button"
|
|
onClick={onClose}
|
|
aria-label="Fermer la modal"
|
|
>
|
|
<X className="h-5 w-5" />
|
|
</button>
|
|
</div>
|
|
<div className="modal-content">
|
|
{children}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Modal;
|