Created
April 19, 2021 14:04
-
-
Save jogilvyt/33795fc921e81744dcdc15fd4a72da12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Modal = ({ header, body, onClose, onConfirm, confirmButtonText }) => { | |
const renderBody = () => { | |
if (typeof body === "string") { | |
return <p>body</p>; | |
} | |
return body; | |
}; | |
return ( | |
<div className="Modal"> | |
<div className="Modal-Header"> | |
<h2>{header}</h2> | |
</div> | |
<div className="Modal-Body">{renderBody()}</div> | |
<div className="Modal-Actions"> | |
<button onClick={onClose}>Close</button> | |
{onConfirm && ( | |
<button onClick={onConfirm}> | |
{confirmButtonText ? confirmButtonText : "Confirm"} | |
</button> | |
)} | |
</div> | |
</div> | |
); | |
}; | |
export default Modal; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment