Skip to content

Commit

Permalink
fix: Handle zero, one and many
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelastic committed Sep 4, 2015
1 parent 1bfd109 commit 5434ca2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/Stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Stats extends React.Component {
var template = this.props.template;
var data = {
nbHits: this.props.nbHits,
isPlural: this.props.nbHits > 1,
hasNoResults: this.props.nbHits === 0,
hasOneResult: this.props.nbHits === 1,
hasManyResults: this.props.nbHits > 1,
processingTimeMS: this.props.processingTimeMS
};

Expand Down
4 changes: 3 additions & 1 deletion widgets/stats/template.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<div>
{{nbHits}} {{#isPlural}}results{{/isPlural}}{{^isPlural}}result{{/isPlural}}
{{#hasNoResults}}No results{{/hasNoResults}}
{{#hasOneResult}}1 result{{/hasOneResult}}
{{#hasManyResults}}{{nbHits}} results{{/hasManyResults}}
<small>found in {{processingTimeMS}}ms</small>
</div>

1 comment on commit 5434ca2

@redox
Copy link
Contributor

@redox redox commented on 5434ca2 Sep 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.