import { ALink, colors, Link } from '@0x/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 } 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 { return ( {this._renderMenuItems(constants.DEVELOPER_TOPBAR_LINKS)} {this.props.screenWidth === ScreenWidths.Sm && this._renderDrawer()} ); } private _renderMenuItems(menuItemLinks: ALink[]): React.ReactNode { const menuItems = _.map(menuItemLinks, menuItemInfo => { return ( {this.props.translate.get(menuItemInfo.title as Key, Deco.Cap)} ); }); return menuItems; } private _renderDrawer(): React.ReactNode { return ( {this.props.sidebar} ); } private _onMenuButtonClick(): void { this.setState({ isDrawerOpen: !this.state.isDrawerOpen, }); } }