}
}
- var formatVariation = (variation) => {
+ var formatVariation = (variation, isPercent) => {
var variationAbs = Math.abs(variation);
+ var suffix = '';
+ if (isPercent === true) {
+ suffix = '%';
+ }
+
if (variation === 0.0) {
- return <span>{variationAbs}%</span>;
+ return <span>{variationAbs}{suffix}</span>;
} else if (variation > 0) {
- return <span className="performance-up">+{variationAbs}%</span>;
+ return <span className="performance-up">+{variationAbs}{suffix}</span>;
}
- return <span className="performance-down">-{variationAbs}%</span>;
+ return <span className="performance-down">-{variationAbs}{suffix}</span>;
};
<div className="d-inline col-2">{this.props.quantity}</div>
<div className="d-inline col-2">{this.props.BTCValue}</div>
<div className="d-inline col-2">{this.props.weight}%</div>
- <div className="d-inline col-2">{formatVariation(this.props.positionPerformanceP)}</div>
+ <div className="d-inline col-2">{formatVariation(this.props.positionPerformanceP, true)}</div>
</div>
</React.Fragment>;
}
<em>since {date}</em>
</div>
<div className="col-4 variation text-center">
- <strong>{formatVariation(this.props.variationP)}</strong>
+ <strong>{formatVariation(this.props.variationP, true)}</strong>
</div>
</div>
</div>
return <React.Fragment>
<div className="balance">
<div className="col-12">
- <CurrencyLogo currency="BTC" /> <span><strong>{this.props.balance}</strong> <strong>{formatVariation(this.props.variationP)}</strong></span>
+ <CurrencyLogo currency="BTC" /> <span><strong>{this.props.balance}</strong> <strong>{formatVariation(this.props.variationP, this.props.isPercent)}</strong></span>
</div>
</div>
</React.Fragment>;