Skip to content

Commit

Permalink
Merge pull request #1307 from COVID19Tracking/kevee/crdt-percentage-1305
Browse files Browse the repository at this point in the history
chore(crdt-dashboard): Fix less than zero percent display
  • Loading branch information
kevee authored Aug 3, 2020
2 parents 33dc9a3 + 5f409bb commit 110aa45
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ exports[`Components : Pages : Race : Dashboard : Ethnicity Table renders correct
<td
className="borderLeft"
>
0
&lt;1
%
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Array [
]
`;

exports[`Components : Race : Dashboard : Percent renders correctly 2`] = `""`;
exports[`Components : Race : Dashboard : Percent renders correctly 2`] = `"-"`;

exports[`Components : Race : Dashboard : Percent renders correctly 3`] = `
Array [
Expand All @@ -18,7 +18,7 @@ Array [

exports[`Components : Race : Dashboard : Percent renders correctly 4`] = `
Array [
"0",
"<1",
"%",
]
`;
30 changes: 15 additions & 15 deletions src/components/pages/race/dashboard/percent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import React from 'react'
import percentStyles from './percent.module.scss'

export default ({ number, highlight }) => {
if (number !== null) {
let percentage = '0'
if (Math.round(number * 100) > 0) {
percentage = number * 100 > 1 ? Math.round(number * 100) : '<1'
}
return (
<>
{highlight ? (
<span className={percentStyles.highlight}>{percentage}%</span>
) : (
<>{percentage}%</>
)}
</>
)
if (number === null) {
return <>-</>
}
return <></>
let percentage = '0'
if (number > 0) {
percentage = number * 100 > 1 ? Math.round(number * 100) : '<1'
}
return (
<>
{highlight ? (
<span className={percentStyles.highlight}>{percentage}%</span>
) : (
<>{percentage}%</>
)}
</>
)
}

0 comments on commit 110aa45

Please sign in to comment.