kreativortex/components/ActionButton/ActionButton.tsx
Jessica Rekcah 4253483f44 jalan
2025-12-02 00:22:34 +07:00

84 lines
2.8 KiB
TypeScript

/**
* File: ActionButton.tsx
* Created by: AI Assistant
* Date: 2025-11-29
* Purpose: ActionButton component for kreatiVortex platform
* Part of: kreatiVortex - Platform Pembelajaran Tari Online
*/
'use client';
import React from 'react';
import { cn } from '@/lib/utils';
interface ActionButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive';
size?: 'sm' | 'md' | 'lg';
loading?: boolean;
icon?: React.ReactNode;
children: React.ReactNode;
}
const ActionButton = React.forwardRef<HTMLButtonElement, ActionButtonProps>(
({ className, variant = 'primary', size = 'md', loading = false, icon, children, disabled, ...props }, ref) => {
const baseClasses = 'inline-flex items-center justify-center font-medium rounded-lg transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed';
const variants = {
primary: 'bg-gold-500 text-navy-900 hover:bg-gold-400 focus:ring-gold-400 shadow-lg hover:shadow-gold-400/25',
secondary: ' text-white hover:bg-navy-600 focus:ring-navy-500',
outline: 'border-2 border-gold-400 text-gold-400 hover:bg-gold-400 hover:text-navy-900 focus:ring-gold-400',
ghost: 'text-gray-300 hover:text-white hover:bg-white/10 focus:ring-white/20',
destructive: 'bg-red-600 text-white hover:bg-red-700 focus:ring-red-500',
};
const sizes = {
sm: 'px-3 py-1.5 text-sm',
md: 'px-4 py-2 text-sm',
lg: 'px-6 py-3 text-base',
};
return (
<button
className={cn(
baseClasses,
variants[variant],
sizes[size],
className
)}
disabled={disabled || loading}
ref={ref}
{...props}
>
{loading && (
<svg
className="animate-spin -ml-1 mr-2 h-4 w-4"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<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 0112 20c5.514 0 10.241-2.636 11.317-7.319l.702-.707a1 1 0 00-1.414 1.414l-.707.707c-.878.879-2.262 1.414-3.817z"
/>
</svg>
)}
{!loading && icon && <span className="ml-2">{icon}</span>}
{!loading && icon && <span className="mr-2">{icon}</span>}
{children}
</button>
);
}
);
ActionButton.displayName = 'ActionButton';
export default ActionButton;