gab-social/app/javascript/gabsocial/components/icon_with_badge.js

23 lines
563 B
JavaScript
Raw Normal View History

2019-07-02 08:10:25 +01:00
import React from 'react';
import PropTypes from 'prop-types';
import Icon from 'gabsocial/components/icon';
import { shortNumberFormat } from 'gabsocial/utils/numbers';
2019-07-02 08:10:25 +01:00
const IconWithBadge = ({ id, count, className }) => {
if (count < 1) return null;
2019-07-02 08:10:25 +01:00
return (
<i className='icon-with-badge'>
{count > 0 && <i className='icon-with-badge__badge'>{shortNumberFormat(count)}</i>}
</i>
)
};
2019-07-02 08:10:25 +01:00
IconWithBadge.propTypes = {
id: PropTypes.string.isRequired,
count: PropTypes.number.isRequired,
className: PropTypes.string,
};
export default IconWithBadge;