aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-26 09:35:06 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-26 09:35:06 +0800
commitd5d99b9d2e3c793a95c68c1035246644b3ae80c6 (patch)
tree880f13fd7dba96285c23986e505f3166de099a4c /packages/instant/src/components
parentab2759f43105c0f2d441790e138840706c6759f8 (diff)
downloaddexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.tar
dexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.tar.gz
dexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.tar.bz2
dexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.tar.lz
dexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.tar.xz
dexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.tar.zst
dexon-sol-tools-d5d99b9d2e3c793a95c68c1035246644b3ae80c6.zip
chore: dont override toString of BigNumber and other PR feedback
Diffstat (limited to 'packages/instant/src/components')
-rw-r--r--packages/instant/src/components/animations/slide_animations.tsx5
-rw-r--r--packages/instant/src/components/erc20_asset_amount_input.tsx (renamed from packages/instant/src/components/asset_amount_input.tsx)21
-rw-r--r--packages/instant/src/components/instant_heading.tsx4
-rw-r--r--packages/instant/src/components/scaling_amount_input.tsx11
4 files changed, 23 insertions, 18 deletions
diff --git a/packages/instant/src/components/animations/slide_animations.tsx b/packages/instant/src/components/animations/slide_animations.tsx
index 7c8666861..84280372b 100644
--- a/packages/instant/src/components/animations/slide_animations.tsx
+++ b/packages/instant/src/components/animations/slide_animations.tsx
@@ -21,7 +21,10 @@ export interface SlideAnimationProps {
animationDirection?: string;
}
-export const SlideAnimation = styled<SlideAnimationProps, 'div'>('div')`
+export const SlideAnimation =
+ styled.div <
+ SlideAnimationProps >
+ `
animation-name: ${props =>
css`
${props.keyframes};
diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/erc20_asset_amount_input.tsx
index 4d2dc0bd8..583fad28b 100644
--- a/packages/instant/src/components/asset_amount_input.tsx
+++ b/packages/instant/src/components/erc20_asset_amount_input.tsx
@@ -1,32 +1,33 @@
-import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import * as React from 'react';
-import { ColorOption } from '../style/theme';
+import { ColorOption, transparentWhite } from '../style/theme';
import { ERC20Asset } from '../types';
import { assetUtils } from '../util/asset';
+import { BigNumberInput } from '../util/big_number_input';
import { util } from '../util/util';
import { ScalingAmountInput } from './scaling_amount_input';
import { Container, Text } from './ui';
// Asset amounts only apply to ERC20 assets
-export interface AssetAmountInputProps {
+export interface ERC20AssetAmountInputProps {
asset?: ERC20Asset;
- onChange: (value?: BigNumber, asset?: ERC20Asset) => void;
+ value?: BigNumberInput;
+ onChange: (value?: BigNumberInput, asset?: ERC20Asset) => void;
startingFontSizePx: number;
fontColor?: ColorOption;
}
-export interface AssetAmountInputState {
+export interface ERC20AssetAmountInputState {
currentFontSizePx: number;
}
-export class AssetAmountInput extends React.Component<AssetAmountInputProps, AssetAmountInputState> {
+export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInputProps, ERC20AssetAmountInputState> {
public static defaultProps = {
onChange: util.boundNoop,
};
- constructor(props: AssetAmountInputProps) {
+ constructor(props: ERC20AssetAmountInputProps) {
super(props);
this.state = {
currentFontSizePx: props.startingFontSizePx,
@@ -36,7 +37,7 @@ export class AssetAmountInput extends React.Component<AssetAmountInputProps, Ass
const { asset, onChange, ...rest } = this.props;
return (
<Container whiteSpace="nowrap">
- <Container borderBottom="1px solid rgba(255,255,255,0.3)" display="inline-block">
+ <Container borderBottom={`1px solid ${transparentWhite}`} display="inline-block">
<ScalingAmountInput
{...rest}
textLengthThreshold={this._textLengthThresholdForAsset(asset)}
@@ -57,7 +58,7 @@ export class AssetAmountInput extends React.Component<AssetAmountInputProps, Ass
</Container>
);
}
- private readonly _handleChange = (value?: BigNumber): void => {
+ private readonly _handleChange = (value?: BigNumberInput): void => {
this.props.onChange(value, this.props.asset);
};
private readonly _handleFontSizeChange = (fontSizePx: number): void => {
@@ -65,6 +66,8 @@ export class AssetAmountInput extends React.Component<AssetAmountInputProps, Ass
currentFontSizePx: fontSizePx,
});
};
+ // For assets with symbols of different length,
+ // start scaling the input at different character lengths
private readonly _textLengthThresholdForAsset = (asset?: ERC20Asset): number => {
if (_.isUndefined(asset)) {
return 3;
diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx
index f0a22bccb..df9856277 100644
--- a/packages/instant/src/components/instant_heading.tsx
+++ b/packages/instant/src/components/instant_heading.tsx
@@ -2,7 +2,7 @@ import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import * as React from 'react';
-import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input';
+import { SelectedERC20AssetAmountInput } from '../containers/selected_erc20_asset_amount_input';
import { ColorOption } from '../style/theme';
import { AsyncProcessState, OrderState } from '../types';
import { format } from '../util/format';
@@ -48,7 +48,7 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
</Container>
<Flex direction="row" justify="space-between">
<Flex height="60px">
- <SelectedAssetAmountInput startingFontSizePx={38} />
+ <SelectedERC20AssetAmountInput startingFontSizePx={38} />
</Flex>
<Flex direction="column" justify="space-between">
{iconOrAmounts}
diff --git a/packages/instant/src/components/scaling_amount_input.tsx b/packages/instant/src/components/scaling_amount_input.tsx
index 23a15305a..655ae2b74 100644
--- a/packages/instant/src/components/scaling_amount_input.tsx
+++ b/packages/instant/src/components/scaling_amount_input.tsx
@@ -1,9 +1,8 @@
-import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import * as React from 'react';
import { ColorOption } from '../style/theme';
-import { BigNumberInput } from '../util/big_number';
+import { BigNumberInput } from '../util/big_number_input';
import { util } from '../util/util';
import { ScalingInput } from './scaling_input';
@@ -12,8 +11,8 @@ export interface ScalingAmountInputProps {
maxFontSizePx: number;
textLengthThreshold: number;
fontColor?: ColorOption;
- value?: BigNumber;
- onChange: (value?: BigNumber) => void;
+ value?: BigNumberInput;
+ onChange: (value?: BigNumberInput) => void;
onFontSizeChange: (fontSizePx: number) => void;
}
@@ -31,7 +30,7 @@ export class ScalingAmountInput extends React.Component<ScalingAmountInputProps>
onFontSizeChange={onFontSizeChange}
fontColor={fontColor}
onChange={this._handleChange}
- value={!_.isUndefined(value) ? value.toString() : ''}
+ value={!_.isUndefined(value) ? value.toDisplayString() : ''}
placeholder="0.00"
emptyInputWidthCh={3.5}
/>
@@ -42,7 +41,7 @@ export class ScalingAmountInput extends React.Component<ScalingAmountInputProps>
let bigNumberValue;
if (!_.isEmpty(value)) {
try {
- bigNumberValue = new BigNumberInput(event.target.value);
+ bigNumberValue = new BigNumberInput(value);
} catch {
// We don't want to allow values that can't be a BigNumber, so don't even call onChange.
return;