import React from 'react';
import classNames from 'classnames';
import './FontIcon.less';

export default function FontIcon({ icon, title = '', disabled = false, size, anime = false, className = '', style, onClick } : {
  icon: string;
  title?: string;
  disabled?: boolean;
  size?: number;
  anime?: boolean;
  className?: string;
  style?: any;
  onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
}) {
  let _style = style || {};
  if (size) {
    _style = { ..._style, fontSize: size };
  }
  return (
    <i
      title={title}
      className={classNames('icon iconfont ' + icon, {
        'iconfont--disabled': disabled,
        'iconfont-active': !disabled && anime,
        [className]: true
      })}
      style={_style}
      onClick={onClick}
    />
  );
}
