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

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

import "./Button.css";

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

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

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

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

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