Added animation to modal when rendering

This commit is contained in:
Camerin 2021-09-23 16:00:54 -04:00
parent 5416eaae58
commit 550518031a
4 changed files with 17 additions and 6 deletions

View File

@ -30,7 +30,7 @@ const Navigation = (props) => {
Contact Me Contact Me
<Envelope /> <Envelope />
</button> </button>
{props.modal ? <ContactModal /> : ''} <ContactModal show={props.modal}/>
</div> </div>
); );
} }

View File

@ -1,15 +1,25 @@
.modal { .modal {
width: 100vw; display:flex;
width:0;
height: 100vh; height: 100vh;
z-index: 100; z-index: 100;
position: fixed; position: fixed;
top:0; top:0;
left:0; left:0;
opacity: 1; opacity: 0;
background-color: rgba(0,0,0,0.4); background-color: rgba(0,0,0,0);
display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
transition-delay: 70ms, 70ms, 0ms;
transition: opacity 300ms ease-out, width 300ms ease-out, background-color 50ms ease-out;
}
.modal.show {
width: 100vw;
background-color: rgba(0,0,0,0.4);
opacity: 1;
transition-delay: 0ms, 0ms, 300ms;
transition: opacity 300ms ease-in, width 300ms ease-in, background-color 300ms ease-in;
} }
.modal .box { .modal .box {

View File

@ -23,6 +23,7 @@ const ContactModal = props => {
title="Contact Me" title="Contact Me"
content = {renderContent()} content = {renderContent()}
onDismiss={props.toggleContactModal} onDismiss={props.toggleContactModal}
show={props.show}
/> />
}; };

View File

@ -4,7 +4,7 @@ import '../css/Modal.css';
const Modal = props => { const Modal = props => {
return ReactDOM.createPortal( return ReactDOM.createPortal(
<div onClick={props.onDismiss} className="modal"> <div onClick={props.onDismiss} className={`modal ${props.show?'show':''}`}>
<div onClick={(e) => e.stopPropagation()} className="box"> <div onClick={(e) => e.stopPropagation()} className="box">
<div className="title">{props.title}</div> <div className="title">{props.title}</div>