This repository was archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModal.tsx
More file actions
85 lines (77 loc) · 1.72 KB
/
Modal.tsx
File metadata and controls
85 lines (77 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React from 'react';
import styled from 'styled-components';
const ModalContainer = styled.div`
position: fixed;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
`;
const ModalBackground = styled.div`
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
background-color: #000;
opacity: 0.8;
`;
const ModalContent = styled.div`
position: relative;
display: flex;
flex-direction: column;
background-color: #fff;
opacity: 1;
padding: 2em;
padding-bottom: 3em;
border-radius: 0.25rem;
`;
const ModalHeader = styled.div`
display: flex;
justify-content: flex-end;
width: 100%;
`;
const ModalCloseButton = styled.button`
margin: 0px;
padding: 0px;
cursor: pointer;
background: none;
border: none;
`;
interface ModalProps {
onClose: () => void;
children?: React.ReactNode;
}
const Modal: React.FC<ModalProps> = ({ onClose, children }: ModalProps) => {
return (
<ModalContainer>
<ModalBackground onClick={() => onClose()} />
<ModalContent>
<ModalHeader>
<ModalCloseButton onClick={() => onClose()}>
<svg
xmlns='http://www.w3.org/2000/svg'
style={{ width: '1.25rem' }}
fill='none'
viewBox='0 0 24 24'
stroke='currentColor'
>
<path
strokeLinecap='round'
strokeLinejoin='round'
strokeWidth={2}
d='M6 18L18 6M6 6l12 12'
/>
</svg>
</ModalCloseButton>
</ModalHeader>
{children}
</ModalContent>
</ModalContainer>
);
};
export default Modal;