From 2778f96483ea21f5ec33f4222c19d7864eca2f1f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 15 Feb 2018 21:51:49 -0700 Subject: Re-design docs pages --- packages/website/ts/components/top_bar/top_bar.tsx | 3 -- .../ts/containers/connect_documentation.tsx | 5 +- .../ts/containers/zero_ex_js_documentation.tsx | 3 +- .../ts/pages/documentation/documentation.tsx | 54 ++++++++++++++-------- .../ts/pages/documentation/method_block.tsx | 9 +++- .../ts/pages/documentation/method_signature.tsx | 47 ++++++++++++++----- .../ts/pages/shared/nested_sidebar_menu.tsx | 9 +++- 7 files changed, 91 insertions(+), 39 deletions(-) (limited to 'packages/website/ts') diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index 589375da3..a412007f2 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -290,9 +290,6 @@ export class TopBar extends React.Component { const sectionTitle = `${this.props.docsInfo.displayName} Docs`; return (
-
- {sectionTitle} -
{_.isUndefined(this.state.docAgnosticFormat) ? ( @@ -129,26 +130,41 @@ export class Documentation extends React.Component
) : ( -
-
+
+
- +
+ +
-
-
-
-
- {this._renderDocumentation()} +
+
+
+ {this._renderDocumentation()} +
diff --git a/packages/website/ts/pages/documentation/method_block.tsx b/packages/website/ts/pages/documentation/method_block.tsx index 78ba2ba1e..1bc6aa4f4 100644 --- a/packages/website/ts/pages/documentation/method_block.tsx +++ b/packages/website/ts/pages/documentation/method_block.tsx @@ -122,12 +122,17 @@ export class MethodBlock extends React.Component
-
{parameter.name}
+
+ {parameter.name} +
{isOptional && 'optional'}
-
+
{parameter.comment && }
diff --git a/packages/website/ts/pages/documentation/method_signature.tsx b/packages/website/ts/pages/documentation/method_signature.tsx index 041dcd093..a24d35924 100644 --- a/packages/website/ts/pages/documentation/method_signature.tsx +++ b/packages/website/ts/pages/documentation/method_signature.tsx @@ -1,5 +1,6 @@ import * as _ from 'lodash'; import * as React from 'react'; +import * as ReactDOM from 'react-dom'; import { DocsInfo } from 'ts/pages/documentation/docs_info'; import { Type } from 'ts/pages/documentation/type'; import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptMethod } from 'ts/types'; @@ -22,26 +23,50 @@ const defaultProps = { export const MethodSignature: React.SFC = (props: MethodSignatureProps) => { const sectionName = constants.TYPES_SECTION_NAME; const parameters = renderParameters(props.method, props.docsInfo, sectionName, props.typeDefinitionByName); - const paramString = _.reduce(parameters, (prev: React.ReactNode, curr: React.ReactNode) => { - return [prev, ', ', curr]; + const paramStringArray: any[] = []; + _.each(parameters, (param: React.ReactNode, i: number) => { + const finalParam = + parameters.length > 2 ? ( + + {param} + + ) : ( + param + ); + paramStringArray.push(finalParam); + const comma = + parameters.length > 2 ? ( + + ,
+
+ ) : ( + ', ' + ); + paramStringArray.push(comma); }); + if (parameters.length <= 2) { + paramStringArray.pop(); + } const methodName = props.shouldHideMethodName ? '' : props.method.name; const typeParameterIfExists = _.isUndefined((props.method as TypescriptMethod).typeParameter) ? undefined : renderTypeParameter(props.method, props.docsInfo, sectionName, props.typeDefinitionByName); return ( - + {props.method.callPath} {methodName} - {typeParameterIfExists}({paramString}) - {props.shouldUseArrowSyntax ? ' => ' : ': '}{' '} + {typeParameterIfExists}({parameters.length > 2 &&
} + {paramStringArray}) {props.method.returnType && ( - + + {props.shouldUseArrowSyntax ? ' => ' : ': '}{' '} + + )}
); diff --git a/packages/website/ts/pages/shared/nested_sidebar_menu.tsx b/packages/website/ts/pages/shared/nested_sidebar_menu.tsx index fde6ef7ae..1b63f5203 100644 --- a/packages/website/ts/pages/shared/nested_sidebar_menu.tsx +++ b/packages/website/ts/pages/shared/nested_sidebar_menu.tsx @@ -36,6 +36,13 @@ const styles: Styles = { }, }; +const titleToIcon: { [title: string]: string } = { + '0x.js': 'zeroExJs.png', + '0x Connect': 'connect.png', + '0x Smart Contracts': 'contracts.png', + Wiki: 'wiki.png', +}; + export class NestedSidebarMenu extends React.Component { public static defaultProps: Partial = { shouldDisplaySectionHeaders: true, @@ -100,7 +107,7 @@ export class NestedSidebarMenu extends React.Component
- +
{this.props.title} -- cgit