You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
564 B

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import Icon from 'mastodon/components/icon';
  4. const formatNumber = num => num > 40 ? '40+' : num;
  5. const IconWithBadge = ({ id, count, className }) => (
  6. <i className='icon-with-badge'>
  7. <Icon id={id} fixedWidth className={className} />
  8. {count > 0 && <i className='icon-with-badge__badge'>{formatNumber(count)}</i>}
  9. </i>
  10. );
  11. IconWithBadge.propTypes = {
  12. id: PropTypes.string.isRequired,
  13. count: PropTypes.number.isRequired,
  14. className: PropTypes.string,
  15. };
  16. export default IconWithBadge;