/*import { createPortal } from "react-dom";
import styles from "./modal.module.css";
import Button from "../button/button.jsx";
const Modal = ({ open, onClose, children, title }) => {
if (!open) return null;
const handleOverlayClick = () => {
onClose();
};
const handleModalClick = (e) => {
e.stopPropagation();
};
return createPortal(
{title &&
{title}
}
{children}
,
document.body
);
};
export default Modal;*/
import { createPortal } from "react-dom";
import styles from "./Modal.module.css";
import Button from "../Button/Button";
import { ReactNode, MouseEvent } from "react";
interface ModalProps {
open: boolean;
onClose: () => void;
children: ReactNode;
title?: string;
}
const Modal = ({ open, onClose, children, title }: ModalProps) => {
if (!open) return null;
const handleOverlayClick = () => {
onClose();
};
const handleModalClick = (e: MouseEvent) => {
e.stopPropagation();
};
return createPortal(
{title &&
{title}
}
{children}
,
document.body
);
};
export default Modal;