diff options
author | Fabio Berger <me@fabioberger.com> | 2018-10-05 01:59:55 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-10-05 01:59:55 +0800 |
commit | 3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e (patch) | |
tree | 87bda5d41b34973960ec230dfb9320e54aea6588 /packages/react-docs/src/components/signature_block.tsx | |
parent | e7ab9938ce5bde17600130584fc75bc8a45f6dc5 (diff) | |
parent | 2da7626b5356f7b0ec809719f1b9da14b2969a07 (diff) | |
download | dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.gz dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.bz2 dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.lz dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.xz dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.zst dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.zip |
merge developmemnt
Diffstat (limited to 'packages/react-docs/src/components/signature_block.tsx')
-rw-r--r-- | packages/react-docs/src/components/signature_block.tsx | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index 1ea0ea28c..5ec82983a 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -32,7 +32,6 @@ export interface SignatureBlockState { const styles: Styles = { chip: { fontSize: 13, - backgroundColor: colors.lightBlueA700, color: colors.white, height: 11, borderRadius: 14, @@ -50,6 +49,8 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu public render(): React.ReactNode { const method = this.props.method; + const isFallback = (method as SolidityMethod).isFallback; + const hasExclusivelyNamedParams = !_.isUndefined(_.find(method.parameters, p => !_.isEmpty(p.name))); return ( <div id={`${this.props.sectionName}-${method.name}`} @@ -63,10 +64,11 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu {(method as TypescriptMethod).isStatic && this._renderChip('Static')} {(method as SolidityMethod).isConstant && this._renderChip('Constant')} {(method as SolidityMethod).isPayable && this._renderChip('Payable')} + {isFallback && this._renderChip('Fallback', colors.lightGreenA700)} <div style={{ lineHeight: 1.3 }}> <AnchorTitle headerSize={HeaderSizes.H3} - title={method.name} + title={isFallback ? '' : method.name} id={`${this.props.sectionName}-${method.name}`} shouldShowAnchor={this.state.shouldShowAnchor} /> @@ -84,6 +86,7 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu typeDefinitionByName={this.props.typeDefinitionByName} docsInfo={this.props.docsInfo} isInPopover={false} + isFallback={isFallback} /> </code> {(method as TypescriptMethod).source && ( @@ -95,12 +98,13 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu )} {method.comment && <Comment comment={method.comment} className="py2" />} {method.parameters && - !_.isEmpty(method.parameters) && ( + !_.isEmpty(method.parameters) && + hasExclusivelyNamedParams && ( <div> <h4 className="pb1 thin" style={{ borderBottom: '1px solid #e1e8ed' }}> ARGUMENTS </h4> - {this._renderParameterDescriptions(method.parameters)} + {this._renderParameterDescriptions(method.parameters, method.name)} </div> )} {method.returnComment && ( @@ -114,19 +118,19 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu </div> ); } - private _renderChip(text: string): React.ReactNode { + private _renderChip(text: string, backgroundColor: string = colors.lightBlueA700): React.ReactNode { return ( - <div className="p1 mr1" style={styles.chip}> + <div className="p1 mr1" style={{ ...styles.chip, backgroundColor }}> {text} </div> ); } - private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode { - const descriptions = _.map(parameters, parameter => { + private _renderParameterDescriptions(parameters: Parameter[], name: string): React.ReactNode { + const descriptions = _.map(parameters, (parameter: Parameter, i: number) => { const isOptional = parameter.isOptional; return ( <div - key={`param-description-${parameter.name}`} + key={`param-description-${parameter.name}-${name}-${i}`} className="flex pb1 mb2" style={{ borderBottom: '1px solid #f0f4f7' }} > |