This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathButton.tsx
More file actions
51 lines (48 loc) · 1.26 KB
/
Button.tsx
File metadata and controls
51 lines (48 loc) · 1.26 KB
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
46
47
48
49
50
51
import { ButtonHTMLAttributes } from 'react';
const styles: Record<string, { default: string, active: string, selected?: string }> = {
dangerous: {
default: 'bg-circle-red-dangerous text-white',
active: 'hover:bg-circle-red-dangerous-dark',
},
secondary: {
default: 'bg-circle-gray-250',
active: 'hover:bg-circle-gray-300',
selected: 'bg-circle-gray-400'
},
flat: {
default: 'text-circle-gray-400',
active: 'hover:bg-circle-gray-300 text-white',
},
primary: {
default: 'bg-circle-blue text-white',
active: 'hover:bg-circle-blue-dark',
},
};
export type ButtonVariant = keyof typeof styles;
export const Button = ({
variant,
className,
margin,
selected,
...props
}: ButtonHTMLAttributes<HTMLButtonElement> & {
variant: ButtonVariant;
margin?: string;
selected?: boolean;
}) => {
return (
<button
{...props}
className={`${
margin ? `mx-${margin}` : 'mx-3'
} whitespace-nowrap text-sm font-medium py-2 px-4 duration:50 transition-colors rounded-md2 ${
styles[variant].default
}
${className}
${props.disabled ? 'opacity-50 cursor-default' : styles[variant].active}
${selected && styles[variant].selected}`}
>
{props.children}
</button>
);
};