import { ButtonHTMLAttributes, FunctionComponent, ReactNode, SVGProps, forwardRef } from 'react'; import cx from 'clsx'; import styles from './button.module.scss'; type BaseProps = ButtonHTMLAttributes & { text?: string; icon?: FunctionComponent & { title?: string | undefined }>; color?: 'primary' | 'dark' | 'light' | 'grey' | 'border' | 'transparent'; size?: 'default' | 'small'; isLoading?: boolean; block?: boolean; noWrap?: boolean; }; type TextProps = BaseProps & { text: string; children?: never; }; type IconProps = BaseProps & { icon: FunctionComponent & { title?: string | undefined }>; children?: never; }; type ChildrenProps = BaseProps & { children: ReactNode; text?: never; icon?: never; }; type Props = TextProps | IconProps | ChildrenProps; const Button = forwardRef((props, ref) => { const { className, text, icon: Icon, disabled, isLoading, type = 'button', color = 'primary', size = 'default', children, block, noWrap, ...attrs } = props; return ( ); }); export { Button }; export type { Props as ButtonProps };