闭社主体 forked from https://github.com/tootsuite/mastodon
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.

22 lines
673 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, issueBadge, 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. {issueBadge && <i className='icon-with-badge__issue-badge' />}
  10. </i>
  11. );
  12. IconWithBadge.propTypes = {
  13. id: PropTypes.string.isRequired,
  14. count: PropTypes.number.isRequired,
  15. issueBadge: PropTypes.bool,
  16. className: PropTypes.string,
  17. };
  18. export default IconWithBadge;