-
Notifications
You must be signed in to change notification settings - Fork 0
/
OverLay.tsx
44 lines (41 loc) · 1012 Bytes
/
OverLay.tsx
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React, { useRef } from "react";
function OverLay(props: {
overlay: boolean;
toggleOverlay: React.MouseEventHandler<HTMLButtonElement>;
children:
| React.ReactElement<any, string | React.JSXElementConstructor<any>>
| React.ReactPortal;
}) {
const dialogRef = useRef<HTMLDivElement>(null);
dialogRef.current?.addEventListener("click", (evt) => {
console.log("overlay button clicked");
return props.toggleOverlay;
});
return (
<div
className={`overlay-dialog ${props.overlay ? "" : "hide-overlay"}`}
role="dialog"
aria-modal="true"
>
<div className="overlay">
<div
className="overlay-bg"
tabIndex={-1}
ref={dialogRef}
>
<div className="overlay-controls">
<button
type="button"
className="btn-overlay-close"
onClick={props.toggleOverlay}
>
Close overlay
</button>
</div>
</div>
<div className="overlay-container">{props.children}</div>
</div>
</div>
);
}
export default OverLay;