aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/asset_amount_input.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src/components/asset_amount_input.tsx')
-rw-r--r--packages/instant/src/components/asset_amount_input.tsx41
1 files changed, 35 insertions, 6 deletions
diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx
index c03ef1cf3..0b22c889c 100644
--- a/packages/instant/src/components/asset_amount_input.tsx
+++ b/packages/instant/src/components/asset_amount_input.tsx
@@ -7,33 +7,62 @@ import { ERC20Asset } from '../types';
import { assetUtils } from '../util/asset';
import { util } from '../util/util';
-import { AmountInput, AmountInputProps } from './amount_input';
+import { ScalingAmountInput } from './scaling_amount_input';
import { Container, Text } from './ui';
// Asset amounts only apply to ERC20 assets
-export interface AssetAmountInputProps extends AmountInputProps {
+export interface AssetAmountInputProps {
asset?: ERC20Asset;
onChange: (value?: BigNumber, asset?: ERC20Asset) => void;
+ startingFontSizePx: number;
+ fontColor?: ColorOption;
}
-export class AssetAmountInput extends React.Component<AssetAmountInputProps> {
+export interface AssetAmountInputState {
+ currentFontSizePx: number;
+}
+
+export class AssetAmountInput extends React.Component<AssetAmountInputProps, AssetAmountInputState> {
public static defaultProps = {
onChange: util.boundNoop,
};
+ constructor(props: AssetAmountInputProps) {
+ super(props);
+ this.state = {
+ currentFontSizePx: props.startingFontSizePx,
+ };
+ }
public render(): React.ReactNode {
const { asset, onChange, ...rest } = this.props;
return (
<Container>
- <AmountInput {...rest} onChange={this._handleChange} />
+ <Container borderBottom="1px solid rgba(255,255,255,0.3)" display="inline-block">
+ <ScalingAmountInput
+ {...rest}
+ startWidthCh={3.5}
+ endWidthCh={5}
+ fontSizePx={this.state.currentFontSizePx}
+ onChange={this._handleChange}
+ />
+ </Container>
<Container display="inline-block" marginLeft="10px">
- <Text fontSize={rest.fontSize} fontColor={ColorOption.white} textTransform="uppercase">
+ <Text
+ fontSize={`${this.state.currentFontSizePx}px`}
+ fontColor={ColorOption.white}
+ textTransform="uppercase"
+ >
{assetUtils.bestNameForAsset(asset)}
</Text>
</Container>
</Container>
);
}
- private readonly _handleChange = (value?: BigNumber): void => {
+ private readonly _handleChange = (value?: BigNumber, fontSize?: number): void => {
this.props.onChange(value, this.props.asset);
+ if (!_.isUndefined(fontSize)) {
+ this.setState({
+ currentFontSizePx: fontSize,
+ });
+ }
};
}