Skip to content

Commit

Permalink
fix(fscomponents): Format review rating number output
Browse files Browse the repository at this point in the history
In the review summary, a numerical rating is shown. Previously, it just displayed the raw numbers
rather than applying any formatting (eg. 4.6254592 / 5). This adds formatting that restricts it to a
single decimal place (eg. 4.6 / 5).
  • Loading branch information
nathan-sankbeil authored and bweissbart committed Sep 6, 2018
1 parent 5ee6528 commit 837469b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/fscomponents/src/components/ReviewsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export class ReviewsSummary extends Component<ReviewsSummaryProps> {
reviewIndicatorRowStyle,
reviewIndicatorTitleText,
reviewIndicatorTitleTextStyle
} = this.props;
} = this.props;

const numberFormatting = { maximumFractionDigits: 1 };
const reviewIndicatorCopy = reviewIndicatorSubtitle ? reviewIndicatorSubtitle :
'based on ' + count + ' reviews';

Expand All @@ -58,7 +59,9 @@ export class ReviewsSummary extends Component<ReviewsSummaryProps> {
<Text style={reviewIndicatorTitleTextStyle}>{reviewIndicatorTitleText}</Text>
)}
<ReviewIndicator value={value} {...reviewIndicatorProps} />
<Text style={[S.averageStyle, averageStyle]}>{value} / {base}</Text>
<Text style={[S.averageStyle, averageStyle]}>
{FSI18n.number(value, numberFormatting)} / {FSI18n.number(base, numberFormatting)}
</Text>
</View>
{!hideReviewIndicatorSubtitle && (
<View style={[S.row, rowStyle]}>
Expand Down

0 comments on commit 837469b

Please sign in to comment.