Created
March 17, 2022 11:13
-
-
Save joeypy/382dd03c3991de3f7782ef43441c48e0 to your computer and use it in GitHub Desktop.
React Components - Modal
This file contains 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
import { useEffect } from 'react'; | |
import { BsXLg } from "react-icons/bs"; | |
import { Button } from 'antd' | |
const Modal = ({ | |
children, | |
setVisible, | |
handleSubmit, | |
visible=false, | |
title="Title", | |
showHeader=true | |
}) => { | |
const handleCancel = () => { | |
setVisible(false); | |
} | |
const onSubmit = () => { | |
handleSubmit() | |
handleCancel() | |
} | |
return ( | |
<> | |
{ | |
visible && ( | |
<div className="modal"> | |
<div className="modal_overlay" onClick={handleCancel}/> | |
<div className="modal_main"> | |
{ | |
showHeader && | |
<div className="modal_header"> | |
<h3>{title}</h3> | |
</div> | |
} | |
<div className="modal_btn-close" onClick={handleCancel}> | |
<BsXLg className="modal_icon"/> | |
</div> | |
<div className="modal_content"> | |
{ children } | |
</div> | |
<div className="modal_footer"> | |
<Button type="danger" onClick={handleCancel}>Cancel</Button> | |
<Button type="primary" onClick={onSubmit}>Submit</Button> | |
</div> | |
</div> | |
</div> | |
) | |
} | |
</> | |
) | |
} | |
export default Modal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment