import { BigNumber } from '@0x/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input'; import { ColorOption } from '../style/theme'; import { AsyncProcessState } from '../types'; import { format } from '../util/format'; import { AmountPlaceholder } from './amount_placeholder'; import { Container, Flex, Text } from './ui'; export interface InstantHeadingProps { selectedAssetAmount?: BigNumber; totalEthBaseAmount?: BigNumber; ethUsdPrice?: BigNumber; quoteRequestState: AsyncProcessState; } const placeholderColor = ColorOption.white; export class InstantHeading extends React.Component { public render(): React.ReactNode { return ( I want to buy {this._placeholderOrAmount(this._ethAmount)} {this._placeholderOrAmount(this._dollarAmount)} ); } private _placeholderOrAmount(amountFunction: () => React.ReactNode): React.ReactNode { if (this.props.quoteRequestState === AsyncProcessState.PENDING) { return ; } if (_.isUndefined(this.props.selectedAssetAmount)) { return ; } return amountFunction(); } private _ethAmount = (): React.ReactNode => { return ( {format.ethBaseAmount( this.props.totalEthBaseAmount, 4, , )} ); }; private _dollarAmount = (): React.ReactNode => { return ( {format.ethBaseAmountInUsd( this.props.totalEthBaseAmount, this.props.ethUsdPrice, 2, , )} ); }; }