-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.tsx
38 lines (32 loc) · 970 Bytes
/
Button.tsx
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
import { forwardRef } from "react";
import classNames from "classnames";
// Styles
import s from "./Button.module.scss";
export type ButtonVariants = "solid" | "outline";
export type ButtonColors = "brand" | "surface";
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant: ButtonVariants;
color: ButtonColors;
small?: boolean;
square?: boolean;
leading?: React.ReactNode;
trailing?: React.ReactNode;
}
const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ variant, color, small, leading, trailing, className, children, ...props }, forwardedRef) => {
return (
<button
{...props}
type="button"
ref={forwardedRef}
className={classNames(s.button, small && s.small, s[variant], s[color], className)}
>
{leading && leading}
{children}
{trailing && trailing}
</button>
);
},
);
Button.displayName = "Button";
export default Button;