2017-07-13 21:02:39 +00:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2017-08-08 03:45:08 +00:00
|
|
|
import Big from 'bignumber.js';
|
2017-07-13 21:02:39 +00:00
|
|
|
import { formatNumber } from 'utils/formatters';
|
2017-07-14 17:04:08 +00:00
|
|
|
import removeIcon from 'assets/images/icon-remove.svg';
|
2017-07-13 21:02:39 +00:00
|
|
|
|
|
|
|
export default class TokenRow extends React.Component {
|
|
|
|
props: {
|
|
|
|
balance: Big,
|
|
|
|
symbol: string,
|
|
|
|
custom?: boolean,
|
|
|
|
onRemove: (symbol: string) => void
|
|
|
|
};
|
|
|
|
|
|
|
|
state = {
|
|
|
|
showLongBalance: false
|
|
|
|
};
|
|
|
|
render() {
|
|
|
|
const { balance, symbol, custom } = this.props;
|
2017-07-14 17:04:08 +00:00
|
|
|
const { showLongBalance } = this.state;
|
2017-07-13 21:02:39 +00:00
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td
|
|
|
|
className="mono wrap point"
|
|
|
|
title={`${balance.toString()} (Double-Click)`}
|
|
|
|
onDoubleClick={this.toggleShowLongBalance}
|
|
|
|
>
|
|
|
|
{!!custom &&
|
|
|
|
<img
|
2017-07-14 17:04:08 +00:00
|
|
|
src={removeIcon}
|
2017-07-13 21:02:39 +00:00
|
|
|
className="token-remove"
|
|
|
|
title="Remove Token"
|
|
|
|
onClick={this.onRemove}
|
|
|
|
/>}
|
|
|
|
<span>
|
2017-07-14 17:04:08 +00:00
|
|
|
{showLongBalance ? balance.toString() : formatNumber(balance)}
|
2017-07-13 21:02:39 +00:00
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{symbol}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleShowLongBalance = (e: SyntheticInputEvent) => {
|
|
|
|
e.preventDefault();
|
|
|
|
this.setState(state => {
|
|
|
|
return {
|
|
|
|
showLongBalance: !state.showLongBalance
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
onRemove = () => {
|
|
|
|
this.props.onRemove(this.props.symbol);
|
|
|
|
};
|
|
|
|
}
|