aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/common/button/FlatButton.tsx
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2023-07-12 15:25:15 +0800
committerGitHub <noreply@github.com>2023-07-12 15:25:15 +0800
commit4a069bf1268f393d5467166356f691eb89963152 (patch)
tree1bfa25fda4bd970a609c161b18e6616b5d5e8221 /FrontEnd/src/views/common/button/FlatButton.tsx
parent78f0934815a87573289c8e52af2666ea38c93251 (diff)
parent7781eede43be5fa277305ce9bd51bfc6a2a6ff46 (diff)
downloadtimeline-4a069bf1268f393d5467166356f691eb89963152.tar.gz
timeline-4a069bf1268f393d5467166356f691eb89963152.tar.bz2
timeline-4a069bf1268f393d5467166356f691eb89963152.zip
Merge pull request #1386 from crupest/dev
Develop.
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;