48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import * as React from 'react';
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
import { cn } from '../../lib/utils';
|
|
|
|
const buttonVariants = cva(
|
|
'inline-flex items-center justify-center gap-2 rounded-[10px] font-bold whitespace-nowrap cursor-pointer transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-50 active:scale-[.985] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-bg',
|
|
{
|
|
variants: {
|
|
variant: {
|
|
primary: 'bg-(image:--btn-grad) text-accent-ink shadow-(--btn-shadow) hover:brightness-105',
|
|
secondary:
|
|
'bg-card/60 text-ink border border-line shadow-card hover:border-accent/55 hover:text-accent-text',
|
|
danger: 'bg-transparent text-danger border border-danger/45 hover:bg-danger/10',
|
|
ghost: 'bg-transparent text-dim hover:text-ink hover:bg-line/30',
|
|
},
|
|
size: {
|
|
md: 'h-10 px-[18px] text-[0.875rem]',
|
|
sm: 'h-8 px-3 text-[0.8125rem]',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'primary',
|
|
size: 'md',
|
|
},
|
|
},
|
|
);
|
|
|
|
export interface ButtonProps
|
|
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
Omit<VariantProps<typeof buttonVariants>, 'size'> {
|
|
size?: 'md' | 'sm';
|
|
}
|
|
|
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
({ className, variant, size, type = 'button', ...props }, ref) => (
|
|
<button
|
|
type={type}
|
|
data-slot="button"
|
|
className={cn(buttonVariants({ variant, size }), className)}
|
|
ref={ref}
|
|
{...props}
|
|
/>
|
|
),
|
|
);
|
|
Button.displayName = 'Button';
|
|
|
|
export { Button, buttonVariants };
|