Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import styled from 'styled-components';
  2.  
  3. const ModalContent = styled('div')`
  4.   z-index: 10000;
  5.   max-width: 400px;
  6.   margin: auto auto;
  7.   padding: 14px;
  8.   border-radius: 8px;
  9.   background-color: #f00;
  10. `;
  11. const ShadedBackground = styled('div')`
  12.   z-index: 500;
  13.   position: fixed;
  14.   display: flex;
  15.   justify-content: center;
  16.   top: 0;
  17.   left: 0;
  18.   background-color: rgba(30, 30, 30, .9);
  19.   width: 100vw;
  20.   height: 100vh;
  21. `;
  22.  
  23. export const Modal = ({children, hideModal}) => {
  24.     return (
  25.         <ShadedBackground onClick={() => {
  26.             console.log('ShadedBackground component got a click, hiding modal.')
  27.             hideModal()
  28.         }}>
  29.             <ModalContent>
  30.                 {children}
  31.             </ModalContent>
  32.         </ShadedBackground>
  33.     )
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement