File size: 1,286 Bytes
cf8b7da
6233641
cf8b7da
 
 
8202034
6233641
 
cf8b7da
 
 
8202034
cf8b7da
6233641
cf8b7da
 
 
 
 
7dc9f9f
cf8b7da
 
 
6233641
 
8202034
 
cf8b7da
 
 
6233641
 
 
 
 
 
 
 
 
cf8b7da
 
 
 
 
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
42
43
44
45
import classNames from "classnames";
import { MouseEvent } from "react";

interface Props {
  children: React.ReactNode;
  disabled?: boolean;
  theme?: "primary" | "secondary" | "white" | "danger" | "success";
  onClick?: (e: MouseEvent<HTMLButtonElement>) => void;
}
export const Button: React.FC<Props> = ({
  children,
  disabled,
  theme = "primary",
  onClick,
  ...props
}) => {
  return (
    <button
      className={classNames(
        "rounded-full px-4 py-1.5 lg:px-6 lg:py-2.5 text-sm lg:text-base font-semibold flex items-center justify-center gap-2.5 border-[2px] transition-all duration-200 max-w-max",
        {
          "bg-primary text-white border-primary": theme === "primary",
          "bg-white text-gray-900 border-white": theme === "white",
          "bg-red-500 text-white border-red-500": theme === "danger",
          "bg-green-500 text-white border-green-500": theme === "success",
          "!bg-gray-400 !text-gray-600 !cursor-not-allowed !border-gray-400":
            disabled,
        }
      )}
      {...props}
      onClick={
        onClick
          ? (e) => {
              e.stopPropagation();
              e.preventDefault();
              onClick(e);
            }
          : undefined
      }
    >
      {children}
    </button>
  );
};