diff --git a/app/javascript/gabsocial/components/icon_with_badge.js b/app/javascript/gabsocial/components/icon_with_badge.js index aa87f425..c42b9337 100644 --- a/app/javascript/gabsocial/components/icon_with_badge.js +++ b/app/javascript/gabsocial/components/icon_with_badge.js @@ -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 }) => ( - - {count > 0 && {formatNumber(count)}} - -); + return ( + + {count > 0 && {shortNumberFormat(count)}} + + ) +}; IconWithBadge.propTypes = { id: PropTypes.string.isRequired, @@ -16,4 +19,4 @@ IconWithBadge.propTypes = { className: PropTypes.string, }; -export default IconWithBadge; \ No newline at end of file +export default IconWithBadge;