2022-05-18 10:15:54 +02:00
|
|
|
import styles from "../styles/exos/Modal.module.scss";
|
|
|
|
import { parseClassName } from "../utils/utils.js";
|
|
|
|
|
|
|
|
export default function Modal({ children, active, onClose, overlay }) {
|
|
|
|
return (
|
|
|
|
<>
|
2022-06-24 13:42:16 +02:00
|
|
|
<div
|
|
|
|
className={parseClassName([
|
|
|
|
styles.modal,
|
|
|
|
active ? styles.visible : "",
|
|
|
|
styles["md-effect"],
|
|
|
|
])}
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
console.log('e')
|
|
|
|
if (e.code == 'Escape') {
|
|
|
|
onClose()
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
>
|
2022-05-18 10:15:54 +02:00
|
|
|
{/* <div className={styles['md-content']}> */}
|
2022-06-24 13:42:16 +02:00
|
|
|
{active && children}
|
|
|
|
{/* </div> */}
|
2022-05-18 10:15:54 +02:00
|
|
|
</div>
|
2022-06-24 13:42:16 +02:00
|
|
|
{overlay == undefined && (
|
|
|
|
<div
|
|
|
|
className={"overlay " + (active == false ? " invisible" : "")}
|
|
|
|
onClick={() => {
|
|
|
|
onClose && onClose();
|
|
|
|
}}
|
|
|
|
></div>
|
|
|
|
)}
|
|
|
|
{overlay != undefined && (
|
|
|
|
<div
|
|
|
|
className={"overlay " + (overlay == false ? " invisible" : "")}
|
|
|
|
onClick={() => {
|
|
|
|
onClose && onClose();
|
|
|
|
}}
|
|
|
|
></div>
|
|
|
|
)}
|
2022-05-18 10:15:54 +02:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|