Skip to content

Commit

Permalink
format chart negative price string
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz committed Apr 26, 2019
1 parent 386ec12 commit 4b4170e
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ const Wrapper = styled.div`
}
`

const buildPriceDisplay = (currency, priceChange, pricePercentageChange) => {
let priceFormatted
if (priceChange < 0) {
priceFormatted = `-${Exchange.getSymbol(currency)}${Currency.formatFiat(
priceChange
).substring(1)}`
} else {
priceFormatted =
Exchange.getSymbol(currency) + Currency.formatFiat(priceChange)
}
return `${priceFormatted} (${Currency.formatFiat(pricePercentageChange)}%)`
}

const Success = ({
currency,
priceChartTime,
Expand All @@ -23,8 +36,7 @@ const Success = ({
return (
<Wrapper>
<Text size='12px' color={priceChange >= 0 ? 'success' : 'sent'}>
{Exchange.getSymbol(currency) + Currency.formatFiat(priceChange)} (
{Currency.formatFiat(pricePercentageChange)}%)
{buildPriceDisplay(currency, priceChange, pricePercentageChange)}
</Text>
<Text size='12px' color='lightblue-gray'>
{getPriceChartTime(priceChartTime)}
Expand Down

0 comments on commit 4b4170e

Please sign in to comment.