import React from 'react';
import { clsx } from 'clsx';

import { forwardRef } from '../utils/react';
import { Box } from '../box';
import * as css from './icon.css';

export interface IconProps extends css.IconVariants {}

export const Icon = forwardRef<'span', IconProps>(function Icon(
  { as = 'span', className, children, size, ...rest },
  ref,
) {
  const cn = clsx(className, css.icon({ size }));

  return (
    <Box ref={ref} as={as} className={cn} {...rest}>
      {children}
    </Box>
  );
});
