import { ALink, colors, Link, NestedSidebarMenu } from '@0xproject/react-shared'; import { ObjectMap } from '@0xproject/types'; 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; } interface MenuItemInfo { iconUrl: string; fontColor: string; fontWeight?: string; link: ALink; } 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 menuItemInfos: MenuItemInfo[] = [ { link: { title: this.props.translate.get(Key.Wiki, Deco.Cap), to: WebsitePaths.Wiki, }, iconUrl: '/images/developers/github_icon.svg', fontColor: colors.linkSectionGrey, }, { link: { title: this.props.translate.get(Key.Forum, Deco.Cap), to: constants.URL_FORUM, shouldOpenInNewTab: true, }, iconUrl: '/images/developers/forum_icon.svg', fontColor: colors.linkSectionGrey, }, { link: { title: this.props.translate.get(Key.LiveChat, Deco.Cap), to: constants.URL_ZEROEX_CHAT, shouldOpenInNewTab: true, }, iconUrl: '/images/developers/chat_icon.svg', fontColor: colors.lightLinkBlue, fontWeight: 'bold', }, ]; return ( 0xproject.com {this._renderMenuItems(menuItemInfos)} {this.props.screenWidth === ScreenWidths.Sm && this._renderDrawer()} ); } private _renderMenuItems(menuItemInfos: MenuItemInfo[]): React.ReactNode { const menuItems = _.map(menuItemInfos, menuItemInfo => { return ( {menuItemInfo.link.title} ); }); return menuItems; } private _renderDrawer(): React.ReactNode { return ( {this.props.sidebar} ); } private _onMenuButtonClick(): void { this.setState({ isDrawerOpen: !this.state.isDrawerOpen, }); } }