diff options
author | crupest <crupest@outlook.com> | 2022-05-04 11:35:47 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-05-04 11:35:47 +0800 |
commit | a90f1a5041cf4a622f41f3b2680052e3a4d5ba11 (patch) | |
tree | f4d656cea49370d02f99dd870dc89ff02cfa3fed /FrontEnd/src/views/common/button/FlatButton.tsx | |
parent | 1caaa504cda68e08d52127949ea7f5e2eb2f304e (diff) | |
download | timeline-a90f1a5041cf4a622f41f3b2680052e3a4d5ba11.tar.gz timeline-a90f1a5041cf4a622f41f3b2680052e3a4d5ba11.tar.bz2 timeline-a90f1a5041cf4a622f41f3b2680052e3a4d5ba11.zip |
...
Diffstat (limited to 'FrontEnd/src/views/common/button/FlatButton.tsx')
-rw-r--r-- | FrontEnd/src/views/common/button/FlatButton.tsx | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/FrontEnd/src/views/common/button/FlatButton.tsx b/FrontEnd/src/views/common/button/FlatButton.tsx index 266ea908..a6377708 100644 --- a/FrontEnd/src/views/common/button/FlatButton.tsx +++ b/FrontEnd/src/views/common/button/FlatButton.tsx @@ -1,16 +1,39 @@ import React from "react"; +import { useTranslation } from "react-i18next"; +import classNames from "classnames"; -import { CommonButtonProps } from "./common"; -import Button from "./Button"; +import { convertI18nText, I18nText } from "@/common"; +import { PaletteColorType } from "@/palette"; import "./FlatButton.css"; function _FlatButton( - props: CommonButtonProps, + props: { + color?: PaletteColorType; + text?: I18nText; + } & React.ComponentPropsWithoutRef<"button">, ref: React.ForwardedRef<HTMLButtonElement> ): React.ReactElement | null { + const { t } = useTranslation(); + + const { color, text, className, children, ...otherProps } = props; + + if (text != null && children != null) { + console.warn("You can't set both text and children props."); + } + return ( - <Button ref={ref} customButtonClassName="cru-flat-button" {...props} /> + <button + ref={ref} + className={classNames( + "cru-" + (color ?? "primary"), + "cru-flat-button", + className + )} + {...otherProps} + > + {text != null ? convertI18nText(text, t) : children} + </button> ); } |