-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathuseModals.tsx
59 lines (52 loc) · 1.36 KB
/
useModals.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
import { ModalProps, useMantineTheme } from "@mantine/core"
import {
useModals as useMantineModals,
openConfirmModal,
openModal,
closeAllModals,
} from "@mantine/modals"
type OpenModalProps = Parameters<typeof openModal>[0]
type OpenConfirmationModalProps = Parameters<typeof openConfirmModal>[0]
type CommonModalProps = Partial<Omit<ModalProps, "opened">>
const useModals = () => {
const theme = useMantineTheme()
const { modals: modalsOpen } = useMantineModals()
const commonModalProps: CommonModalProps = {
centered: true,
overlayProps: {
color: theme.colors.navy[9],
opacity: 0.8,
blur: 3,
},
padding: "md",
}
const openConfirmationModal = (modalProps: OpenConfirmationModalProps) =>
openConfirmModal({
...commonModalProps,
groupProps: { grow: true, mt: 32 },
...modalProps,
})
const openContentModal = (modalProps: OpenModalProps) => {
openModal({
...commonModalProps,
...modalProps,
})
}
const openFullScreenModal = (modalProps: OpenModalProps) => {
openModal({
fullScreen: true,
withCloseButton: false,
styles: { body: { marginTop: "90px" } },
...commonModalProps,
...modalProps,
})
}
return {
openConfirmationModal,
openContentModal,
openFullScreenModal,
modalsOpen,
closeAllModals,
}
}
export default useModals