Complete modal component

This commit is contained in:
Hazem Krimi
2021-05-02 03:57:59 +01:00
parent 6e416bcc9c
commit a8f8077770
3 changed files with 63 additions and 3 deletions
+49 -2
View File
@@ -1,7 +1,54 @@
import { theme } from '../../themes';
import { Box, Button, Text } from '..';
import { Wrapper } from './styles';
const Modal = () => {
return <Wrapper></Wrapper>;
type ModalProps = {
color: 'client' | 'productOwner' | 'developer' | 'admin';
title: string;
description: string;
children?: React.ReactNode | JSX.Element | string;
onConfirm: () => void;
onClose: () => void;
};
const Modal = ({
color,
title,
description,
children,
onConfirm,
onClose,
}: ModalProps) => {
return (
<Wrapper>
<Box
background={theme.colors.white.main}
borderRadius='10px'
padding='20px'
display='grid'
gridTemplateRows='auto'
alignItems='center'
rowGap='1rem'
>
<Text variant='headline' weight='bold' color={color}>
{title}
</Text>
<Text variant='body' color={theme.colors.black.main}>
{description}
</Text>
{children}
<Box
display='grid'
gridTemplateColumns='repeat(2, auto)'
justifyContent='flex-end'
columnGap='1rem'
>
<Button color={color} text='Confirm' onClick={onConfirm} />
<Button color={color} text='Cancel' onClick={onClose} />
</Box>
</Box>
</Wrapper>
);
};
export default Modal;
+12 -1
View File
@@ -1,3 +1,14 @@
import styled from 'styled-components';
export const Wrapper = styled.div``;
export const Wrapper = styled.div`
position: fixed;
z-index: 200;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.15);
display: grid;
align-items: center;
justify-content: center;
`;
+2
View File
@@ -18,6 +18,7 @@ import Sidebar from './Sidebar';
import ProtectedRoute from './ProtectedRoute';
import AuthRoute from './AuthRoute';
import SectionSelector from './SectionSelector';
import Modal from './Modal';
export {
Button,
@@ -40,4 +41,5 @@ export {
ProtectedRoute,
AuthRoute,
SectionSelector,
Modal,
};