diff options
author | Fabio Berger <me@fabioberger.com> | 2018-08-01 23:36:37 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-08-01 23:36:37 +0800 |
commit | 3bdf6004ca74dd9eb380aa61cf9e69c47725116a (patch) | |
tree | 02065e5e202fdf959aa90c44eaeb25cf838540dd /packages/react-docs/src/components/type.tsx | |
parent | 11869122b4fe00c834347f9911985d7b2572bc9b (diff) | |
download | dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.tar dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.tar.gz dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.tar.bz2 dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.tar.lz dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.tar.xz dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.tar.zst dexon-sol-tools-3bdf6004ca74dd9eb380aa61cf9e69c47725116a.zip |
Start refactoring docs to remove unnecessary configs given more concise TypeDoc JSON
Diffstat (limited to 'packages/react-docs/src/components/type.tsx')
-rw-r--r-- | packages/react-docs/src/components/type.tsx | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 04fcd9998..3504be303 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -9,6 +9,7 @@ import { DocsInfo } from '../docs_info'; import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types'; import { Signature } from './signature'; +import { constants } from '../utils/constants'; import { TypeDefinition } from './type_definition'; export interface TypeProps { @@ -43,7 +44,7 @@ export function Type(props: TypeProps): any { <span> <Type key={key} - type={arg.elementType} + type={arg} sectionName={props.sectionName} typeDefinitionByName={props.typeDefinitionByName} docsInfo={props.docsInfo} @@ -142,7 +143,6 @@ export function Type(props: TypeProps): any { let typeNameUrlIfExists; let typePrefixIfExists; - let sectionNameIfExists; if (!_.isUndefined(props.docsInfo.typeConfigs)) { typeNameUrlIfExists = !_.isUndefined(props.docsInfo.typeConfigs.typeNameToExternalLink) ? props.docsInfo.typeConfigs.typeNameToExternalLink[typeName as string] @@ -150,9 +150,6 @@ export function Type(props: TypeProps): any { typePrefixIfExists = !_.isUndefined(props.docsInfo.typeConfigs.typeNameToPrefix) ? props.docsInfo.typeConfigs.typeNameToPrefix[typeName as string] : undefined; - sectionNameIfExists = !_.isUndefined(props.docsInfo.typeConfigs.typeNameToDocSection) - ? props.docsInfo.typeConfigs.typeNameToDocSection[typeName as string] - : undefined; } if (!_.isUndefined(typeNameUrlIfExists)) { typeName = ( @@ -168,16 +165,12 @@ export function Type(props: TypeProps): any { ); } else if ( (isReference || isArray) && - (props.docsInfo.isPublicType(typeName as string) || !_.isUndefined(sectionNameIfExists)) + props.typeDefinitionByName && + props.typeDefinitionByName[typeName as string] ) { const id = Math.random().toString(); - const typeDefinitionAnchorId = _.isUndefined(sectionNameIfExists) - ? `${props.sectionName}-${typeName}` - : sectionNameIfExists; - let typeDefinition; - if (props.typeDefinitionByName) { - typeDefinition = props.typeDefinitionByName[typeName as string]; - } + const typeDefinitionAnchorId = `${constants.TYPES_SECTION_NAME}-${typeName}`; + let typeDefinition = props.typeDefinitionByName[typeName as string]; typeName = ( <ScrollLink to={typeDefinitionAnchorId} @@ -186,18 +179,12 @@ export function Type(props: TypeProps): any { duration={sharedConstants.DOCS_SCROLL_DURATION_MS} containerId={sharedConstants.DOCS_CONTAINER_ID} > - {_.isUndefined(typeDefinition) || sharedUtils.isUserOnMobile() ? ( - <span - onClick={sharedUtils.setUrlHash.bind(null, typeDefinitionAnchorId)} - style={{ color: colors.lightBlueA700, cursor: 'pointer' }} - > - {typeName} - </span> + {sharedUtils.isUserOnMobile() ? ( + <span style={{ color: colors.lightBlueA700, cursor: 'pointer' }}>{typeName}</span> ) : ( <span data-tip={true} data-for={id} - onClick={sharedUtils.setUrlHash.bind(null, typeDefinitionAnchorId)} style={{ color: colors.lightBlueA700, cursor: 'pointer', |