import { ReactNode } from 'react'; import { type VariantProps } from 'tailwind-variants'; import { ResponsiveVariants } from '../../types/responsive-variants.types.js'; import { IconProps } from '../icon/index.js'; import { styles } from './button.styles.js'; type Variants = VariantProps; export type BaseButtonProps = { /** * Fit button width to its parent width. * @default false */ block?: ResponsiveVariants; /** * Badge body content */ children?: ReactNode; /** * Places an icon within the button, after the button’s text */ iconAfter?: (props: IconProps) => JSX.Element; /** * Places an icon within the button, before the button’s text */ iconBefore?: (props: IconProps) => JSX.Element; /** * The color for the icon. * * Defaults to the current text color. */ iconColor?: IconProps['color']; /** * The look of the icon * @default filled */ iconLook?: IconProps['look']; /** * The size of the icon * * Defaults to system size depending on size of the button */ iconSize?: IconProps['size']; /** * When true, children will use flex justify-between * @default false */ justify?: ResponsiveVariants; /** * Button look * @default hero */ look?: ResponsiveVariants; /** * Removes horizontal padding from the 'link' look button * @default false */ removeLinkPadding?: boolean; /** * Size of the button * @default medium */ size?: ResponsiveVariants; /** * Removes background colour and adjusts text colour. */ soft?: ResponsiveVariants; }; export type ButtonRef = React.ComponentRef; export type PolymorphicRef = React.ComponentPropsWithRef['ref']; export type ButtonProps = BaseButtonProps & { /** * Type to render * @default button */ tag?: C; } & Omit, keyof BaseButtonProps | 'tag'>; export type ButtonImplementationProps = BaseButtonProps & { className?: string; tag?: React.ElementType; } & Record; export type ButtonComponent = ( props: ButtonProps & { ref?: PolymorphicRef }, ) => React.ReactElement | null;