aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/instant_heading.tsx
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2019-01-09 19:02:25 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2019-01-09 19:02:25 +0800
commitea14913b412e78ff458bdfba47182f7363e776e5 (patch)
tree3ee220bfbbd9923b5e1adc36ee51f9b5d39ad640 /packages/instant/src/components/instant_heading.tsx
parent5868c91cfb54cfa9177572b201d88d1168bf5b06 (diff)
parent5dd55491b86bf8577405e37d0f2d668aa1273b10 (diff)
downloaddexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.gz
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.bz2
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.lz
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.xz
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.tar.zst
dexon-sol-tools-ea14913b412e78ff458bdfba47182f7363e776e5.zip
Merge development
Diffstat (limited to 'packages/instant/src/components/instant_heading.tsx')
-rw-r--r--packages/instant/src/components/instant_heading.tsx47
1 files changed, 32 insertions, 15 deletions
diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx
index 002695269..e943f68d7 100644
--- a/packages/instant/src/components/instant_heading.tsx
+++ b/packages/instant/src/components/instant_heading.tsx
@@ -28,11 +28,11 @@ const ICON_WIDTH = 34;
const ICON_HEIGHT = 34;
const ICON_COLOR = ColorOption.white;
-export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
+export class InstantHeading extends React.PureComponent<InstantHeadingProps, {}> {
public render(): React.ReactNode {
const iconOrAmounts = this._renderIcon() || this._renderAmountsSection();
return (
- <Container backgroundColor={ColorOption.primaryColor} padding="20px" width="100%">
+ <Container backgroundColor={ColorOption.primaryColor} width="100%" padding="20px">
<Container marginBottom="5px">
<Text
letterSpacing="1px"
@@ -61,12 +61,19 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
}
private _renderAmountsSection(): React.ReactNode {
- return (
- <Container>
- <Container marginBottom="5px">{this._renderPlaceholderOrAmount(this._renderEthAmount)}</Container>
- <Container opacity={0.7}>{this._renderPlaceholderOrAmount(this._renderDollarAmount)}</Container>
- </Container>
- );
+ if (
+ _.isUndefined(this.props.totalEthBaseUnitAmount) &&
+ this.props.quoteRequestState !== AsyncProcessState.Pending
+ ) {
+ return null;
+ } else {
+ return (
+ <Container>
+ <Container marginBottom="5px">{this._renderPlaceholderOrAmount(this._renderEthAmount)}</Container>
+ <Container opacity={0.7}>{this._renderPlaceholderOrAmount(this._renderDollarAmount)}</Container>
+ </Container>
+ );
+ }
}
private _renderIcon(): React.ReactNode {
@@ -106,20 +113,30 @@ export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
}
private readonly _renderEthAmount = (): React.ReactNode => {
+ const ethAmount = format.ethBaseUnitAmount(
+ this.props.totalEthBaseUnitAmount,
+ 4,
+ <AmountPlaceholder isPulsating={false} color={PLACEHOLDER_COLOR} />,
+ );
+
+ const fontSize = _.isString(ethAmount) && ethAmount.length >= 13 ? '14px' : '16px';
return (
- <Text fontSize="16px" fontColor={ColorOption.white} fontWeight={500}>
- {format.ethBaseUnitAmount(
- this.props.totalEthBaseUnitAmount,
- 4,
- <AmountPlaceholder isPulsating={false} color={PLACEHOLDER_COLOR} />,
- )}
+ <Text
+ fontSize={fontSize}
+ textAlign="right"
+ width="100%"
+ fontColor={ColorOption.white}
+ fontWeight={500}
+ noWrap={true}
+ >
+ {ethAmount}
</Text>
);
};
private readonly _renderDollarAmount = (): React.ReactNode => {
return (
- <Text fontSize="16px" fontColor={ColorOption.white}>
+ <Text fontSize="16px" textAlign="right" width="100%" fontColor={ColorOption.white} noWrap={true}>
{format.ethBaseUnitAmountInUsd(
this.props.totalEthBaseUnitAmount,
this.props.ethUsdPrice,