From 72671c10148d304fec072d0c62bcc9788b967f55 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 20 Mar 2018 12:26:04 +0000 Subject: Refactor titleToIcon mapping to idToIcon and move to docPage --- packages/website/ts/components/sidebar_header.tsx | 15 ++------------- packages/website/ts/components/top_bar/top_bar.tsx | 5 +++-- packages/website/ts/pages/documentation/doc_page.tsx | 17 +++++++++++++++-- packages/website/ts/pages/wiki/wiki.tsx | 4 +++- 4 files changed, 23 insertions(+), 18 deletions(-) (limited to 'packages/website/ts') diff --git a/packages/website/ts/components/sidebar_header.tsx b/packages/website/ts/components/sidebar_header.tsx index 556243430..51e8a59d5 100644 --- a/packages/website/ts/components/sidebar_header.tsx +++ b/packages/website/ts/components/sidebar_header.tsx @@ -4,20 +4,9 @@ import * as React from 'react'; const SHOW_DURATION_MS = 4000; -const titleToIcon: { [title: string]: string } = { - '0x.js': 'zeroExJs.png', - Web3Wrapper: 'zeroExJs.png', - Deployer: 'zeroExJs.png', - 'Sol-cov': 'zeroExJs.png', - 'JSON Schemas': 'zeroExJs.png', - Subproviders: 'zeroExJs.png', - '0x Connect': 'connect.png', - '0x Smart Contracts': 'contracts.png', - Wiki: 'wiki.png', -}; - interface SidebarHeaderProps { title: string; + iconUrl: string; } interface SidebarHeaderState {} @@ -37,7 +26,7 @@ export class SidebarHeader extends React.Component
- +
{this.props.title} diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 3a6ceed34..4b2e82119 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -39,6 +39,7 @@ interface TopBarProps { style?: React.CSSProperties; isNightVersion?: boolean; onVersionSelected?: (semver: string) => void; + sidebarHeader?: React.ReactNode; } interface TopBarState { @@ -393,7 +394,7 @@ export class TopBar extends React.Component { } + sidebarHeader={this.props.sidebarHeader} shouldDisplaySectionHeaders={false} onMenuItemClick={this._onMenuButtonClick.bind(this)} selectedVersion={this.props.docsVersion} @@ -413,7 +414,7 @@ export class TopBar extends React.Component { } + sidebarHeader={this.props.sidebarHeader} shouldDisplaySectionHeaders={false} onMenuItemClick={this._onMenuButtonClick.bind(this)} /> diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx index 80c47ea5c..b6dfc04b2 100644 --- a/packages/website/ts/pages/documentation/doc_page.tsx +++ b/packages/website/ts/pages/documentation/doc_page.tsx @@ -15,9 +15,20 @@ import { docUtils } from 'ts/utils/doc_utils'; import { Translate } from 'ts/utils/translate'; import { utils } from 'ts/utils/utils'; +const isDevelopment = configs.ENVIRONMENT === Environments.DEVELOPMENT; const ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH = '0.32.4'; -const isDevelopment = configs.ENVIRONMENT === Environments.DEVELOPMENT; +const idToIcon: { [id: string]: string } = { + [DocPackages.ZeroExJs]: 'zeroExJs.png', + [DocPackages.Web3Wrapper]: 'zeroExJs.png', + [DocPackages.Deployer]: 'zeroExJs.png', + [DocPackages.SolCov]: 'zeroExJs.png', + [DocPackages.JSONSchemas]: 'zeroExJs.png', + [DocPackages.Subproviders]: 'zeroExJs.png', + [DocPackages.Connect]: 'connect.png', + [DocPackages.SmartContracts]: 'contracts.png', +}; + const docIdToS3FolderName: { [id: string]: string } = { [DocPackages.ZeroExJs]: '0xjs', [DocPackages.SmartContracts]: 'smart-contracts', @@ -79,6 +90,7 @@ export class DocPage extends React.Component { ? {} : this.props.docsInfo.getMenuSubsectionsBySection(this.state.docAgnosticFormat); const sourceUrl = this._getSourceUrl(); + const iconUrl = idToIcon[this.props.docsInfo.id]; return (
@@ -92,13 +104,14 @@ export class DocPage extends React.Component { docsInfo={this.props.docsInfo} translate={this.props.translate} onVersionSelected={this._onVersionSelected.bind(this)} + sidebarHeader={} /> } + sidebarHeader={} sourceUrl={sourceUrl} topBarHeight={60} onVersionSelected={this._onVersionSelected.bind(this)} diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx index e2dd3a68e..a8d70029c 100644 --- a/packages/website/ts/pages/wiki/wiki.tsx +++ b/packages/website/ts/pages/wiki/wiki.tsx @@ -88,6 +88,7 @@ export class Wiki extends React.Component { ...styles.mainContainers, overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden', }; + const sidebarHeader = ; return (
@@ -96,6 +97,7 @@ export class Wiki extends React.Component { location={this.props.location} menuSubsectionsBySection={menuSubsectionsBySection} translate={this.props.translate} + sidebarHeader={sidebarHeader} /> {_.isUndefined(this.state.articlesBySection) ? (
@@ -134,7 +136,7 @@ export class Wiki extends React.Component { } + sidebarHeader={sidebarHeader} />
-- cgit v1.2.3