import { forwardRef, type ComponentPropsWithoutRef } from 'react';
import { cx } from '../utils';
import type { BtnVariant } from '../button';

type IconButtonProps = ComponentPropsWithoutRef<'button'> & {
  variant?: BtnVariant;
  size?: 'sm' | 'lg';
};

export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
  ({ variant = 'key', size, className, ...props }, ref) => (
    <button
      ref={ref}
      className={cx(
        'mta-btn',
        'mta-iconbtn',
        variant !== 'key' && `mta-btn--${variant}`,
        size && `mta-iconbtn--${size}`,
        className,
      )}
      {...props}
    />
  ),
);
IconButton.displayName = 'IconButton';
