bigbuffet-rw/app/soapbox/components/icon_with_badge.js

22 lines
529 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
2020-05-28 15:52:07 -07:00
import { shortNumberFormat } from 'soapbox/utils/numbers';
2020-03-27 13:59:38 -07:00
const IconWithBadge = ({ id, count, className }) => {
2020-04-14 11:44:40 -07:00
if (count < 1) return null;
2020-03-27 13:59:38 -07:00
2020-04-14 11:44:40 -07:00
return (
<i className='icon-with-badge'>
{count > 0 && <i className='icon-with-badge__badge'>{shortNumberFormat(count)}</i>}
</i>
);
2020-03-27 13:59:38 -07:00
};
IconWithBadge.propTypes = {
2020-04-14 11:44:40 -07:00
id: PropTypes.string.isRequired,
count: PropTypes.number.isRequired,
className: PropTypes.string,
2020-03-27 13:59:38 -07:00
};
export default IconWithBadge;