From 34125b7c7a57b749cf8cbaf6bab8d3b186a52559 Mon Sep 17 00:00:00 2001
From: crupest <crupest@outlook.com>
Date: Tue, 11 Jul 2023 21:45:37 +0800
Subject: ...

---
 FrontEnd/src/views/common/button/FlatButton.tsx | 32 +++++++++++--------------
 1 file changed, 14 insertions(+), 18 deletions(-)

(limited to 'FrontEnd/src/views/common/button/FlatButton.tsx')

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;
-- 
cgit v1.2.3

