| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import React, { FC } from "react";
- import styled from "styled-components";
- import { Flex } from "reflexbox/styled-components";
- interface Props {
- show: boolean;
- id?: string;
- closeHandler?: () => unknown;
- }
- const Wrapper = styled.div`
- position: fixed;
- width: 100%;
- height: 100%;
- top: 0;
- left: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: rgba(50, 50, 50, 0.8);
- z-index: 1000;
- `;
- const Modal: FC<Props> = ({ children, id, show, closeHandler }) => {
- if (!show) return null;
- const onClickOutside = e => {
- if (e.target.id === id) closeHandler();
- };
- return (
- <Wrapper id={id} onClick={onClickOutside}>
- <Flex
- minWidth={[400, 450]}
- maxWidth={0.9}
- py={[32, 32, 48]}
- px={[24, 24, 32]}
- style={{ borderRadius: 8, backgroundColor: "white" }}
- flexDirection="column"
- >
- {children}
- </Flex>
- </Wrapper>
- );
- };
- Modal.defaultProps = {
- show: false
- };
- export default Modal;
|