parent
17af572ec9
commit
45754503ca
@ -1,14 +1,17 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Icon from 'gabsocial/components/icon';
|
||||
import { shortNumberFormat } from 'gabsocial/utils/numbers';
|
||||
|
||||
const formatNumber = num => num > 40 ? '40+' : num;
|
||||
const IconWithBadge = ({ id, count, className }) => {
|
||||
if (count < 1) return null;
|
||||
|
||||
const IconWithBadge = ({ id, count, className }) => (
|
||||
<i className='icon-with-badge'>
|
||||
{count > 0 && <i className='icon-with-badge__badge'>{formatNumber(count)}</i>}
|
||||
</i>
|
||||
);
|
||||
return (
|
||||
<i className='icon-with-badge'>
|
||||
{count > 0 && <i className='icon-with-badge__badge'>{shortNumberFormat(count)}</i>}
|
||||
</i>
|
||||
)
|
||||
};
|
||||
|
||||
IconWithBadge.propTypes = {
|
||||
id: PropTypes.string.isRequired,
|
||||
@ -16,4 +19,4 @@ IconWithBadge.propTypes = {
|
||||
className: PropTypes.string,
|
||||
};
|
||||
|
||||
export default IconWithBadge;
|
||||
export default IconWithBadge;
|
||||
|
Loading…
x
Reference in New Issue
Block a user