From f5dfd52f6efece2f4cad227044ecf4dd66301bbc Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 26 Aug 2023 21:36:58 +0800 Subject: ... --- FrontEnd/src/components/dialog/DialogContainer.tsx | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 FrontEnd/src/components/dialog/DialogContainer.tsx (limited to 'FrontEnd/src/components/dialog/DialogContainer.tsx') diff --git a/FrontEnd/src/components/dialog/DialogContainer.tsx b/FrontEnd/src/components/dialog/DialogContainer.tsx new file mode 100644 index 00000000..afee2669 --- /dev/null +++ b/FrontEnd/src/components/dialog/DialogContainer.tsx @@ -0,0 +1,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; + bodyContainerClassName?: string; + bodyContainerRef?: Ref; + buttonsClassName?: string; + buttonsContainerRef?: ComponentProps["containerRef"]; + children: ReactNode; +} + +interface DialogContainerWithButtonsProps extends DialogContainerBaseProps { + buttons: ComponentProps["buttons"]; +} + +interface DialogContainerWithButtonsV2Props extends DialogContainerBaseProps { + buttonsV2: ComponentProps["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 ( +
+
+ {c(title)} +
+
+
+ {children} +
+
+ {"buttons" in props ? ( + + ) : ( + + )} +
+ ); +} -- cgit v1.2.3 From 5c624ecb5c7e33039d9f14dbce099e4874efb23b Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 30 Aug 2023 00:34:47 +0800 Subject: ... --- FrontEnd/src/components/dialog/ConfirmDialog.tsx | 5 ++--- FrontEnd/src/components/dialog/Dialog.css | 24 ++-------------------- FrontEnd/src/components/dialog/Dialog.tsx | 9 +++++++- FrontEnd/src/components/dialog/DialogContainer.css | 3 +-- FrontEnd/src/components/dialog/DialogContainer.tsx | 2 +- FrontEnd/src/components/dialog/OperationDialog.css | 4 ---- FrontEnd/src/components/dialog/OperationDialog.tsx | 2 +- FrontEnd/src/components/theme.css | 16 +++++++++++++++ 8 files changed, 31 insertions(+), 34 deletions(-) (limited to 'FrontEnd/src/components/dialog/DialogContainer.tsx') diff --git a/FrontEnd/src/components/dialog/ConfirmDialog.tsx b/FrontEnd/src/components/dialog/ConfirmDialog.tsx index a7b3917f..97cad452 100644 --- a/FrontEnd/src/components/dialog/ConfirmDialog.tsx +++ b/FrontEnd/src/components/dialog/ConfirmDialog.tsx @@ -9,7 +9,6 @@ export default function ConfirmDialog({ title, body, color, - bodyColor, }: { onConfirm: () => void; title: Text; @@ -22,7 +21,7 @@ export default function ConfirmDialog({ const closeDialog = useCloseDialog(); return ( - + -
{c(body)}
+
{c(body)}
); diff --git a/FrontEnd/src/components/dialog/Dialog.css b/FrontEnd/src/components/dialog/Dialog.css index f25309ae..e4f52a92 100644 --- a/FrontEnd/src/components/dialog/Dialog.css +++ b/FrontEnd/src/components/dialog/Dialog.css @@ -27,34 +27,14 @@ margin: 2em auto; - border: var(--cru-dialog-container-background-color) 1px solid; + border: var(--cru-theme-color) 2px solid; border-radius: 5px; padding: 1.5em; - background-color: var(--cru-surface-color); + background-color: var(--cru-dialog-container-background-color); } @media (min-width: 576px) { .cru-dialog-container { max-width: 800px; } -} - -.cru-dialog-enter .cru-dialog-container { - transform: scale(0, 0); - opacity: 0; - transform-origin: center; -} - -.cru-dialog-enter-active .cru-dialog-container { - transform: scale(1, 1); - opacity: 1; - transition: transform 0.3s, opacity 0.3s; - transform-origin: center; -} - -.cru-dialog-exit-active .cru-dialog-container { - transition: transform 0.3s, opacity 0.3s; - transform: scale(0, 0); - opacity: 0; - transform-origin: center; } \ No newline at end of file diff --git a/FrontEnd/src/components/dialog/Dialog.tsx b/FrontEnd/src/components/dialog/Dialog.tsx index bdba9198..85e8ca46 100644 --- a/FrontEnd/src/components/dialog/Dialog.tsx +++ b/FrontEnd/src/components/dialog/Dialog.tsx @@ -15,11 +15,13 @@ if (optionalPortalElement == null) { const portalElement = optionalPortalElement; interface DialogProps { + color?: ThemeColor; children?: ReactNode; disableCloseOnClickOnOverlay?: boolean; } export default function Dialog({ + color, children, disableCloseOnClickOnOverlay, }: DialogProps) { @@ -28,7 +30,12 @@ export default function Dialog({ const lastPointerDownIdRef = useRef(null); return ReactDOM.createPortal( -
+
{ diff --git a/FrontEnd/src/components/dialog/DialogContainer.css b/FrontEnd/src/components/dialog/DialogContainer.css index fbb18e0d..b3c52511 100644 --- a/FrontEnd/src/components/dialog/DialogContainer.css +++ b/FrontEnd/src/components/dialog/DialogContainer.css @@ -1,11 +1,10 @@ .cru-dialog-container-title { font-size: 1.2em; font-weight: bold; - color: var(--cru-key-color); + color: var(--cru-theme-color); margin-bottom: 0.5em; } - .cru-dialog-container-hr { margin: 1em 0; } diff --git a/FrontEnd/src/components/dialog/DialogContainer.tsx b/FrontEnd/src/components/dialog/DialogContainer.tsx index afee2669..6ee4e134 100644 --- a/FrontEnd/src/components/dialog/DialogContainer.tsx +++ b/FrontEnd/src/components/dialog/DialogContainer.tsx @@ -52,7 +52,7 @@ export default function DialogContainer(props: DialogContainerProps) {
diff --git a/FrontEnd/src/components/dialog/OperationDialog.css b/FrontEnd/src/components/dialog/OperationDialog.css index f4b7237e..28f73c9d 100644 --- a/FrontEnd/src/components/dialog/OperationDialog.css +++ b/FrontEnd/src/components/dialog/OperationDialog.css @@ -1,7 +1,3 @@ -.cru-operation-dialog-prompt { - color: var(--cru-surface-on-color); -} - .cru-operation-dialog-input-group { display: block; margin: 0.5em 0; diff --git a/FrontEnd/src/components/dialog/OperationDialog.tsx b/FrontEnd/src/components/dialog/OperationDialog.tsx index 902d60c6..4b4ceb36 100644 --- a/FrontEnd/src/components/dialog/OperationDialog.tsx +++ b/FrontEnd/src/components/dialog/OperationDialog.tsx @@ -217,7 +217,7 @@ function OperationDialog(props: OperationDialogProps) { } return ( - + {body} diff --git a/FrontEnd/src/components/theme.css b/FrontEnd/src/components/theme.css index d7e30d1a..67340b6f 100644 --- a/FrontEnd/src/components/theme.css +++ b/FrontEnd/src/components/theme.css @@ -14,6 +14,22 @@ --cru-danger-color: hsl(0 100% 50%); } +.cru-theme-primary { + --cru-theme-color: var(--cru-primary-color); +} + +.cru-theme-secondary { + --cru-theme-color: var(--cru-secondary-color); +} + +.cru-theme-create { + --cru-theme-color: var(--cru-create-color); +} + +.cru-theme-danger { + --cru-theme-color: var(--cru-danger-color); +} + /* common colors */ :root { --cru-background-color: hsl(0 0% 100%); -- cgit v1.2.3