Use Image component where relevant and add back tracked token timestamp logic

This commit is contained in:
fragosti
2018-06-29 11:08:48 -07:00
parent e71862676c
commit 36cadaae46
3 changed files with 24 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
import { BigNumber } from '@0xproject/utils'; import { BigNumber } from '@0xproject/utils';
import * as React from 'react'; import * as React from 'react';
import { Container } from 'ts/components/ui/container'; import { Container } from 'ts/components/ui/container';
import { Image } from 'ts/components/ui/image';
import { Text } from 'ts/components/ui/text'; import { Text } from 'ts/components/ui/text';
import { constants } from 'ts/utils/constants'; import { constants } from 'ts/utils/constants';
import { utils } from 'ts/utils/utils'; import { utils } from 'ts/utils/utils';
@@ -24,17 +25,17 @@ export const AddEthOnboardingStep: React.StatelessComponent<AddEthOnboardingStep
in your wallet. in your wallet.
</Text> </Text>
<Container marginTop="15px" marginBottom="15px"> <Container marginTop="15px" marginBottom="15px">
<img src="/images/ether_alt.svg" height="50px" width="50px" /> <Image src="/images/ether_alt.svg" height="50px" width="50px" />
</Container> </Container>
</div> </div>
) : ( ) : (
<div className="flex items-center flex-column"> <div className="flex items-center flex-column">
<Text> Before you begin you will need to send some ETH to your wallet.</Text> <Text> Before you begin you will need to send some ETH to your wallet.</Text>
<Container marginTop="15px" marginBottom="15px"> <Container marginTop="15px" marginBottom="15px">
<img src="/images/ether_alt.svg" height="50px" width="50px" /> <Image src="/images/ether_alt.svg" height="50px" width="50px" />
</Container> </Container>
<Text className="xs-hide"> <Text className="xs-hide">
Click on the <img src="/images/metamask_icon.png" height="20px" width="20px" /> metamask extension in Click on the <Image src="/images/metamask_icon.png" height="20px" width="20px" /> MetaMask extension in
your browser and click either <b>BUY</b> or <b>DEPOSIT</b>. your browser and click either <b>BUY</b> or <b>DEPOSIT</b>.
</Text> </Text>
</div> </div>

View File

@@ -1,5 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import { Container } from 'ts/components/ui/container'; import { Container } from 'ts/components/ui/container';
import { Image } from 'ts/components/ui/image';
import { Text } from 'ts/components/ui/text'; import { Text } from 'ts/components/ui/text';
export interface IntroOnboardingStepProps {} export interface IntroOnboardingStepProps {}
@@ -11,15 +12,15 @@ export const IntroOnboardingStep: React.StatelessComponent<IntroOnboardingStepPr
</Text> </Text>
<Container width="100%" marginTop="25px" marginBottom="15px" className="flex justify-around"> <Container width="100%" marginTop="25px" marginBottom="15px" className="flex justify-around">
<div className="flex flex-column items-center"> <div className="flex flex-column items-center">
<img src="/images/ether.png" height="50px" width="50px" /> <Image src="/images/ether.png" height="50px" width="50px" />
<Text> Add ETH </Text> <Text> Add ETH </Text>
</div> </div>
<div className="flex flex-column items-center"> <div className="flex flex-column items-center">
<img src="/images/eth_token.svg" height="50px" width="50x" /> <Image src="/images/eth_token.svg" height="50px" width="50x" />
<Text> Wrap ETH </Text> <Text> Wrap ETH </Text>
</div> </div>
<div className="flex flex-column items-center"> <div className="flex flex-column items-center">
<img src="/images/fake_toggle.svg" height="50px" width="50px" /> <Image src="/images/fake_toggle.svg" height="50px" width="50px" />
<Text> Unlock tokens </Text> <Text> Unlock tokens </Text>
</div> </div>
</Container> </Container>

View File

@@ -156,6 +156,20 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
isHoveringSidebar: false, isHoveringSidebar: false,
}; };
} }
public componentDidUpdate(prevProps: WalletProps): void {
const currentTrackedTokens = this.props.trackedTokens;
const differentTrackedTokens = _.difference(currentTrackedTokens, prevProps.trackedTokens);
const firstDifferentTrackedToken = _.head(differentTrackedTokens);
// check if there is only one different token, and if that token is a member of the current tracked tokens
// this means that the token was added, not removed
if (
!_.isUndefined(firstDifferentTrackedToken) &&
_.size(differentTrackedTokens) === 1 &&
_.includes(currentTrackedTokens, firstDifferentTrackedToken)
) {
document.getElementById(firstDifferentTrackedToken.address).scrollIntoView();
}
}
public render(): React.ReactNode { public render(): React.ReactNode {
const isBlockchainLoaded = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError; const isBlockchainLoaded = this.props.blockchainIsLoaded && this.props.blockchainErr === BlockchainErrs.NoError;
return ( return (
@@ -318,7 +332,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const trackedTokensStartingWithEtherToken = trackedTokens.sort( const trackedTokensStartingWithEtherToken = trackedTokens.sort(
firstBy((t: Token) => t.symbol !== constants.ETHER_TOKEN_SYMBOL) firstBy((t: Token) => t.symbol !== constants.ETHER_TOKEN_SYMBOL)
.thenBy((t: Token) => t.symbol !== constants.ZRX_TOKEN_SYMBOL) .thenBy((t: Token) => t.symbol !== constants.ZRX_TOKEN_SYMBOL)
.thenBy('address'), .thenBy('trackedTimestamp'),
); );
return _.map(trackedTokensStartingWithEtherToken, this._renderTokenRow.bind(this)); return _.map(trackedTokensStartingWithEtherToken, this._renderTokenRow.bind(this));
} }
@@ -375,7 +389,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
const style = { ...styles.tokenItem, ...additionalStyle }; const style = { ...styles.tokenItem, ...additionalStyle };
const etherToken = this._getEthToken(); const etherToken = this._getEthToken();
return ( return (
<div key={key} className={`flex flex-column ${className || ''}`}> <div id={key} key={key} className={`flex flex-column ${className || ''}`}>
<StandardIconRow <StandardIconRow
icon={icon} icon={icon}
main={ main={