diff options
author | crupest <crupest@outlook.com> | 2023-07-12 15:25:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-12 15:25:15 +0800 |
commit | 4a069bf1268f393d5467166356f691eb89963152 (patch) | |
tree | 1bfa25fda4bd970a609c161b18e6616b5d5e8221 /FrontEnd/src/views/common/button/Button.tsx | |
parent | 78f0934815a87573289c8e52af2666ea38c93251 (diff) | |
parent | 7781eede43be5fa277305ce9bd51bfc6a2a6ff46 (diff) | |
download | timeline-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/Button.tsx')
-rw-r--r-- | FrontEnd/src/views/common/button/Button.tsx | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/FrontEnd/src/views/common/button/Button.tsx b/FrontEnd/src/views/common/button/Button.tsx index c5976909..be605328 100644 --- a/FrontEnd/src/views/common/button/Button.tsx +++ b/FrontEnd/src/views/common/button/Button.tsx @@ -1,43 +1,47 @@ -import * as React from "react"; +import { ComponentPropsWithoutRef, Ref } from "react"; import classNames from "classnames"; -import { useTranslation } from "react-i18next"; -import { convertI18nText, I18nText } from "@/common"; +import { I18nText, useC } from "@/common"; import { PaletteColorType } from "@/palette"; import "./Button.css"; -function _Button( - props: { - color?: PaletteColorType; - text?: I18nText; - outline?: boolean; - } & React.ComponentPropsWithoutRef<"button">, - ref: React.ForwardedRef<HTMLButtonElement> -): JSX.Element { - const { t } = useTranslation(); +interface ButtonProps extends ComponentPropsWithoutRef<"button"> { + color?: PaletteColorType; + text?: I18nText; + outline?: boolean; + buttonRef?: Ref<HTMLButtonElement> | null; +} - const { color, text, outline, className, children, ...otherProps } = props; +export default function Button(props: ButtonProps) { + const { + buttonRef, + color, + text, + outline, + className, + children, + ...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-button", outline && "outline", - className + className, )} {...otherProps} > - {text != null ? convertI18nText(text, t) : children} + {text != null ? c(text) : children} </button> ); } - -const Button = React.forwardRef(_Button); -export default Button; |