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.

24 lines
717 B

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { connect } from 'react-redux';
  4. import Icon from 'mastodon/components/icon';
  5. const mapStateToProps = state => ({
  6. count: state.getIn(['notifications', 'unread']),
  7. });
  8. const formatNumber = num => num > 99 ? '99+' : num;
  9. const NotificationsCounterIcon = ({ count, className }) => (
  10. <i className='icon-with-badge'>
  11. <Icon id='bell' fixedWidth className={className} />
  12. {count > 0 && <i className='icon-with-badge__badge'>{formatNumber(count)}</i>}
  13. </i>
  14. );
  15. NotificationsCounterIcon.propTypes = {
  16. count: PropTypes.number.isRequired,
  17. className: PropTypes.string,
  18. };
  19. export default connect(mapStateToProps)(NotificationsCounterIcon);