diff options
author | crupest <crupest@outlook.com> | 2023-09-21 23:49:12 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-09-21 23:49:12 +0800 |
commit | d477c7270c90b190ed82b13f48f39a05d83503d2 (patch) | |
tree | 572f74b2adc75247b9d1c9a8965e3de2559d4160 /FrontEnd/src/components | |
parent | a8a8385cd959e4d9d57b8a35381d2851049c07ff (diff) | |
download | timeline-d477c7270c90b190ed82b13f48f39a05d83503d2.tar.gz timeline-d477c7270c90b190ed82b13f48f39a05d83503d2.tar.bz2 timeline-d477c7270c90b190ed82b13f48f39a05d83503d2.zip |
Fix #1394.
Diffstat (limited to 'FrontEnd/src/components')
-rw-r--r-- | FrontEnd/src/components/AppBar.tsx | 3 | ||||
-rw-r--r-- | FrontEnd/src/components/SearchInput.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/alert/AlertHost.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/alert/AlertService.ts | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/button/Button.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/button/ButtonRowV2.tsx | 10 | ||||
-rw-r--r-- | FrontEnd/src/components/button/FlatButton.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/common.ts | 9 | ||||
-rw-r--r-- | FrontEnd/src/components/dialog/ConfirmDialog.tsx | 6 | ||||
-rw-r--r-- | FrontEnd/src/components/dialog/DialogContainer.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/dialog/OperationDialog.tsx | 14 | ||||
-rw-r--r-- | FrontEnd/src/components/hooks/useWindowLeave.ts | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/input/InputGroup.tsx | 14 | ||||
-rw-r--r-- | FrontEnd/src/components/menu/Menu.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/tab/TabBar.tsx | 4 | ||||
-rw-r--r-- | FrontEnd/src/components/tab/TabPages.tsx | 4 |
16 files changed, 49 insertions, 47 deletions
diff --git a/FrontEnd/src/components/AppBar.tsx b/FrontEnd/src/components/AppBar.tsx index d40c8105..6ea8bdac 100644 --- a/FrontEnd/src/components/AppBar.tsx +++ b/FrontEnd/src/components/AppBar.tsx @@ -37,7 +37,8 @@ function AppBarNavLink({ className={({ isActive }) => classnames(className, isActive && "active")} onClick={onClick} > - {children != null ? children : c(label)} + {children} + {label && c(label)} </NavLink> ); } diff --git a/FrontEnd/src/components/SearchInput.tsx b/FrontEnd/src/components/SearchInput.tsx index b1de6227..04341245 100644 --- a/FrontEnd/src/components/SearchInput.tsx +++ b/FrontEnd/src/components/SearchInput.tsx @@ -1,6 +1,6 @@ import classNames from "classnames"; -import { useC, Text } from "./common"; +import { useC, I18nText } from "./common"; import { LoadingButton } from "./button"; import "./SearchInput.css"; @@ -11,7 +11,7 @@ interface SearchInputProps { onButtonClick: () => void; loading?: boolean; className?: string; - buttonText?: Text; + buttonText?: I18nText; } export default function SearchInput({ diff --git a/FrontEnd/src/components/alert/AlertHost.tsx b/FrontEnd/src/components/alert/AlertHost.tsx index 59f8f27c..8dca42d5 100644 --- a/FrontEnd/src/components/alert/AlertHost.tsx +++ b/FrontEnd/src/components/alert/AlertHost.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; import classNames from "classnames"; -import { ThemeColor, useC, Text } from "../common"; +import { ThemeColor, useC, I18nText } from "../common"; import IconButton from "../button/IconButton"; import { alertService, AlertInfoWithId } from "./AlertService"; @@ -10,7 +10,7 @@ import "./alert.css"; interface AutoCloseAlertProps { color: ThemeColor; - message: Text; + message: I18nText; onDismiss?: () => void; onIn?: () => void; onOut?: () => void; diff --git a/FrontEnd/src/components/alert/AlertService.ts b/FrontEnd/src/components/alert/AlertService.ts index b9cda752..8e98cc4d 100644 --- a/FrontEnd/src/components/alert/AlertService.ts +++ b/FrontEnd/src/components/alert/AlertService.ts @@ -1,10 +1,10 @@ -import { ThemeColor, Text } from "../common"; +import { ThemeColor, I18nText } from "../common"; const defaultDismissTime = 5000; export interface AlertInfo { color?: ThemeColor; - message: Text; + message: I18nText; dismissTime?: number | "never"; } diff --git a/FrontEnd/src/components/button/Button.tsx b/FrontEnd/src/components/button/Button.tsx index 30ea8c11..bdb7bb2d 100644 --- a/FrontEnd/src/components/button/Button.tsx +++ b/FrontEnd/src/components/button/Button.tsx @@ -1,13 +1,13 @@ import { ComponentPropsWithoutRef, Ref } from "react"; import classNames from "classnames"; -import { Text, useC, ClickableColor } from "../common"; +import { I18nText, useC, ClickableColor } from "../common"; import "./Button.css"; interface ButtonProps extends ComponentPropsWithoutRef<"button"> { color?: ClickableColor; - text?: Text; + text?: I18nText; outline?: boolean; buttonRef?: Ref<HTMLButtonElement> | null; } diff --git a/FrontEnd/src/components/button/ButtonRowV2.tsx b/FrontEnd/src/components/button/ButtonRowV2.tsx index a54425cc..75f2ad9d 100644 --- a/FrontEnd/src/components/button/ButtonRowV2.tsx +++ b/FrontEnd/src/components/button/ButtonRowV2.tsx @@ -1,7 +1,7 @@ import { ComponentPropsWithoutRef, Ref } from "react"; import classNames from "classnames"; -import { Text, ClickableColor } from "../common"; +import { I18nText, ClickableColor } from "../common"; import Button from "./Button"; import FlatButton from "./FlatButton"; @@ -22,21 +22,21 @@ interface ButtonRowV2ButtonBase { interface ButtonRowV2ButtonWithNoType extends ButtonRowV2ButtonBase { type?: undefined | null; - text: Text; + text: I18nText; outline?: boolean; props?: ComponentPropsWithoutRef<typeof Button>; } interface ButtonRowV2NormalButton extends ButtonRowV2ButtonBase { type: "normal"; - text: Text; + text: I18nText; outline?: boolean; props?: ComponentPropsWithoutRef<typeof Button>; } interface ButtonRowV2FlatButton extends ButtonRowV2ButtonBase { type: "flat"; - text: Text; + text: I18nText; props?: ComponentPropsWithoutRef<typeof FlatButton>; } @@ -48,7 +48,7 @@ interface ButtonRowV2IconButton extends ButtonRowV2ButtonBase { interface ButtonRowV2LoadingButton extends ButtonRowV2ButtonBase { type: "loading"; - text: Text; + text: I18nText; loading?: boolean; props?: ComponentPropsWithoutRef<typeof LoadingButton>; } diff --git a/FrontEnd/src/components/button/FlatButton.tsx b/FrontEnd/src/components/button/FlatButton.tsx index aad02e76..e15b8c2b 100644 --- a/FrontEnd/src/components/button/FlatButton.tsx +++ b/FrontEnd/src/components/button/FlatButton.tsx @@ -1,13 +1,13 @@ import { ComponentPropsWithoutRef, Ref } from "react"; import classNames from "classnames"; -import { Text, useC, ClickableColor } from "../common"; +import { I18nText, useC, ClickableColor } from "../common"; import "./FlatButton.css"; interface FlatButtonProps extends ComponentPropsWithoutRef<"button"> { color?: ClickableColor; - text?: Text; + text?: I18nText; buttonRef?: Ref<HTMLButtonElement> | null; } diff --git a/FrontEnd/src/components/common.ts b/FrontEnd/src/components/common.ts index a6c3e705..840e1be5 100644 --- a/FrontEnd/src/components/common.ts +++ b/FrontEnd/src/components/common.ts @@ -1,7 +1,9 @@ import "./index.css"; -export type { Text, I18nText } from "~src/common"; -export { UiLogicError, c, convertI18nText, useC } from "~src/common"; +export type { I18nText } from "~src/i18n"; +export { convertI18nText, useC } from "~src/i18n"; + +export class UiLogicError extends Error {} export const themeColors = [ "primary", @@ -18,5 +20,4 @@ export { breakpoints } from "./breakpoints"; export * as geometry from "~src/utilities/geometry"; -export * as array from "~src/utilities/array" - +export * as array from "~src/utilities/array"; diff --git a/FrontEnd/src/components/dialog/ConfirmDialog.tsx b/FrontEnd/src/components/dialog/ConfirmDialog.tsx index 4ee0ec03..199eee6b 100644 --- a/FrontEnd/src/components/dialog/ConfirmDialog.tsx +++ b/FrontEnd/src/components/dialog/ConfirmDialog.tsx @@ -1,4 +1,4 @@ -import { useC, Text, ThemeColor } from "../common"; +import { useC, I18nText, ThemeColor } from "../common"; import Dialog from "./Dialog"; import DialogContainer from "./DialogContainer"; @@ -14,8 +14,8 @@ export default function ConfirmDialog({ open: boolean; onClose: () => void; onConfirm: () => void; - title: Text; - body: Text; + title: I18nText; + body: I18nText; color?: ThemeColor; bodyColor?: ThemeColor; }) { diff --git a/FrontEnd/src/components/dialog/DialogContainer.tsx b/FrontEnd/src/components/dialog/DialogContainer.tsx index 6ee4e134..844d8ddd 100644 --- a/FrontEnd/src/components/dialog/DialogContainer.tsx +++ b/FrontEnd/src/components/dialog/DialogContainer.tsx @@ -1,14 +1,14 @@ import { ComponentProps, Ref, ReactNode } from "react"; import classNames from "classnames"; -import { ThemeColor, Text, useC } from "../common"; +import { ThemeColor, I18nText, useC } from "../common"; import { ButtonRow, ButtonRowV2 } from "../button"; import "./DialogContainer.css"; interface DialogContainerBaseProps { className?: string; - title: Text; + title: I18nText; titleColor?: ThemeColor; titleClassName?: string; titleRef?: Ref<HTMLDivElement>; diff --git a/FrontEnd/src/components/dialog/OperationDialog.tsx b/FrontEnd/src/components/dialog/OperationDialog.tsx index feaf5c79..4541d6f8 100644 --- a/FrontEnd/src/components/dialog/OperationDialog.tsx +++ b/FrontEnd/src/components/dialog/OperationDialog.tsx @@ -1,7 +1,7 @@ import { useState, ReactNode, ComponentProps } from "react"; import classNames from "classnames"; -import { useC, Text, ThemeColor } from "../common"; +import { useC, I18nText, ThemeColor } from "../common"; import { useInputs, InputGroup, @@ -15,8 +15,8 @@ import DialogContainer from "./DialogContainer"; import "./OperationDialog.css"; interface OperationDialogPromptProps { - message?: Text; - customMessage?: Text; + message?: I18nText; + customMessage?: I18nText; customMessageNode?: ReactNode; className?: string; } @@ -39,12 +39,12 @@ export interface OperationDialogProps<TData> { onClose: () => void; color?: ThemeColor; inputColor?: ThemeColor; - title: Text; - inputPrompt?: Text; + title: I18nText; + inputPrompt?: I18nText; inputPromptNode?: ReactNode; - successPrompt?: (data: TData) => Text; + successPrompt?: (data: TData) => I18nText; successPromptNode?: (data: TData) => ReactNode; - failurePrompt?: (error: unknown) => Text; + failurePrompt?: (error: unknown) => I18nText; failurePromptNode?: (error: unknown) => ReactNode; inputs: InputInitializer; diff --git a/FrontEnd/src/components/hooks/useWindowLeave.ts b/FrontEnd/src/components/hooks/useWindowLeave.ts index ecd999d4..b829a92f 100644 --- a/FrontEnd/src/components/hooks/useWindowLeave.ts +++ b/FrontEnd/src/components/hooks/useWindowLeave.ts @@ -1,10 +1,10 @@ import { useEffect } from "react"; -import { useC, Text } from "../common"; +import { useC, I18nText } from "../common"; export default function useWindowLeave( allow: boolean, - message: Text = "timeline.confirmLeave", + message: I18nText = "timeline.confirmLeave", ) { const c = useC(); diff --git a/FrontEnd/src/components/input/InputGroup.tsx b/FrontEnd/src/components/input/InputGroup.tsx index 47a43b38..be6cd577 100644 --- a/FrontEnd/src/components/input/InputGroup.tsx +++ b/FrontEnd/src/components/input/InputGroup.tsx @@ -26,16 +26,16 @@ import { useState, Ref, useId } from "react"; import classNames from "classnames"; -import { useC, Text, ThemeColor } from "../common"; +import { useC, I18nText, ThemeColor } from "../common"; import "./InputGroup.css"; export interface InputBase { key: string; - label: Text; - helper?: Text; + label: I18nText; + helper?: I18nText; disabled?: boolean; - error?: Text; + error?: I18nText; } export interface TextInput extends InputBase { @@ -51,7 +51,7 @@ export interface BoolInput extends InputBase { export interface SelectInputOption { value: string; - label: Text; + label: I18nText; icon?: string; } @@ -66,14 +66,14 @@ export type Input = TextInput | BoolInput | SelectInput; export type InputValue = Input["value"]; export type InputValueDict = Record<string, InputValue>; -export type InputErrorDict = Record<string, Text>; +export type InputErrorDict = Record<string, I18nText>; export type InputDisabledDict = Record<string, boolean>; export type InputDirtyDict = Record<string, boolean>; // use never so you don't have to cast everywhere export type InputConfirmValueDict = Record<string, never>; export type GeneralInputErrorDict = { - [key: string]: Text | null | undefined; + [key: string]: I18nText | null | undefined; }; type MakeInputInfo<I extends Input> = Omit<I, "value" | "error" | "disabled">; diff --git a/FrontEnd/src/components/menu/Menu.tsx b/FrontEnd/src/components/menu/Menu.tsx index 1a196a69..6093a56f 100644 --- a/FrontEnd/src/components/menu/Menu.tsx +++ b/FrontEnd/src/components/menu/Menu.tsx @@ -1,7 +1,7 @@ import { MouseEvent, CSSProperties } from "react"; import classNames from "classnames"; -import { useC, Text, ThemeColor } from "../common"; +import { useC, I18nText, ThemeColor } from "../common"; import Icon from "../Icon"; import "./Menu.css"; @@ -12,7 +12,7 @@ export type MenuItem = } | { type: "button"; - text: Text; + text: I18nText; icon?: string; color?: ThemeColor; onClick?: (e: MouseEvent<HTMLButtonElement>) => void; diff --git a/FrontEnd/src/components/tab/TabBar.tsx b/FrontEnd/src/components/tab/TabBar.tsx index 601f664d..6957b700 100644 --- a/FrontEnd/src/components/tab/TabBar.tsx +++ b/FrontEnd/src/components/tab/TabBar.tsx @@ -2,13 +2,13 @@ import { ReactNode } from "react"; import { Link } from "react-router-dom"; import classNames from "classnames"; -import { Text, ThemeColor, useC } from "../common"; +import { I18nText, ThemeColor, useC } from "../common"; import "./TabBar.css"; export interface Tab { name: string; - text: Text; + text: I18nText; link?: string; onClick?: () => void; } diff --git a/FrontEnd/src/components/tab/TabPages.tsx b/FrontEnd/src/components/tab/TabPages.tsx index ab45ffdf..71065b01 100644 --- a/FrontEnd/src/components/tab/TabPages.tsx +++ b/FrontEnd/src/components/tab/TabPages.tsx @@ -1,7 +1,7 @@ import { ReactNode, useState } from "react"; import classNames from "classnames"; -import { Text, UiLogicError } from "../common"; +import { I18nText, UiLogicError } from "../common"; import Tabs from "./TabBar"; @@ -9,7 +9,7 @@ import "./TabPages.css"; interface TabPage { name: string; - text: Text; + text: I18nText; page: ReactNode; } |