-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathButton.tsx
More file actions
43 lines (37 loc) · 1.46 KB
/
Copy pathButton.tsx
File metadata and controls
43 lines (37 loc) · 1.46 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
import React, { ButtonHTMLAttributes } from 'react';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'danger';
isLoading?: boolean;
}
export const Button: React.FC<ButtonProps> = ({
children,
className = '',
variant = 'primary',
isLoading,
disabled,
style,
...props
}) => {
const baseStyles = "flex items-center justify-center gap-2 px-6 py-2.5 font-bold rounded-xl transition-all shadow-md active:scale-95 disabled:active:scale-100 disabled:cursor-not-allowed";
const variants = {
primary: "text-white disabled:bg-slate-300 dark:disabled:bg-slate-700",
secondary: "bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 hover:bg-slate-200 dark:hover:bg-slate-700",
danger: "bg-red-500 text-white hover:bg-red-600"
};
const primaryStyles = variant === 'primary' ? {
backgroundColor: 'var(--product-primary)',
boxShadow: '0 4px 12px var(--product-glow)',
} : {};
// Handle hover for primary via CSS or just keep it simple if we can't easily do hover in inline styles without a library
// Better yet, I can add a small CSS block in index.html for .btn-primary-product
return (
<button
className={`${baseStyles} ${variants[variant]} ${variant === 'primary' ? 'btn-product-primary' : ''} ${className}`}
style={{ ...primaryStyles, ...style }}
disabled={disabled || isLoading}
{...props}
>
{children}
</button>
);
};