import * as React from 'react'; import { Slot } from '@radix-ui/react-slot'; import { cva, type VariantProps } from 'class-variance-authority'; import { cn } from '@/lib/classMerge'; import { CircleSpinnerLoader } from '../loaders/CircleSpinnerLoader'; const buttonVariants = cva( 'inline-flex items-center justify-center gap-1.5 shadow-btn rounded transition-all duration-200 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none cursor-pointer disabled:cursor-not-allowed data-[loading=true]:cursor-progress px-2.5 py-1.5', { variants: { buttonType: { default: 'bg-white border hover:bg-item-hover disabled:bg-disabled disabled:text-light-gray active:bg-item-active data-[selected=true]:bg-nav-background', black: 'bg-black text-white hover:bg-black-hover disabled:bg-black-hover', primary: 'bg-primary text-white hover:bg-primary-light active:bg-primary-dark data-[selected=true]:bg-primary-dark', ghost: 'bg-transparent text-dark-gray shadow-none hover:bg-item-hover disabled:bg-transparent disabled:text-light-gray active:bg-item-active data-[selected=true]:bg-nav-background' }, size: { default: 'h-6', tall: 'h-7' } }, defaultVariants: { buttonType: 'default', size: 'default' } } ); export interface ButtonProps extends Omit, 'prefix'>, VariantProps { asChild?: boolean; prefix?: React.ReactNode; suffix?: React.ReactNode; loading?: boolean; selected?: boolean; } const AppButton = React.forwardRef( ( { className = '', buttonType = 'default', size = 'default', asChild = false, prefix, suffix, children, loading = false, selected = false, disabled = false, ...props }, ref ) => { const Comp = asChild ? Slot : 'button'; return ( {loading ? : prefix && {prefix}} {children} {suffix && {suffix}} ); } ); AppButton.displayName = 'AppButton'; const LoadingIcon: React.FC<{ buttonType: 'default' | 'black' | 'primary' | 'ghost' | null; }> = ({ buttonType = 'default' }) => { return (
); }; export { AppButton, buttonVariants };