-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomPopup.jsx
More file actions
42 lines (36 loc) · 981 Bytes
/
CustomPopup.jsx
File metadata and controls
42 lines (36 loc) · 981 Bytes
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
import { useEffect, useState } from "react";
import popupStyles from "./custom-popup.module.css";
import PropTypes from "prop-types";
const CustomPopup = (props) => {
const [show, setShow] = useState(false);
const closeHandler = (e) => {
setShow(false);
props.onClose(false);
};
useEffect(() => {
setShow(props.show);
}, [props.show]);
return (
<div
style={{
visibility: show ? "visible" : "hidden",
opacity: show ? "1" : "0"
}}
className={popupStyles.overlay}
>
<div className={popupStyles.popup}>
<h2>{props.title}</h2>
<span className={popupStyles.close} onClick={closeHandler}>
×
</span>
<div className={popupStyles.content}>{props.children}</div>
</div>
</div>
);
};
CustomPopup.propTypes = {
title: PropTypes.string.isRequired,
show: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired
};
export default CustomPopup;