This repository has been archived by the owner on May 7, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added upvote percentage to the popup for votes made
The upvote percentage can be viewed when hovering over the vote count and seeing the voters and their vote reward value.
- Loading branch information
Showing
6 changed files
with
48 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* Formats a number to a percentage with 2 decimal places. | ||
* | ||
* @param {number} value Number to be formatted | ||
* @return {element} Span element containing formatted value | ||
*/ | ||
const PercentDisplay = ({ value }) => { | ||
const formatter = new Intl.NumberFormat('en-US', { | ||
style: 'percent', | ||
minimumFractionDigits: 2 | ||
}) | ||
return ( | ||
<span>{formatter.format(value)}</span> | ||
) | ||
} | ||
|
||
PercentDisplay.propTypes = { | ||
value: PropTypes.number, | ||
}; | ||
|
||
PercentDisplay.defaultProps = { | ||
value: 0, | ||
}; | ||
|
||
export default PercentDisplay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters