From ac40d9c18e2ac7b4995dac38d5da04a3ea7f1559 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 3 Sep 2020 18:10:02 +0800 Subject: Migrate to react-bootstrap. --- Timeline/ClientApp/src/app/views/common/AppBar.tsx | 2 +- .../ClientApp/src/app/views/common/FileInput.tsx | 36 --------- .../src/app/views/common/OperationDialog.tsx | 93 ++++++++++------------ .../src/app/views/common/alert/AlertHost.tsx | 9 ++- 4 files changed, 48 insertions(+), 92 deletions(-) delete mode 100644 Timeline/ClientApp/src/app/views/common/FileInput.tsx (limited to 'Timeline/ClientApp/src/app/views/common') diff --git a/Timeline/ClientApp/src/app/views/common/AppBar.tsx b/Timeline/ClientApp/src/app/views/common/AppBar.tsx index 464747c0..ee4ead8f 100644 --- a/Timeline/ClientApp/src/app/views/common/AppBar.tsx +++ b/Timeline/ClientApp/src/app/views/common/AppBar.tsx @@ -17,7 +17,7 @@ const AppBar: React.FC = (_) => { const isAdministrator = user && user.administrator; return ( - + diff --git a/Timeline/ClientApp/src/app/views/common/FileInput.tsx b/Timeline/ClientApp/src/app/views/common/FileInput.tsx deleted file mode 100644 index 7b053d5c..00000000 --- a/Timeline/ClientApp/src/app/views/common/FileInput.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React from "react"; -import clsx from "clsx"; - -export interface FileInputProps - extends Omit, "type" | "id"> { - inputId?: string; - labelText: string; - color?: string; - className?: string; -} - -const FileInput: React.FC = (props) => { - const { inputId, labelText, color, className, ...otherProps } = props; - - const realInputId = React.useMemo(() => { - if (inputId != null) return inputId; - return ( - "file-input-" + - (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) - ); - }, [inputId]); - - return ( - <> - - - - ); -}; - -export default FileInput; diff --git a/Timeline/ClientApp/src/app/views/common/OperationDialog.tsx b/Timeline/ClientApp/src/app/views/common/OperationDialog.tsx index 402ffbec..6f97eb15 100644 --- a/Timeline/ClientApp/src/app/views/common/OperationDialog.tsx +++ b/Timeline/ClientApp/src/app/views/common/OperationDialog.tsx @@ -1,26 +1,13 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; -import { - Spinner, - Container, - ModalBody, - Label, - Input, - FormGroup, - FormFeedback, - ModalFooter, - Button, - Modal, - ModalHeader, - FormText, -} from "reactstrap"; +import { Spinner, Container, Form, Button, Modal } from "react-bootstrap"; import { UiLogicError } from "@/common"; const DefaultProcessPrompt: React.FC = (_) => { return ( - + ); }; @@ -233,7 +220,7 @@ const OperationDialog: React.FC = (props) => { body = ( <> - + {inputPrompt} {inputScheme.map((item, index) => { const value = values[index]; @@ -242,9 +229,9 @@ const OperationDialog: React.FC = (props) => { if (item.type === "text") { return ( - - {item.label && } - + {item.label && {t(item.label)}} + { @@ -258,35 +245,35 @@ const OperationDialog: React.FC = (props) => { ) ); }} - invalid={error != null} - {...item.textFieldProps} + isInvalid={error != null} /> - {error != null && {error}} - {item.helperText && {t(item.helperText)}} - + {error != null && ( + {error} + )} + {item.helperText && ( + {t(item.helperText)} + )} + ); } else if (item.type === "bool") { return ( - - + type="checkbox" - value={value as string} - onChange={(e) => { - updateValue( - index, - (e.target as HTMLInputElement).checked - ); + checked={value as boolean} + onChange={(event) => { + updateValue(index, event.currentTarget.checked); }} + label={t(item.label)} /> - - + ); } else if (item.type === "select") { return ( - - - + {t(item.label)} + { updateValue(index, event.target.value); @@ -300,18 +287,18 @@ const OperationDialog: React.FC = (props) => { ); })} - - + + ); } })} - - - - + ); } else if (step === "process") { body = ( - + {props.processPrompt?.() ?? } - + ); } else { let content: React.ReactNode; @@ -345,12 +332,12 @@ const OperationDialog: React.FC = (props) => { } body = ( <> - {content} - - - + ); } @@ -359,7 +346,7 @@ const OperationDialog: React.FC = (props) => { return ( - = (props) => { } > {title} - + {body} ); diff --git a/Timeline/ClientApp/src/app/views/common/alert/AlertHost.tsx b/Timeline/ClientApp/src/app/views/common/alert/AlertHost.tsx index 31c0fb86..c74f18e2 100644 --- a/Timeline/ClientApp/src/app/views/common/alert/AlertHost.tsx +++ b/Timeline/ClientApp/src/app/views/common/alert/AlertHost.tsx @@ -1,8 +1,8 @@ import React, { useCallback } from "react"; -import { Alert } from "reactstrap"; import without from "lodash/without"; import concat from "lodash/concat"; import { useTranslation } from "react-i18next"; +import { Alert } from "react-bootstrap"; import { alertService, @@ -37,7 +37,12 @@ export const AutoCloseAlert: React.FC = (props) => { }, [dismissTime, props.close]); return ( - + {(() => { const { message } = alert; if (typeof message === "function") { -- cgit v1.2.3