diff options
author | crupest <crupest@outlook.com> | 2021-06-26 18:46:58 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-06-26 18:46:58 +0800 |
commit | 29da3cef05ef138af2028ad44a27d706e9ae2df8 (patch) | |
tree | 91e651c098e52a5a709cb780ba7847a8f6ec586a /FrontEnd/src/views/common | |
parent | fa540c046d126449f77e46edd379bbc84e02d05d (diff) | |
download | timeline-29da3cef05ef138af2028ad44a27d706e9ae2df8.tar.gz timeline-29da3cef05ef138af2028ad44a27d706e9ae2df8.tar.bz2 timeline-29da3cef05ef138af2028ad44a27d706e9ae2df8.zip |
...
Diffstat (limited to 'FrontEnd/src/views/common')
-rw-r--r-- | FrontEnd/src/views/common/ToggleIconButton.tsx | 30 | ||||
-rw-r--r-- | FrontEnd/src/views/common/button/LoadingButton.tsx (renamed from FrontEnd/src/views/common/LoadingButton.tsx) | 1 | ||||
-rw-r--r-- | FrontEnd/src/views/common/dailog/ConfirmDialog.tsx (renamed from FrontEnd/src/views/common/ConfirmDialog.tsx) | 22 | ||||
-rw-r--r-- | FrontEnd/src/views/common/dailog/Dialog.css | 0 | ||||
-rw-r--r-- | FrontEnd/src/views/common/dailog/Dialog.tsx | 13 | ||||
-rw-r--r-- | FrontEnd/src/views/common/dailog/OperationDialog.tsx (renamed from FrontEnd/src/views/common/OperationDialog.tsx) | 43 |
6 files changed, 45 insertions, 64 deletions
diff --git a/FrontEnd/src/views/common/ToggleIconButton.tsx b/FrontEnd/src/views/common/ToggleIconButton.tsx deleted file mode 100644 index c4d2d132..00000000 --- a/FrontEnd/src/views/common/ToggleIconButton.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from "react"; -import classnames from "classnames"; - -export interface ToggleIconButtonProps - extends React.HTMLAttributes<HTMLElement> { - state: boolean; - trueIconClassName: string; - falseIconClassName: string; -} - -const ToggleIconButton: React.FC<ToggleIconButtonProps> = ({ - state, - className, - trueIconClassName, - falseIconClassName, - ...otherProps -}) => { - return ( - <i - className={classnames( - state ? trueIconClassName : falseIconClassName, - "icon-button", - className - )} - {...otherProps} - /> - ); -}; - -export default ToggleIconButton; diff --git a/FrontEnd/src/views/common/LoadingButton.tsx b/FrontEnd/src/views/common/button/LoadingButton.tsx index cd9f1adc..fd1c19b3 100644 --- a/FrontEnd/src/views/common/LoadingButton.tsx +++ b/FrontEnd/src/views/common/button/LoadingButton.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { Button, ButtonProps, Spinner } from "react-bootstrap"; const LoadingButton: React.FC<{ loading?: boolean } & ButtonProps> = ({ loading, diff --git a/FrontEnd/src/views/common/ConfirmDialog.tsx b/FrontEnd/src/views/common/dailog/ConfirmDialog.tsx index 70dc83f5..1ad52350 100644 --- a/FrontEnd/src/views/common/ConfirmDialog.tsx +++ b/FrontEnd/src/views/common/dailog/ConfirmDialog.tsx @@ -2,25 +2,23 @@ import { convertI18nText, I18nText } from "@/common"; import React from "react"; import { useTranslation } from "react-i18next"; -import Button from "./button/Button"; +import Button from "../button/Button"; +import Dialog from "./Dialog"; const ConfirmDialog: React.FC<{ + open?: boolean; onClose: () => void; onConfirm: () => void; title: I18nText; body: I18nText; -}> = ({ onClose, onConfirm, title, body }) => { +}> = ({ open, onClose, onConfirm, title, body }) => { const { t } = useTranslation(); return ( - <Modal onHide={onClose} show centered> - <Modal.Header> - <Modal.Title className="text-danger"> - {convertI18nText(title, t)} - </Modal.Title> - </Modal.Header> - <Modal.Body>{convertI18nText(body, t)}</Modal.Body> - <Modal.Footer> + <Dialog onClose={onClose} open={open}> + <h3 className="text-danger">{convertI18nText(title, t)}</h3> + <p>{convertI18nText(body, t)}</p> + <div> <Button text="operationDialog.cancel" color="secondary" @@ -34,8 +32,8 @@ const ConfirmDialog: React.FC<{ onClose(); }} /> - </Modal.Footer> - </Modal> + </div> + </Dialog> ); }; diff --git a/FrontEnd/src/views/common/dailog/Dialog.css b/FrontEnd/src/views/common/dailog/Dialog.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/FrontEnd/src/views/common/dailog/Dialog.css diff --git a/FrontEnd/src/views/common/dailog/Dialog.tsx b/FrontEnd/src/views/common/dailog/Dialog.tsx new file mode 100644 index 00000000..5a3902c4 --- /dev/null +++ b/FrontEnd/src/views/common/dailog/Dialog.tsx @@ -0,0 +1,13 @@ +import React from "react"; + +export interface DialogProps { + onClose: () => void; + open?: boolean; + children?: React.ReactNode; +} + +export default function Dialog(props: DialogProps): React.ReactElement | null { + const { open, onClose, children } = props; + + return <div>{children}</div>; +} diff --git a/FrontEnd/src/views/common/OperationDialog.tsx b/FrontEnd/src/views/common/dailog/OperationDialog.tsx index ac4c51b9..129e85d5 100644 --- a/FrontEnd/src/views/common/OperationDialog.tsx +++ b/FrontEnd/src/views/common/dailog/OperationDialog.tsx @@ -1,12 +1,13 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; -import { Form, Button, Modal } from "react-bootstrap"; import { TwitterPicker } from "react-color"; import moment from "moment"; import { convertI18nText, I18nText, UiLogicError } from "@/common"; -import LoadingButton from "./LoadingButton"; +import Button from "../button/Button"; +import LoadingButton from "../button/LoadingButton"; +import Dialog from "./Dialog"; interface DefaultErrorPromptProps { error?: string; @@ -141,7 +142,7 @@ export interface OperationDialogProps< OperationInputInfoList extends readonly OperationDialogInput[] > { open: boolean; - close: () => void; + onClose: () => void; title: I18nText | (() => React.ReactNode); themeColor?: "danger" | "success" | string; onProcess: ( @@ -204,7 +205,7 @@ const OperationDialog = < const close = (): void => { if (step.type !== "process") { - props.close(); + props.onClose(); if (step.type === "success" && props.onSuccessAndClose) { props.onSuccessAndClose(step.data); } @@ -278,7 +279,7 @@ const OperationDialog = < body = ( <> - <Modal.Body> + <div> {inputPrompt} {inputScheme.map((item, index) => { const value = values[index]; @@ -403,11 +404,13 @@ const OperationDialog = < ); } })} - </Modal.Body> - <Modal.Footer> - <Button variant="outline-secondary" onClick={close}> - {t("operationDialog.cancel")} - </Button> + </div> + <div> + <Button + text="operationDialog.cancel" + color="secondary" + onClick={close} + /> <LoadingButton variant={props.themeColor} loading={process} @@ -421,7 +424,7 @@ const OperationDialog = < > {t("operationDialog.confirm")} </LoadingButton> - </Modal.Footer> + </div> </> ); } else { @@ -439,12 +442,10 @@ const OperationDialog = < } body = ( <> - <Modal.Body>{content}</Modal.Body> - <Modal.Footer> - <Button variant="primary" onClick={close}> - {t("operationDialog.ok")} - </Button> - </Modal.Footer> + <div>{content}</div> + <div> + <Button text="operationDialog.ok" color="primary" onClick={close} /> + </div> </> ); } @@ -455,16 +456,16 @@ const OperationDialog = < : convertI18nText(props.title, t); return ( - <Modal show={props.open} onHide={close}> - <Modal.Header + <Dialog open={props.open} onClose={close}> + <h3 className={ props.themeColor != null ? "text-" + props.themeColor : undefined } > {title} - </Modal.Header> + </h3> {body} - </Modal> + </Dialog> ); }; |