aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/common/button/FlatButton.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-07-11 21:45:37 +0800
committercrupest <crupest@outlook.com>2023-07-11 21:45:37 +0800
commit34125b7c7a57b749cf8cbaf6bab8d3b186a52559 (patch)
treee5782d2988ca5b45b4973d1c1da8d296f5eb47ce /FrontEnd/src/views/common/button/FlatButton.tsx
parent78f0934815a87573289c8e52af2666ea38c93251 (diff)
downloadtimeline-34125b7c7a57b749cf8cbaf6bab8d3b186a52559.tar.gz
timeline-34125b7c7a57b749cf8cbaf6bab8d3b186a52559.tar.bz2
timeline-34125b7c7a57b749cf8cbaf6bab8d3b186a52559.zip
...
Diffstat (limited to 'FrontEnd/src/views/common/button/FlatButton.tsx')
-rw-r--r--FrontEnd/src/views/common/button/FlatButton.tsx32
1 files changed, 14 insertions, 18 deletions
diff --git a/FrontEnd/src/views/common/button/FlatButton.tsx b/FrontEnd/src/views/common/button/FlatButton.tsx
index b42c5b3a..49912b68 100644
--- a/FrontEnd/src/views/common/button/FlatButton.tsx
+++ b/FrontEnd/src/views/common/button/FlatButton.tsx
@@ -1,41 +1,37 @@
-import * as React from "react";
-import { useTranslation } from "react-i18next";
+import { ComponentPropsWithoutRef, Ref } from "react";
import classNames from "classnames";
-import { convertI18nText, I18nText } from "@/common";
+import { I18nText, useC } from "@/common";
import { PaletteColorType } from "@/palette";
import "./FlatButton.css";
-function _FlatButton(
- props: {
- color?: PaletteColorType;
- text?: I18nText;
- } & React.ComponentPropsWithoutRef<"button">,
- ref: React.ForwardedRef<HTMLButtonElement>
-): React.ReactElement | null {
- const { t } = useTranslation();
+interface FlatButtonProps extends ComponentPropsWithoutRef<"button"> {
+ color?: PaletteColorType;
+ text?: I18nText;
+ buttonRef?: Ref<HTMLButtonElement> | null;
+}
- const { color, text, className, children, ...otherProps } = props;
+export default function FlatButton(props: FlatButtonProps) {
+ const { color, text, className, children, buttonRef, ...otherProps } = props;
if (text != null && children != null) {
console.warn("You can't set both text and children props.");
}
+ const c = useC();
+
return (
<button
- ref={ref}
+ ref={buttonRef}
className={classNames(
"cru-" + (color ?? "primary"),
"cru-flat-button",
- className
+ className,
)}
{...otherProps}
>
- {text != null ? convertI18nText(text, t) : children}
+ {text != null ? c(text) : children}
</button>
);
}
-
-const FlatButton = React.forwardRef(_FlatButton);
-export default FlatButton;