From d0a0af51306bf5e5b46fd8982c70b271212af42f Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 29 Oct 2018 18:37:23 -0700 Subject: feat: add 'Select Token' UI to asset amount input --- .../src/components/erc20_asset_amount_input.tsx | 69 ++++++++++++++++++---- 1 file changed, 57 insertions(+), 12 deletions(-) (limited to 'packages/instant/src/components/erc20_asset_amount_input.tsx') diff --git a/packages/instant/src/components/erc20_asset_amount_input.tsx b/packages/instant/src/components/erc20_asset_amount_input.tsx index 5abb34c2f..4108fd0e8 100644 --- a/packages/instant/src/components/erc20_asset_amount_input.tsx +++ b/packages/instant/src/components/erc20_asset_amount_input.tsx @@ -8,13 +8,14 @@ import { BigNumberInput } from '../util/big_number_input'; import { util } from '../util/util'; import { ScalingAmountInput } from './scaling_amount_input'; -import { Container, Text } from './ui'; +import { Container, Flex, Icon, Text } from './ui'; // Asset amounts only apply to ERC20 assets export interface ERC20AssetAmountInputProps { asset?: ERC20Asset; value?: BigNumberInput; onChange: (value?: BigNumberInput, asset?: ERC20Asset) => void; + onSymbolClick: (asset?: ERC20Asset) => void; startingFontSizePx: number; fontColor?: ColorOption; isDisabled: boolean; @@ -27,6 +28,7 @@ export interface ERC20AssetAmountInputState { export class ERC20AssetAmountInput extends React.Component { public static defaultProps = { onChange: util.boundNoop, + onSymbolClick: util.boundNoop, isDisabled: false, }; constructor(props: ERC20AssetAmountInputProps) { @@ -36,10 +38,18 @@ export class ERC20AssetAmountInput extends React.Component + {!_.isUndefined(asset) ? this._renderContentForAsset(asset) : this._renderBackupContent()} + + ); + } + private readonly _renderContentForAsset = (asset: ERC20Asset): React.ReactNode => { + const { onChange, ...rest } = this.props; + const amountBorderBottom = this.props.isDisabled ? '' : `1px solid ${transparentWhite}`; + return ( + - - - {assetUtils.formattedSymbolForAsset(asset)} - + + + + {assetUtils.formattedSymbolForAsset(asset)} + + {this._renderChevronIcon()} + + + ); + }; + private readonly _renderBackupContent = (): React.ReactNode => { + return ( + + + Select Token + + {this._renderChevronIcon()} + + ); + }; + private readonly _renderChevronIcon = (): React.ReactNode => { + return ( + + ); - } + }; private readonly _handleChange = (value?: BigNumberInput): void => { this.props.onChange(value, this.props.asset); }; @@ -69,6 +111,9 @@ export class ERC20AssetAmountInput extends React.Component { + this.props.onSymbolClick(this.props.asset); + }; // For assets with symbols of different length, // start scaling the input at different character lengths private readonly _textLengthThresholdForAsset = (asset?: ERC20Asset): number => { -- cgit v1.2.3