import type { ButtonHTMLAttributes, ReactNode } from 'react' import React, { forwardRef } from 'react' import { Loader } from '../../' export type Variant = 'primary' | 'secondary' | 'tertiary' export type Size = 'small' | 'regular' export type IconPosition = 'left' | 'right' export interface ButtonProps extends ButtonHTMLAttributes { /** * ID to find this component in testing tools (e.g.: cypress, testing library, and jest). */ testId?: string /** * Specifies the component color variant. */ variant?: Variant /** * Specifies the size variant. */ size?: Size /** * Defines the use of inverted colors. */ inverse?: boolean /** * Specifies that this button should be disabled. */ disabled?: boolean /** * A React component that will be rendered as an icon. */ icon?: ReactNode /** * Boolean that represents a loading state. */ loading?: boolean /** * Specifies a label for loading state. */ loadingLabel?: string /** * Specifies where the icon should be positioned */ iconPosition?: IconPosition } const Button = forwardRef(function Button( { children, variant, inverse, size = 'regular', testId = 'fs-button', loading, loadingLabel, icon, iconPosition = 'left', disabled, ...otherProps }, ref ) { return ( {loading && ( {loadingLabel} )} {!!icon && iconPosition === 'left' && ( {icon} )} {children && {children}} {!!icon && iconPosition === 'right' && ( {icon} )} ) }) export default Button
{loadingLabel}