-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathindex.tsx
93 lines (85 loc) · 2.17 KB
/
index.tsx
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
86
87
88
89
90
91
92
93
/*--------------------------------------------------------------------------
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
* All Rights Reserved. Proprietary and confidential.
* Unauthorized copying of this file, via any medium is strictly prohibited
*--------------------------------------------------------------------------
*/
import React from 'react'
import { makeStyles, Dialog, IconButton } from '@material-ui/core'
import { Close as CloseIcon } from '@material-ui/icons'
import clsx from 'clsx'
import { SectionTitle } from '@postgres.ai/shared/components/SectionTitle'
import { colors } from '@postgres.ai/shared/styles/colors'
type Props = {
isOpen: boolean
onClose: () => void
children: React.ReactNode
title: React.ReactNode
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
titleRightContent?: React.ReactNode
headerContent?: React.ReactNode
classes?: {
content?: string
}
}
const useStyles = makeStyles(
(theme) => ({
root: {
padding: '24px',
width: '100%',
[theme.breakpoints.down('xs')]: {
padding: '20px',
margin: '20px',
maxHeight: 'calc(100% - 40px)',
},
},
closeButton: {
position: 'absolute',
right: '12px',
top: '12px',
color: colors.pgaiDarkGray,
},
titleContent: {
paddingRight: '36px',
},
content: {
marginTop: '16px',
},
}),
{ index: 1 },
)
export const Modal = (props: Props) => {
const {
isOpen,
onClose,
children,
title,
size = 'xs',
titleRightContent,
} = props
const classes = useStyles()
return (
<Dialog
open={isOpen}
onClose={onClose}
classes={{ paper: classes.root }}
maxWidth={size}
>
<IconButton className={classes.closeButton} onClick={onClose}>
<CloseIcon />
</IconButton>
<SectionTitle
text={title}
tag="h3"
level={1}
rightContent={titleRightContent}
contentClassName={classes.titleContent}
>
{props.headerContent}
</SectionTitle>
<div className={clsx(classes.content, props.classes?.content)}>
{children}
</div>
</Dialog>
)
}