aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src/views/common/button/Button.tsx
blob: 1171064780a2360b6496bae22f4a0304196925a6 (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
import React from "react";
import { useTranslation } from "react-i18next";

import { calculateProps, CommonButtonProps } from "./common";

import "./Button.css";

function _Button(
  props: CommonButtonProps & { customButtonClassName?: string },
  ref: React.ForwardedRef<HTMLButtonElement>
): React.ReactElement | null {
  const { t } = useTranslation();

  const { customButtonClassName, ...otherProps } = props;

  const { newProps, children } = calculateProps(
    otherProps,
    customButtonClassName ?? "cru-button",
    t
  );

  return (
    <button ref={ref} {...newProps}>
      {children}
    </button>
  );
}

const Button = React.forwardRef(_Button);
export default Button;