blob: 575abf7fc4c737eb0c4b9c132ee263270507aac3 (
plain)
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
|
import { ReactNode } from "react";
import { createPortal } from "react-dom";
import classNames from "classnames";
import { ThemeColor, UiLogicError } from "../common";
import { IconButton } from "../button";
import { useCloseDialog } from "./DialogProvider";
import "./FullPageDialog.css";
const optionalPortalElement = document.getElementById("portal");
if (optionalPortalElement == null) {
throw new UiLogicError();
}
const portalElement = optionalPortalElement;
interface FullPageDialogProps {
color?: ThemeColor;
contentContainerClassName?: string;
children: ReactNode;
}
export default function FullPageDialog({
color,
children,
contentContainerClassName,
}: FullPageDialogProps) {
const closeDialog = useCloseDialog();
return createPortal(
<div className={`cru-dialog-full-page cru-theme-${color ?? "primary"}`}>
<div className="cru-dialog-full-page-top-bar">
<IconButton
icon="arrow-left"
color="light"
className="cru-dialog-full-page-back-button"
onClick={closeDialog}
/>
</div>
<div
className={classNames(
"cru-dialog-full-page-content-container",
contentContainerClassName,
)}
>
{children}
</div>
</div>,
portalElement,
);
}
|