import { forwardRef } from 'react'; import { Button as WPButton, type ButtonProps as WPButtonProps } from '@wordpress/components'; import { LoaderCircle, type LucideIcon } from 'lucide-react'; import { cn } from '@/lib/utils'; export type ButtonVariant = 'primary' | 'outline' | 'secondary' | 'ghost' | 'danger' | 'danger-outline'; interface ButtonProps extends Omit { variant?: ButtonVariant; size?: 'default' | 'sm'; /** Shows a spinner and disables the button. */ loading?: boolean; /** Ripple behind the label while a request runs (keeps the label). */ pending?: boolean; icon?: LucideIcon; } /** * WordPress's Button (a link when given `href`), drawn with the app's own * button styles (components.css, .wtofe-btn) rather than WordPress's * variants, so it looks the same on every WordPress version. */ const Button = forwardRef( function Button( { variant = 'secondary', size = 'default', loading = false, pending = false, icon: Icon, className, disabled, type = 'button', children, ...props }, ref ) { return ( { loading && ); } ); export { Button };