mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
|
|
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
variant?: 'primary' | 'outline' | 'ghost' | 'primary-ghost' | 'destructive';
|
|
size?: 'default' | 'sm' | 'lg';
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ variant = 'primary', size = 'default', children, className, ...props }, ref) => {
|
|
const baseClasses =
|
|
'inline-flex items-center justify-center rounded-md text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none transform hover:scale-102 active:scale-98';
|
|
|
|
const variantClasses = {
|
|
primary: 'bg-primary text-primary-foreground hover:bg-primary/90 shadow',
|
|
outline: 'border bg-background hover:bg-accent hover:text-accent-foreground',
|
|
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
'primary-ghost': 'border border-primary/40 bg-primary/10 text-primary hover:bg-primary/15',
|
|
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow',
|
|
};
|
|
|
|
const sizeClasses = {
|
|
default: 'h-10 py-2 px-4',
|
|
sm: 'h-9 px-3',
|
|
lg: 'h-12 rounded-lg px-6 text-base',
|
|
};
|
|
|
|
return (
|
|
<button
|
|
ref={ref}
|
|
className={`${baseClasses} ${variantClasses[variant]} ${sizeClasses[size]} ${className}`}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|
|
);
|
|
|
|
Button.displayName = 'Button';
|
|
|
|
export default Button;
|