aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/common/button/TextButton.tsx
blob: 1a2bac9479c3b1c9f28f42af8172f0715fdc83e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;