/*! Strand UI | MIT License | dillingerstaffing.com */ import type { JSX } from "preact"; import { forwardRef } from "preact/compat"; import { cx } from "../../internal/index.js"; export interface ButtonProps extends Omit, "size" | "loading" | "type" | "ref"> { variant?: "primary" | "secondary" | "ghost" | "danger"; size?: "sm" | "md" | "lg"; /** Shows the spinner and disables interaction. */ loading?: boolean; /** Square, for an icon with an `aria-label`. */ iconOnly?: boolean; type?: "button" | "submit" | "reset"; disabled?: boolean; /** Stretch to the container width. */ fullWidth?: boolean; /** Render an anchor styled as a button; inferred when `href` is set. */ as?: "button" | "a"; href?: string; } /** * Primary action trigger. * * @example * */ export const Button = forwardRef( ( { variant = "primary", size = "md", loading = false, iconOnly = false, fullWidth = false, disabled = false, className = "", children, onClick, type = "button", as, href, ...rest }, ref, ) => { const isDisabled = disabled || loading; const classes = cx( "strand-btn", `strand-btn--${variant}`, `strand-btn--${size}`, iconOnly && "strand-btn--icon-only", fullWidth && "strand-btn--full-width", loading && "strand-btn--loading", className, ); const inner = ( <> {loading &&