Skip to content

Commit

Permalink
Fix: Do not render an empty props table for TypeScript projects (#1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy Bradford authored and sapegin committed Oct 3, 2018
1 parent b6bbf80 commit ee5c664
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/rsg-components/Pathline/PathlineRenderer.js
Expand Up @@ -10,7 +10,7 @@ export const styles = ({ space, fontFamily, fontSize, color }) => ({
fontFamily: fontFamily.monospace,
fontSize: fontSize.small,
color: color.light,
wordBreak: 'break-all'
wordBreak: 'break-all',
},
copyButton: {
marginLeft: space[0],
Expand Down
5 changes: 3 additions & 2 deletions src/rsg-components/Usage/Usage.js
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types';
import Props from 'rsg-components/Props';
import Methods from 'rsg-components/Methods';
import isEmpty from 'lodash/isEmpty';

export default function Usage({ props: { props, methods } }) {
const propsNode = props && <Props props={props} />;
const methodsNode = methods && methods.length > 0 && <Methods methods={methods} />;
const propsNode = !isEmpty(props) && <Props props={props} />;
const methodsNode = !isEmpty(methods) && <Methods methods={methods} />;

if (!propsNode && !methodsNode) {
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/rsg-components/slots/UsageTabButton.js
@@ -1,10 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import TabButton from 'rsg-components/TabButton';
import isEmpty from 'lodash/isEmpty';

const UsageTabButton = props => {
const component = props.props;
const showButton = component.props || (component.methods && component.methods.length > 0);
const showButton = !isEmpty(component.props) || !isEmpty(component.methods);
return showButton ? <TabButton {...props}>Props & methods</TabButton> : null;
};

Expand Down

0 comments on commit ee5c664

Please sign in to comment.