Spaces:
Runtime error
Runtime error
Upload components/TmaButton.tsx with huggingface_hub
Browse files- components/TmaButton.tsx +34 -0
components/TmaButton.tsx
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
|
| 3 |
+
interface TmaButtonProps {
|
| 4 |
+
text: string;
|
| 5 |
+
onClick?: () => void;
|
| 6 |
+
className?: string;
|
| 7 |
+
disabled?: boolean;
|
| 8 |
+
loading?: boolean;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
export default function TmaButton({ text, onClick, className = '', disabled = false, loading = false }: TmaButtonProps) {
|
| 12 |
+
const baseStyles = 'w-full py-3 px-4 rounded-lg font-medium transition-all duration-200 flex items-center justify-center gap-2';
|
| 13 |
+
const disabledStyles = 'opacity-50 cursor-not-allowed bg-gray-300 text-gray-600';
|
| 14 |
+
const primaryStyles = 'bg-tg-secondary text-white shadow-md hover:bg-blue-600 active:scale-95';
|
| 15 |
+
|
| 16 |
+
const finalClassName = `${baseStyles} ${disabled ? disabledStyles : primaryStyles} ${className}`;
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<button
|
| 20 |
+
onClick={onClick}
|
| 21 |
+
disabled={disabled || loading}
|
| 22 |
+
className={finalClassName}
|
| 23 |
+
>
|
| 24 |
+
{loading ? (
|
| 25 |
+
<svg className="animate-spin h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
| 26 |
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
| 27 |
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
| 28 |
+
</svg>
|
| 29 |
+
) : (
|
| 30 |
+
text
|
| 31 |
+
)}
|
| 32 |
+
</button>
|
| 33 |
+
);
|
| 34 |
+
}
|