Spaces:
Paused
Paused
File size: 646 Bytes
a0fda44 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import React from "react";
import { useDispatch } from "react-redux";
import { modalActions } from "../../store/modalSlice";
function Overlay({ children, canOverlayClose }) {
const dispatch = useDispatch();
const closeModal = () => {
if (!canOverlayClose) return;
dispatch(modalActions.closeModal());
};
return (
<div
onClick={(event) => {
if (event.target.id !== "overlay") return;
closeModal("Click caused it");
}}
className=" w-full h-full absolute z-20 top-0 left-0 flex items-center justify-center"
id="overlay"
>
{children}
</div>
);
}
export default Overlay;
|