import React, { forwardRef } from 'react'; import { cn } from '../../utils/cn'; import { LoadingType } from '../../types'; export type ButtonVariant = 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' | 'primary'; export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; export type ButtonLoadingType = LoadingType; export interface ButtonProps extends React.ButtonHTMLAttributes { /** * The visual style of the button * @default 'default' */ variant?: ButtonVariant; /** * The size of the button * @default 'md' */ size?: ButtonSize; /** * Whether the button is in a loading state * @default false */ isLoading?: boolean; /** * The type of loading animation to display * @default 'spinner' */ loadingType?: ButtonLoadingType; /** * Text to display when loading */ loadingText?: string; /** * Icon to display at the start of the button */ startIcon?: React.ReactNode; /** * Icon to display at the end of the button */ endIcon?: React.ReactNode; /** * Make the button take the full width of its container * @default false */ fullWidth?: boolean; /** * Add elevation effect to the button * @default false */ elevated?: boolean; /** * Custom CSS class name */ className?: string; /** * Content of the button */ children: React.ReactNode; } const Button = forwardRef( ( { children, variant = 'default', size = 'md', isLoading = false, loadingType = 'spinner', loadingText, startIcon, endIcon, fullWidth = false, elevated = false, disabled, className, ...props }, ref ) => { // Render the correct loading indicator based on loadingType const renderLoadingIndicator = () => { switch (loadingType) { case 'dots': return ( ); case 'wave': return ( ); case 'pulse': return ; case 'circle': return ; case 'progress': // case 'slide': case 'spinner': default: return ; } }; return ( ); } ); Button.displayName = 'Button'; export default Button;