mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-24 20:21:53 +08:00
32 lines
964 B
TypeScript
32 lines
964 B
TypeScript
import { Slot } from '@radix-ui/react-slot';
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
import type { ButtonHTMLAttributes } from 'react';
|
|
import { cn } from '@/lib/cn';
|
|
|
|
const buttonVariants = cva('ui-button', {
|
|
variants: {
|
|
variant: {
|
|
primary: 'ui-button--primary',
|
|
secondary: 'ui-button--secondary',
|
|
ghost: 'ui-button--ghost',
|
|
danger: 'ui-button--danger',
|
|
},
|
|
size: {
|
|
sm: 'ui-button--sm',
|
|
md: 'ui-button--md',
|
|
icon: 'ui-button--icon',
|
|
},
|
|
},
|
|
defaultVariants: { variant: 'secondary', size: 'md' },
|
|
});
|
|
|
|
export interface ButtonProps
|
|
extends ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
asChild?: boolean;
|
|
}
|
|
|
|
export function Button({ className, variant, size, asChild, ...props }: ButtonProps) {
|
|
const Component = asChild ? Slot : 'button';
|
|
return <Component className={cn(buttonVariants({ variant, size }), className)} {...props} />;
|
|
}
|