forked from github/copilot-cli-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.jsx
More file actions
55 lines (49 loc) · 1.24 KB
/
Copy pathButton.jsx
File metadata and controls
55 lines (49 loc) · 1.24 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
52
53
54
55
/**
* Reusable Button component
*/
import React from 'react';
function Button({
children,
onClick,
variant = 'primary',
size = 'medium',
disabled = false,
loading = false,
type = 'button'
}) {
const baseStyles = 'font-medium rounded-lg transition-colors focus:outline-none focus:ring-2';
const variants = {
primary: 'bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500',
secondary: 'bg-gray-200 text-gray-800 hover:bg-gray-300 focus:ring-gray-500',
danger: 'bg-red-600 text-white hover:bg-red-700 focus:ring-red-500'
};
const sizes = {
small: 'px-3 py-1.5 text-sm',
medium: 'px-4 py-2 text-base',
large: 'px-6 py-3 text-lg'
};
const handleClick = (e) => {
if (!disabled && !loading && onClick) {
onClick(e);
}
};
return (
<button
type={type}
onClick={handleClick}
disabled={disabled || loading}
className={`${baseStyles} ${variants[variant]} ${sizes[size]} ${
disabled ? 'opacity-50 cursor-not-allowed' : ''
}`}
>
{loading ? (
<span className="flex items-center gap-2">
<span className="animate-spin">Loading...</span>
</span>
) : (
children
)}
</button>
);
}
export default Button;