diff options
Diffstat (limited to 'FrontEnd/src/views/common/button')
-rw-r--r-- | FrontEnd/src/views/common/button/FlatButton.css | 48 | ||||
-rw-r--r-- | FrontEnd/src/views/common/button/FlatButton.tsx | 41 | ||||
-rw-r--r-- | FrontEnd/src/views/common/button/TextButton.css | 36 | ||||
-rw-r--r-- | FrontEnd/src/views/common/button/TextButton.tsx | 41 |
4 files changed, 166 insertions, 0 deletions
diff --git a/FrontEnd/src/views/common/button/FlatButton.css b/FrontEnd/src/views/common/button/FlatButton.css new file mode 100644 index 00000000..522563b9 --- /dev/null +++ b/FrontEnd/src/views/common/button/FlatButton.css @@ -0,0 +1,48 @@ +.cru-flat-button {
+ cursor: pointer;
+ padding: 0.2em 0.5em;
+ border-radius: 0.2em;
+ border: none;
+ background-color: transparent;
+ transition: all 0.6s;
+}
+
+.cru-flat-button:hover:not(.disabled) {
+ background-color: #e9ecef;
+}
+
+.cru-flat-button.disabled {
+ cursor: default;
+}
+
+.cru-flat-button.primary {
+ color: var(--tl-primary-color);
+}
+
+.cru-flat-button.primary.disabled {
+ color: var(--tl-primary-lighter-color);
+}
+
+.cru-flat-button.secondary {
+ color: var(--tl-secondary-color);
+}
+
+.cru-flat-button.secondary.disabled {
+ color: var(--tl-secondary-lighter-color);
+}
+
+.cru-flat-button.success {
+ color: var(--tl-success-color);
+}
+
+.cru-flat-button.success.disabled {
+ color: var(--tl-success-lighter-color);
+}
+
+.cru-flat-button.danger {
+ color: var(--tl-danger-color);
+}
+
+.cru-flat-button.danger.disabled {
+ color: var(--tl-danger-ligher-color);
+}
diff --git a/FrontEnd/src/views/common/button/FlatButton.tsx b/FrontEnd/src/views/common/button/FlatButton.tsx new file mode 100644 index 00000000..6351971a --- /dev/null +++ b/FrontEnd/src/views/common/button/FlatButton.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import { useTranslation } from "react-i18next"; +import classNames from "classnames"; + +import { convertI18nText, I18nText } from "@/common"; +import { PaletteColorType } from "@/palette"; + +import "./FlatButton.css"; + +function _FlatButton( + { + text, + color, + onClick, + className, + style, + }: { + text: I18nText; + color?: PaletteColorType; + onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void; + className?: string; + style?: React.CSSProperties; + }, + ref: React.ForwardedRef<HTMLButtonElement> +): React.ReactElement | null { + const { t } = useTranslation(); + + return ( + <button + ref={ref} + className={classNames("cru-flat-button", color ?? "primary", className)} + onClick={onClick} + style={style} + > + {convertI18nText(text, t)} + </button> + ); +} + +const FlatButton = React.forwardRef(_FlatButton); +export default FlatButton; diff --git a/FrontEnd/src/views/common/button/TextButton.css b/FrontEnd/src/views/common/button/TextButton.css new file mode 100644 index 00000000..dc5abaaa --- /dev/null +++ b/FrontEnd/src/views/common/button/TextButton.css @@ -0,0 +1,36 @@ +.cru-text-button {
+ background: transparent;
+ border: none;
+}
+
+.cru-text-button.primary {
+ color: var(--tl-primary-color);
+}
+
+.cru-text-button.primary:hover {
+ color: var(--tl-primary-lighter-color);
+}
+
+.cru-text-button.secondary {
+ color: var(--tl-secondary-color);
+}
+
+.cru-text-button.secondary:hover {
+ color: var(--tl-secondary-lighter-color);
+}
+
+.cru-text-button.success {
+ color: var(--tl-success-color);
+}
+
+.cru-text-button.success:hover {
+ color: var(--tl-success-lighter-color);
+}
+
+.cru-text-button.danger {
+ color: var(--tl-danger-color);
+}
+
+.cru-text-button.danger:hover {
+ color: var(--tl-danger-lighter-color);
+}
diff --git a/FrontEnd/src/views/common/button/TextButton.tsx b/FrontEnd/src/views/common/button/TextButton.tsx new file mode 100644 index 00000000..1a2bac94 --- /dev/null +++ b/FrontEnd/src/views/common/button/TextButton.tsx @@ -0,0 +1,41 @@ +import React from "react"; +import { useTranslation } from "react-i18next"; +import classNames from "classnames"; + +import { convertI18nText, I18nText } from "@/common"; +import { PaletteColorType } from "@/palette"; + +import "./TextButton.css"; + +function _TextButton( + { + text, + color, + onClick, + className, + style, + }: { + text: I18nText; + color?: PaletteColorType; + onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void; + className?: string; + style?: React.CSSProperties; + }, + ref: React.ForwardedRef<HTMLButtonElement> +): React.ReactElement | null { + const { t } = useTranslation(); + + return ( + <button + ref={ref} + className={classNames("cru-text-button", color ?? "primary", className)} + onClick={onClick} + style={style} + > + {convertI18nText(text, t)} + </button> + ); +} + +const TextButton = React.forwardRef(_TextButton); +export default TextButton; |