diff options
author | crupest <crupest@outlook.com> | 2023-08-19 02:13:26 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-08-19 02:13:26 +0800 |
commit | d6c1c9f2c9eddd7d6e4e91b2a9de71cfd9db6b73 (patch) | |
tree | 4b546fe67049a8211b3265a5d3316ae3947ac6e7 /FrontEnd/src/views/common/dialog/DialogContainer.tsx | |
parent | eec2e74a928f6448a0503e003d8afa693730b365 (diff) | |
download | timeline-d6c1c9f2c9eddd7d6e4e91b2a9de71cfd9db6b73.tar.gz timeline-d6c1c9f2c9eddd7d6e4e91b2a9de71cfd9db6b73.tar.bz2 timeline-d6c1c9f2c9eddd7d6e4e91b2a9de71cfd9db6b73.zip |
...
Diffstat (limited to 'FrontEnd/src/views/common/dialog/DialogContainer.tsx')
-rw-r--r-- | FrontEnd/src/views/common/dialog/DialogContainer.tsx | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/FrontEnd/src/views/common/dialog/DialogContainer.tsx b/FrontEnd/src/views/common/dialog/DialogContainer.tsx index b0a87ea5..afee2669 100644 --- a/FrontEnd/src/views/common/dialog/DialogContainer.tsx +++ b/FrontEnd/src/views/common/dialog/DialogContainer.tsx @@ -2,11 +2,11 @@ import { ComponentProps, Ref, ReactNode } from "react"; import classNames from "classnames"; import { ThemeColor, Text, useC } from "../common"; -import { ButtonRow } from "../button"; +import { ButtonRow, ButtonRowV2 } from "../button"; import "./DialogContainer.css"; -interface DialogContainerProps { +interface DialogContainerBaseProps { className?: string; title: Text; titleColor?: ThemeColor; @@ -14,25 +14,37 @@ interface DialogContainerProps { titleRef?: Ref<HTMLDivElement>; bodyContainerClassName?: string; bodyContainerRef?: Ref<HTMLDivElement>; - buttons: ComponentProps<typeof ButtonRow>["buttons"]; buttonsClassName?: string; buttonsContainerRef?: ComponentProps<typeof ButtonRow>["containerRef"]; children: ReactNode; } -export default function DialogContainer({ - className, - title, - titleColor, - titleClassName, - titleRef, - bodyContainerClassName, - bodyContainerRef, - buttons, - buttonsClassName, - buttonsContainerRef, - children, -}: DialogContainerProps) { +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 ( @@ -57,12 +69,27 @@ export default function DialogContainer({ {children} </div> <hr className="cru-dialog-container-hr" /> - <ButtonRow - containerRef={buttonsContainerRef} - className={classNames("cru-dialog-container-button-row", buttonsClassName)} - buttons={buttons} - buttonsClassName="cru-dialog-container-button" - /> + {"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> ); } |