From 5bc83fceaa3c281e45af0f30ace67643554830c8 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 17 May 2018 10:54:32 -0700 Subject: Refactor code in response to CR feedback --- .../ts/components/inputs/balance_bounded_input.tsx | 15 ++++++++------- .../website/ts/components/inputs/token_amount_input.tsx | 4 ++-- packages/website/ts/components/wallet/wrap_ether_item.tsx | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'packages/website/ts/components') diff --git a/packages/website/ts/components/inputs/balance_bounded_input.tsx b/packages/website/ts/components/inputs/balance_bounded_input.tsx index 9a6ff64a7..b90232e05 100644 --- a/packages/website/ts/components/inputs/balance_bounded_input.tsx +++ b/packages/website/ts/components/inputs/balance_bounded_input.tsx @@ -5,7 +5,7 @@ import TextField from 'material-ui/TextField'; import * as React from 'react'; import { Link } from 'react-router-dom'; import { RequiredLabel } from 'ts/components/ui/required_label'; -import { InputErrMsg, ValidatedBigNumberCallback, WebsitePaths } from 'ts/types'; +import { ValidatedBigNumberCallback, WebsitePaths } from 'ts/types'; import { utils } from 'ts/utils/utils'; interface BalanceBoundedInputProps { @@ -17,7 +17,7 @@ interface BalanceBoundedInputProps { onErrorMsgChange?: (errorMsg: React.ReactNode) => void; shouldShowIncompleteErrs?: boolean; shouldCheckBalance: boolean; - validate?: (amount: BigNumber) => InputErrMsg; + validate?: (amount: BigNumber) => React.ReactNode; onVisitBalancesPageClick?: () => void; shouldHideVisitBalancesLink?: boolean; isDisabled?: boolean; @@ -26,7 +26,7 @@ interface BalanceBoundedInputProps { } interface BalanceBoundedInputState { - errMsg: InputErrMsg; + errMsg: React.ReactNode; amountString: string; } @@ -37,7 +37,7 @@ export class BalanceBoundedInput extends React.Component { const isValid = _.isUndefined(this._validate(amountString, this.props.balance)); - if (utils.isNumeric(amountString) && !_.includes(amountString, '-')) { + const isPositiveNumber = utils.isNumeric(amountString) && !_.includes(amountString, '-'); + if (isPositiveNumber) { this.props.onChange(isValid, new BigNumber(amountString)); } else { this.props.onChange(isValid); @@ -114,7 +115,7 @@ export class BalanceBoundedInput extends React.Component void = utils.noop): void { + private _setAmountState(amount: string, balance: BigNumber, callback: () => void = _.noop): void { const errorMsg = this._validate(amount, balance); this.props.onErrorMsgChange(errorMsg); this.setState({ diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx index 3ff2c5440..a5fd86f6c 100644 --- a/packages/website/ts/components/inputs/token_amount_input.tsx +++ b/packages/website/ts/components/inputs/token_amount_input.tsx @@ -6,7 +6,7 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { Blockchain } from 'ts/blockchain'; import { BalanceBoundedInput } from 'ts/components/inputs/balance_bounded_input'; -import { InputErrMsg, Token, ValidatedBigNumberCallback, WebsitePaths } from 'ts/types'; +import { Token, ValidatedBigNumberCallback, WebsitePaths } from 'ts/types'; interface TokenAmountInputProps { userAddress: string; @@ -107,7 +107,7 @@ export class TokenAmountInput extends React.Component diff --git a/packages/website/ts/components/wallet/wrap_ether_item.tsx b/packages/website/ts/components/wallet/wrap_ether_item.tsx index c8ced8d08..0dff22feb 100644 --- a/packages/website/ts/components/wallet/wrap_ether_item.tsx +++ b/packages/website/ts/components/wallet/wrap_ether_item.tsx @@ -56,7 +56,7 @@ const styles: Styles = { errorMsg: { fontSize: 12, marginTop: 4, - color: 'red', + color: colors.red, minHeight: 20, }, }; -- cgit