import { ALink, colors, Link } from '@0xproject/react-shared'; import * as _ from 'lodash'; import Drawer from 'material-ui/Drawer'; import * as React from 'react'; import { DocsLogo } from 'ts/components/documentation/docs_logo'; import { Container } from 'ts/components/ui/container'; import { Text } from 'ts/components/ui/text'; import { Deco, Key, ScreenWidths, WebsitePaths } from 'ts/types'; import { constants } from 'ts/utils/constants'; import { Translate } from 'ts/utils/translate'; export interface DocsTopBarProps { location: Location; screenWidth: ScreenWidths; translate: Translate; sidebar?: React.ReactNode; } interface DocsTopBarState { isDrawerOpen: boolean; } export class DocsTopBar extends React.Component { constructor(props: DocsTopBarProps) { super(props); this.state = { isDrawerOpen: false, }; } public componentWillReceiveProps(nextProps: DocsTopBarProps): void { if (nextProps.location.pathname !== this.props.location.pathname) { this.setState({ isDrawerOpen: false, }); } } public render(): React.ReactNode { const menuItemLinks: ALink[] = [ { title: this.props.translate.get(Key.Home, Deco.Cap), to: WebsitePaths.Home, }, { title: this.props.translate.get(Key.Wiki, Deco.Cap), to: WebsitePaths.Wiki, }, { title: this.props.translate.get(Key.Forum, Deco.Cap), to: constants.URL_FORUM, shouldOpenInNewTab: true, }, { title: this.props.translate.get(Key.LiveChat, Deco.Cap), to: constants.URL_ZEROEX_CHAT, shouldOpenInNewTab: true, }, ]; return ( {this._renderMenuItems(menuItemLinks)} {this.props.screenWidth === ScreenWidths.Sm && this._renderDrawer()} ); } private _renderMenuItems(menuItemLinks: ALink[]): React.ReactNode { const menuItems = _.map(menuItemLinks, menuItemInfo => { return ( {menuItemInfo.title} ); }); return menuItems; } private _renderDrawer(): React.ReactNode { return ( {this.props.sidebar} ); } private _onMenuButtonClick(): void { this.setState({ isDrawerOpen: !this.state.isDrawerOpen, }); } }