aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/top_bar/top_bar.tsx
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-05-19 06:38:04 +0800
committerGitHub <noreply@github.com>2018-05-19 06:38:04 +0800
commitc70540e7f4ead1f25d1436de3b4dcda06c3e1e68 (patch)
tree03c9c8b6cc1c66b462b7009edb470e340b17a46f /packages/website/ts/components/top_bar/top_bar.tsx
parent85020c74cf8622d131b21f82a8027d437717712e (diff)
parente291146443e2dca839e9ee58f823dde3ab71093e (diff)
downloaddexon-0x-contracts-c70540e7f4ead1f25d1436de3b4dcda06c3e1e68.tar.gz
dexon-0x-contracts-c70540e7f4ead1f25d1436de3b4dcda06c3e1e68.tar.zst
dexon-0x-contracts-c70540e7f4ead1f25d1436de3b4dcda06c3e1e68.zip
Merge pull request #598 from 0xProject/feature/website/mobile-optimize
Mobile optimize the portal layout
Diffstat (limited to 'packages/website/ts/components/top_bar/top_bar.tsx')
-rw-r--r--packages/website/ts/components/top_bar/top_bar.tsx25
1 files changed, 24 insertions, 1 deletions
diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx
index 5fde007d6..2c3273dee 100644
--- a/packages/website/ts/components/top_bar/top_bar.tsx
+++ b/packages/website/ts/components/top_bar/top_bar.tsx
@@ -9,6 +9,7 @@ import { Link } from 'react-router-dom';
import ReactTooltip = require('react-tooltip');
import { Blockchain } from 'ts/blockchain';
import { LegacyPortalMenu } from 'ts/components/legacy_portal/legacy_portal_menu';
+import { DrawerMenu } from 'ts/components/portal/drawer_menu';
import { SidebarHeader } from 'ts/components/sidebar_header';
import { ProviderDisplay } from 'ts/components/top_bar/provider_display';
import { TopBarMenuItem } from 'ts/components/top_bar/top_bar_menu_item';
@@ -18,6 +19,7 @@ import { Dispatcher } from 'ts/redux/dispatcher';
import { Deco, Key, ProviderType, WebsiteLegacyPaths, WebsitePaths } from 'ts/types';
import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate';
+import { utils } from 'ts/utils/utils';
export enum TopBarDisplayType {
Default,
@@ -93,6 +95,13 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
isDrawerOpen: false,
};
}
+ public componentWillReceiveProps(nextProps: TopBarProps): void {
+ if (nextProps.location.pathname !== this.props.location.pathname) {
+ this.setState({
+ isDrawerOpen: false,
+ });
+ }
+ }
public render(): React.ReactNode {
const isNightVersion = this.props.isNightVersion;
const isExpandedDisplayType = this.props.displayType === TopBarDisplayType.Expanded;
@@ -202,6 +211,8 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</div>
);
const popoverContent = <Menu style={{ color: colors.darkGrey }}>{developerSectionMenuItems}</Menu>;
+ // TODO : Remove this once we ship portal v2
+ const shouldShowPortalV2Drawer = this._isViewingPortal() && utils.shouldShowPortalV2();
return (
<div style={{ ...styles.topBar, ...bottomBorderStyle, ...this.props.style, ...{ height } }} className="pb1">
<div className={parentClassNames}>
@@ -274,10 +285,22 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</div>
</div>
</div>
- {this._renderDrawer()}
+ {shouldShowPortalV2Drawer ? this._renderPortalV2Drawer() : this._renderDrawer()}
</div>
);
}
+ private _renderPortalV2Drawer(): React.ReactNode {
+ return (
+ <Drawer
+ open={this.state.isDrawerOpen}
+ docked={false}
+ openSecondary={true}
+ onRequestChange={this._onMenuButtonClick.bind(this)}
+ >
+ <DrawerMenu selectedPath={this.props.location.pathname} userAddress={this.props.userAddress} />
+ </Drawer>
+ );
+ }
private _renderDrawer(): React.ReactNode {
return (
<Drawer