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
|
import { ComponentProps, Ref, ReactNode } from "react";
import classNames from "classnames";
import { ThemeColor, Text, useC } from "../common";
import { ButtonRow, ButtonRowV2 } from "../button";
import "./DialogContainer.css";
interface DialogContainerBaseProps {
className?: string;
title: Text;
titleColor?: ThemeColor;
titleClassName?: string;
titleRef?: Ref<HTMLDivElement>;
bodyContainerClassName?: string;
bodyContainerRef?: Ref<HTMLDivElement>;
buttonsClassName?: string;
buttonsContainerRef?: ComponentProps<typeof ButtonRow>["containerRef"];
children: ReactNode;
}
interface DialogContainerWithButtonsProps extends DialogContainerBaseProps {
buttons: ComponentProps<typeof ButtonRow>["buttons"];
}
interface DialogContainerWithButtonsV2Props extends DialogContainerBaseProps {
buttonsV2: ComponentProps<typeof ButtonRowV2>["buttons"];
}
type DialogContainerProps =
| DialogContainerWithButtonsProps
| DialogContainerWithButtonsV2Props;
export default function DialogContainer(props: DialogContainerProps) {
const {
className,
title,
titleColor,
titleClassName,
titleRef,
bodyContainerClassName,
bodyContainerRef,
buttonsClassName,
buttonsContainerRef,
children,
} = props;
const c = useC();
return (
<div className={classNames(className)}>
<div
ref={titleRef}
className={classNames(
`cru-dialog-container-title cru-theme-${titleColor ?? "primary"}`,
titleClassName,
)}
>
{c(title)}
</div>
<hr className="cru-dialog-container-hr" />
<div
ref={bodyContainerRef}
className={classNames(
"cru-dialog-container-body",
bodyContainerClassName,
)}
>
{children}
</div>
<hr className="cru-dialog-container-hr" />
{"buttons" in props ? (
<ButtonRow
containerRef={buttonsContainerRef}
className={classNames(
"cru-dialog-container-button-row",
buttonsClassName,
)}
buttons={props.buttons}
buttonsClassName="cru-dialog-container-button"
/>
) : (
<ButtonRowV2
containerRef={buttonsContainerRef}
className={classNames(
"cru-dialog-container-button-row",
buttonsClassName,
)}
buttons={props.buttonsV2}
buttonsClassName="cru-dialog-container-button"
/>
)}
</div>
);
}
|