import React from 'react';
import { createPortal } from 'react-dom';
import styled from 'styled-components';

interface BackgroundModalProps {
  children: React.ReactNode;
}

function BackgroundModal(props: BackgroundModalProps) {
  return createPortal(
    <Container {...props}>{props.children}</Container>,
    document.body
  );
}

const Container = styled.div`
  border: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;  
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  box-shadow: 0px 3px 10px #00000029;
`;

export default BackgroundModal;
