William O'Beirne bf6a122e38 Night Mode Theme (#1896)
* Initial changes to define theme maps, color function, and convert all global styles.

* More global styles.

* All styles converted, colors uncertain.

* Fix tabs, temporary theme toggle button.

* Color refinements

* Color network selector, introduce shade function

* Make palette page

* Add theme button and minor styling to nav

* Blueify dark theme

* A bunch of color adjustments to work better with dark theme

* Fix tables

* Fix wallet decrypt colors

* More misc fixes

* Fix up electron colors

* Convert web theme to redux state / action

* Theme toggle in app, prevent rerenders

* Get rid of all variables, fix selects

* Fix conf modal, modal close styles

* Fix test

* Adjust swap colors

* Check in breaking out component, changing icons

* Check in progress

* Theme toggle in footer. New icons

* Prevent rerender on theme change

* Fix up outstanding merge conflicts

* Fix generate colors to be dark mode friendly

* Reduce swap color intensity

* Make disabled buttons darker in dark mode

* Reduce button size by 25%
2018-06-26 23:51:42 -05:00

96 lines
2.5 KiB
TypeScript

import React from 'react';
import { translateRaw } from 'translations';
import { TokenValue } from 'libs/units';
import removeIcon from 'assets/images/icon-remove.svg';
import { UnitDisplay } from 'components/ui';
import './TokenRow.scss';
type ToggleTrackedFn = (symbol: string) => void;
interface Props {
balance: TokenValue;
symbol: string;
custom?: boolean;
decimal: number;
tracked: boolean;
toggleTracked: ToggleTrackedFn | false;
onRemove(symbol: string): void;
}
interface State {
showLongBalance: boolean;
}
export default class TokenRow extends React.PureComponent<Props, State> {
public state = {
showLongBalance: false
};
public render() {
const { balance, symbol, custom, decimal, tracked } = this.props;
const { showLongBalance } = this.state;
return (
<tr className="TokenRow" onClick={this.handleToggleTracked}>
{/* Only allow to toggle tracking on non custom tokens
because the user can just remove the custom token instead */}
{this.props.toggleTracked && (
<td className="TokenRow-toggled">
<input
type="checkbox"
checked={tracked || this.props.custom}
disabled={this.props.custom}
/>
</td>
)}
<td
className="TokenRow-balance"
title={`${balance.toString()} (Double-Click)`}
onDoubleClick={this.toggleShowLongBalance}
>
<span>
<UnitDisplay
value={balance}
decimal={decimal}
displayShortBalance={!showLongBalance}
checkOffline={true}
/>
</span>
</td>
<td className="TokenRow-symbol">
{symbol}
{!!custom && (
<img
src={removeIcon}
alt={translateRaw('REMOVE')}
className="TokenRow-symbol-remove"
title={translateRaw('REMOVE_TOKEN')}
onClick={this.onRemove}
tabIndex={0}
/>
)}
</td>
</tr>
);
}
public toggleShowLongBalance = (e: React.FormEvent<HTMLTableDataCellElement>) => {
e.preventDefault();
this.setState(state => {
return {
showLongBalance: !state.showLongBalance
};
});
};
private onRemove = () => {
this.props.onRemove(this.props.symbol);
};
private handleToggleTracked = () => {
if (this.props.toggleTracked) {
this.props.toggleTracked(this.props.symbol);
}
};
}