Skip to content

Commit

Permalink
feat(docz): render [Empty String] on PropsTable (#427)
Browse files Browse the repository at this point in the history
* Updates the PropsTable to render '[Empty String]' instead of nothing.
* Add the code to print [No Default]
  • Loading branch information
Jared-Dev authored and pedronauck committed Oct 30, 2018
1 parent 475eb52 commit 2a9db98
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/docz/src/components/PropsTable.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -115,12 +116,11 @@ const BasePropsTable: SFC<PropsTable> = ({ 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'
Expand All @@ -138,7 +138,7 @@ const BasePropsTable: SFC<PropsTable> = ({ of: component, components }) => {
<Th className="PropsTable--type">Type</Th>
<Th className="PropsTable--required">Required</Th>
<Th className="PropsTable--default">Default</Th>
{includeDescription && (
{hasDescription && (
<Th width="40%" className="PropsTable--description">
Description
</Th>
Expand Down Expand Up @@ -170,7 +170,7 @@ const BasePropsTable: SFC<PropsTable> = ({ of: component, components }) => {
)}
</Td>
)}
{includeDescription && (
{hasDescription && (
<Td>{prop.description && prop.description}</Td>
)}
</Tr>
Expand Down

0 comments on commit 2a9db98

Please sign in to comment.