import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
import { cx } from '../utils';

type BadgeVariant = 'lime' | 'ember' | 'neutral' | 'outline';

export const Badge = ({
  variant = 'neutral',
  dot,
  className,
  children,
  ...props
}: ComponentPropsWithoutRef<'span'> & {
  variant?: BadgeVariant;
  dot?: boolean;
}) => (
  <span
    className={cx(
      'mta-badge',
      `mta-badge--${variant}`,
      dot && 'mta-badge--dot',
      className,
    )}
    {...props}
  >
    {children}
  </span>
);

export const Chip = ({
  children,
  onRemove,
}: {
  children: ReactNode;
  onRemove?: () => void;
}) => (
  <span className="mta-chip">
    {children}
    {onRemove && (
      <button type="button" className="x" onClick={onRemove} aria-label="Remove">
        ×
      </button>
    )}
  </span>
);
