format reaction count to include commas
This commit is contained in:
parent
c1bd9ad6af
commit
6d4a92ad27
2 changed files with 8 additions and 2 deletions
|
@ -3,6 +3,7 @@ import * as ICONS from 'constants/icons';
|
|||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import Button from 'component/button';
|
||||
import { formatNumberWithCommas } from 'util/number';
|
||||
|
||||
type Props = {
|
||||
claim: StreamClaim,
|
||||
|
@ -31,7 +32,7 @@ function FileReactions(props: Props) {
|
|||
title={__('I like this')}
|
||||
requiresAuth
|
||||
className={classnames('button--file-action')}
|
||||
label={String(likeCount)}
|
||||
label={formatNumberWithCommas(likeCount)}
|
||||
iconSize={18}
|
||||
icon={ICONS.UPVOTE}
|
||||
onClick={() => doReactionLike(uri)}
|
||||
|
@ -40,7 +41,7 @@ function FileReactions(props: Props) {
|
|||
requiresAuth
|
||||
title={__('I dislike this')}
|
||||
className={classnames('button--file-action')}
|
||||
label={String(dislikeCount)}
|
||||
label={formatNumberWithCommas(dislikeCount)}
|
||||
iconSize={18}
|
||||
icon={ICONS.DOWNVOTE}
|
||||
onClick={() => doReactionDislike(uri)}
|
||||
|
|
5
ui/util/number.js
Normal file
5
ui/util/number.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
// @flow
|
||||
|
||||
export function formatNumberWithCommas(num: number): string {
|
||||
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
}
|
Loading…
Reference in a new issue