import PropTypes from 'prop-types';
import avatarImg from './头像@2x.png';
import styles from './index.less';

/**
 * 圆形用户头像，默认90x90px
 * @param {string} src 图片路径
 */
export default function Avatar({ src, className, ...rest }) {
  return (
    <img
      alt="avatar"
      src={src || avatarImg}
      className={styles.avatar + ' ' + className}
      {...rest}
      onError={e => (e.target.src = avatarImg)}
    />
  );
}

Avatar.propTypes = {
  src: PropTypes.string.isRequired,
};
