-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Modal.styles.ts
97 lines (85 loc) · 2.15 KB
/
Modal.styles.ts
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
94
95
96
97
import { createStyles, CSSObject } from '@mantine/styles';
const sizes = {
xs: 320,
sm: 380,
md: 440,
lg: 620,
xl: 780,
};
export interface ModalStylesParams {
overflow: 'outside' | 'inside';
size: string | number;
centered: boolean;
zIndex: React.CSSProperties['zIndex'];
fullScreen: boolean;
}
function getFullScreenStyles(fullScreen: boolean): CSSObject {
if (!fullScreen) {
return {};
}
return {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
};
}
export default createStyles(
(theme, { overflow, size, centered, zIndex, fullScreen }: ModalStylesParams) => ({
close: {},
overlay: {
display: fullScreen ? 'none' : undefined,
},
root: {
position: 'fixed',
zIndex,
top: 0,
left: 0,
right: 0,
bottom: 0,
},
inner: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
overflowY: 'auto',
padding: fullScreen ? 0 : `${theme.spacing.xl * 2}px ${theme.spacing.md}px`,
display: 'flex',
justifyContent: 'center',
alignItems: centered ? 'center' : 'flex-start',
},
title: {
marginRight: theme.spacing.md,
textOverflow: 'ellipsis',
display: 'block',
wordBreak: 'break-word',
},
modal: {
position: 'relative',
width: fullScreen ? undefined : theme.fn.size({ sizes, size }),
borderRadius: fullScreen ? 0 : undefined,
outline: 0,
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.white,
marginTop: centered ? 'auto' : undefined,
marginBottom: centered ? 'auto' : undefined,
zIndex: 1,
marginLeft: fullScreen ? undefined : 'calc(var(--removed-scroll-width, 0px) * -1)',
...getFullScreenStyles(fullScreen),
},
header: {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: theme.spacing.md,
marginRight: -9,
},
body: {
maxHeight: overflow === 'inside' ? 'calc(100vh - 185px)' : null,
overflowY: overflow === 'inside' ? 'auto' : null,
wordBreak: 'break-word',
},
})
);