import { colors } from '@0xproject/react-shared'; import { ObjectMap } from '@0xproject/types'; import * as _ from 'lodash'; import * as React from 'react'; import { Container } from 'ts/components/ui/container'; import { DropDown } from 'ts/components/ui/drop_down'; import { Link } from 'ts/components/ui/link'; import { Text } from 'ts/components/ui/text'; import { Deco, Key, WebsitePaths } from 'ts/types'; import { constants } from 'ts/utils/constants'; import { Translate } from 'ts/utils/translate'; interface LinkInfo { link: string; shouldOpenInNewTab?: boolean; } const gettingStartedKeyToLinkInfo1: ObjectMap = { [Key.BuildARelayer]: { link: `${WebsitePaths.Wiki}#Build-A-Relayer`, }, [Key.OrderBasics]: { link: `${WebsitePaths.Wiki}#Create,-Validate,-Fill-Order`, }, }; const gettingStartedKeyToLinkInfo2: ObjectMap = { [Key.DevelopOnEthereum]: { link: `${WebsitePaths.Wiki}#Ethereum-Development`, }, [Key.UseSharedLiquidity]: { link: `${WebsitePaths.Wiki}#Find,-Submit,-Fill-Order-From-Relayer`, }, }; const popularDocsToLinkInfos: ObjectMap = { [Key.ZeroExJs]: { link: WebsitePaths.ZeroExJs, }, [Key.Connect]: { link: WebsitePaths.Connect, }, [Key.SmartContract]: { link: WebsitePaths.SmartContracts, }, }; const usefulLinksToLinkInfo: ObjectMap = { [Key.Github]: { link: constants.URL_GITHUB_ORG, shouldOpenInNewTab: true, }, [Key.Whitepaper]: { link: WebsitePaths.Whitepaper, shouldOpenInNewTab: true, }, [Key.Sandbox]: { link: constants.URL_SANDBOX, shouldOpenInNewTab: true, }, }; interface DevelopersDropDownProps { translate: Translate; menuItemStyles: React.CSSProperties; menuIconStyle: React.CSSProperties; } interface DevelopersDropDownState {} export class DevelopersDropDown extends React.Component { public render(): React.ReactNode { const activeNode = ( {this.props.translate.get(Key.Developers, Deco.Cap)} ); return ( ); } private _renderDropdownMenu(): React.ReactNode { const dropdownMenu = (
{this._renderTitle('Getting started')}
{this._renderLinkSection(gettingStartedKeyToLinkInfo1)}
{this._renderLinkSection(gettingStartedKeyToLinkInfo2)}
{this._renderTitle('Popular docs')}
{this._renderLinkSection(popularDocsToLinkInfos)}
{this._renderTitle('Useful links')}
{this._renderLinkSection(usefulLinksToLinkInfo)}
{this.props.translate.get(Key.ViewAllDocumentation, Deco.Upper)}
); return dropdownMenu; } private _renderTitle(title: string): React.ReactNode { return (
{title.toUpperCase()}
); } private _renderLinkSection(keyToLinkInfo: ObjectMap): React.ReactNode { const linkStyle: React.CSSProperties = { color: colors.lightBlueA700, fontFamily: 'Roboto, Roboto Mono', }; const numLinks = _.size(keyToLinkInfo); let i = 0; const links = _.map(keyToLinkInfo, (linkInfo: LinkInfo, key: string) => { i++; const isLast = i === numLinks; const linkText = this.props.translate.get(key as Key, Deco.Cap); return (
{linkText}
); }); return
{links}
; } }