/*
 * @Author: 赵伟
 * @Date: 2024-04-17 12:53:06
 * @Description: 封装 iconfont 组件
 */
import '@/iconfont/iconfont-menu.js';
import '@/iconfont/iconfont.js';
import { createFromIconfontCN } from '@ant-design/icons';

const Icon = createFromIconfontCN({
  scriptUrl: '',
});

type IconFontProps = Parameters<typeof Icon>[0];

interface KFIconProps extends IconFontProps {
  /** 图标 */
  type: string;
  /** 字体大小 */
  font?: number;
  /** 字体颜色 */
  color?: string;
  /** 自定义类名 */
  className?: string;
  /** 自定义样式 */
  style?: React.CSSProperties;
}

/** 封装 iconfont 图标 */
function KFIcon({ type, font = 15, color, className, style, ...rest }: KFIconProps) {
  const iconStyle = {
    ...style,
    fontSize: font,
    color,
  };
  return <Icon {...rest} type={type} className={className} style={iconStyle} />;
}

export default KFIcon;
