aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-11-02 04:16:48 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-11-02 04:16:48 +0800
commitbda9d4c1b099fc4db05d34a1d8dc0543a68413b8 (patch)
treefaee82d0bca11cc610ee7ac8d0c4c298722208b4 /packages
parentb55ba3a31823699fa2460fad6fd22b913c38c946 (diff)
downloaddexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.tar
dexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.tar.gz
dexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.tar.bz2
dexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.tar.lz
dexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.tar.xz
dexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.tar.zst
dexon-sol-tools-bda9d4c1b099fc4db05d34a1d8dc0543a68413b8.zip
feat: auto-close panel when a token is selected
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/src/components/zero_ex_instant_container.tsx2
-rw-r--r--packages/instant/src/containers/available_erc20_token_selector.ts12
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx
index 765ff7e3d..850beb49c 100644
--- a/packages/instant/src/components/zero_ex_instant_container.tsx
+++ b/packages/instant/src/components/zero_ex_instant_container.tsx
@@ -46,7 +46,7 @@ export class ZeroExInstantContainer extends React.Component<ZeroExInstantContain
animationState={this.state.tokenSelectionPanelAnimationState}
onClose={this._handlePanelClose}
>
- <AvailableERC20TokenSelector />
+ <AvailableERC20TokenSelector onTokenSelect={this._handlePanelClose} />
</SlidingPanel>
</Container>
</Container>
diff --git a/packages/instant/src/containers/available_erc20_token_selector.ts b/packages/instant/src/containers/available_erc20_token_selector.ts
index e8bacdba0..bb194cd6b 100644
--- a/packages/instant/src/containers/available_erc20_token_selector.ts
+++ b/packages/instant/src/containers/available_erc20_token_selector.ts
@@ -1,3 +1,4 @@
+import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
@@ -9,7 +10,9 @@ import { assetUtils } from '../util/asset';
import { ERC20TokenSelector } from '../components/erc20_token_selector';
import { Action, actions } from '../redux/actions';
-export interface AvailableERC20TokenSelectorProps {}
+export interface AvailableERC20TokenSelectorProps {
+ onTokenSelect?: (token: ERC20Asset) => void;
+}
interface ConnectedState {
tokens: ERC20Asset[];
@@ -27,7 +30,12 @@ const mapDispatchToProps = (
dispatch: Dispatch<Action>,
ownProps: AvailableERC20TokenSelectorProps,
): ConnectedDispatch => ({
- onTokenSelect: (token: ERC20Asset) => dispatch(actions.updateSelectedAsset(token)),
+ onTokenSelect: (token: ERC20Asset) => {
+ if (ownProps.onTokenSelect) {
+ ownProps.onTokenSelect(token);
+ }
+ dispatch(actions.updateSelectedAsset(token));
+ },
});
export const AvailableERC20TokenSelector: React.ComponentClass<AvailableERC20TokenSelectorProps> = connect(