import type { MouseEventHandler, ReactNode } from 'react' import type { PolymorphicComponentPropsWithRef, PolymorphicRef } from '../types' import classNames from 'classnames' import React from 'react' import { Loader } from '../loader' import { BUTTON_CLASSES, BUTTON_SIZES, BUTTON_STYLES, BUTTON_STYLES_VARIANT } from './styles' export type ButtonColor = 'red' | 'blue' | 'pink' | 'purple' | 'gradient' | 'gray' | 'green' export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'default' export type ButtonVariant = 'outlined' | 'filled' | 'empty' interface Props { children?: ReactNode startIcon?: ReactNode endIcon?: ReactNode color?: ButtonColor size?: ButtonSize variant?: ButtonVariant fullWidth?: boolean loading?: boolean href?: string onClick?: MouseEventHandler } export type ButtonProps = PolymorphicComponentPropsWithRef export type ButtonComponent = ( props: ButtonProps ) => React.ReactNode | null export const Button: ButtonComponent = React.forwardRef( ( { as, children, className, color = 'blue', size = 'default', variant = 'filled', startIcon = undefined, endIcon = undefined, fullWidth = false, loading, disabled, ...rest }: ButtonProps, ref?: PolymorphicRef, ) => { const Component = as || 'button' return ( { loading ? : ( <> {startIcon && startIcon} {children} {endIcon && endIcon} ) } ) }, ) export default Button