From 2a9db98814b4036c642ec08eead0380e194bbef1 Mon Sep 17 00:00:00 2001 From: Jared Malcolm <1476753+InquisitiveDevelopment@users.noreply.github.com> Date: Sat, 27 Oct 2018 06:53:43 -0700 Subject: [PATCH] feat(docz): render [Empty String] on PropsTable (#427) * Updates the PropsTable to render '[Empty String]' instead of nothing. * Add the code to print [No Default] --- packages/docz/src/components/PropsTable.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/docz/src/components/PropsTable.tsx b/packages/docz/src/components/PropsTable.tsx index 65f0079d9..2437b0cd5 100644 --- a/packages/docz/src/components/PropsTable.tsx +++ b/packages/docz/src/components/PropsTable.tsx @@ -1,6 +1,7 @@ import * as React from 'react' import { CSSProperties, Fragment, SFC, ComponentType } from 'react' import { withMDXComponents } from '@mdx-js/tag/dist/mdx-provider' +import { get } from 'lodash/fp' import capitalize from 'capitalize' import { humanize } from '../utils/humanize-prop' @@ -115,12 +116,11 @@ const BasePropsTable: SFC = ({ of: component, components }) => { return null } - const includeDescription: boolean = Object.keys(props).some( - (name: string) => - props[name] && - typeof props[name].description !== 'undefined' && - props[name].description !== '' - ) + const hasDescription = Object.keys(props).some((name: string) => { + const description = get(`${name}.description`, props) + return Boolean(description) && Boolean(get('length', description)) + }) + const Table = components.table || 'table' const Thead = components.thead || 'thead' const Tr = components.tr || 'tr' @@ -138,7 +138,7 @@ const BasePropsTable: SFC = ({ of: component, components }) => { Type Required Default - {includeDescription && ( + {hasDescription && ( Description @@ -170,7 +170,7 @@ const BasePropsTable: SFC = ({ of: component, components }) => { )} )} - {includeDescription && ( + {hasDescription && ( {prop.description && prop.description} )}