gab-social/app/javascript/gabsocial/utils/numbers.js

15 lines
321 B
JavaScript
Raw Normal View History

2020-02-08 06:12:01 +00:00
import { Fragment } from 'react'
import { FormattedNumber } from 'react-intl'
2019-07-02 08:10:25 +01:00
export const shortNumberFormat = number => {
if (number < 1000) {
2020-02-08 06:12:01 +00:00
return <FormattedNumber value={number} />
2019-07-02 08:10:25 +01:00
}
2020-02-08 06:12:01 +00:00
return (
<Fragment>
<FormattedNumber value={number / 1000} maximumFractionDigits={1} />K
</Fragment>
)
}