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 --- .../ts/pages/documentation/documentation.tsx | 54 ++++++++++++++-------- .../ts/pages/documentation/method_block.tsx | 9 +++- .../ts/pages/documentation/method_signature.tsx | 47 ++++++++++++++----- 3 files changed, 78 insertions(+), 32 deletions(-) (limited to 'packages/website/ts/pages/documentation') diff --git a/packages/website/ts/pages/documentation/documentation.tsx b/packages/website/ts/pages/documentation/documentation.tsx index e20040bc0..2227f59d3 100644 --- a/packages/website/ts/pages/documentation/documentation.tsx +++ b/packages/website/ts/pages/documentation/documentation.tsx @@ -37,6 +37,7 @@ import { constants } from 'ts/utils/constants'; import { docUtils } from 'ts/utils/doc_utils'; import { utils } from 'ts/utils/utils'; +const TOP_BAR_HEIGHT = 60; const SCROLL_TOP_ID = 'docsScrollTop'; const networkNameToColor: { [network: string]: string } = { @@ -67,7 +68,7 @@ const styles: Styles = { right: 0, overflowZ: 'hidden', overflowY: 'scroll', - minHeight: 'calc(100vh - 1px)', + minHeight: 'calc(100vh - 60px)', WebkitOverflowScrolling: 'touch', }, menuContainer: { @@ -111,7 +112,7 @@ export class Documentation extends React.Component {_.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 ? ' => ' : ': '}{' '} + + )}
); -- cgit v1.2.3