Skip to content

Commit

Permalink
fix(docz): PropsTable component
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jun 15, 2018
1 parent cca862c commit 48638cc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/docz/src/components/PropsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ const extractTypeDescribedValue = (type: PropType): string => {

// oneOf, oneOfType
if (Array.isArray(value)) {
return value.map(valueType => {
if (valueType.name === 'custom') {
return `custom(${valueType.raw})`
}

const values = value.map(valueType => {
if (valueType.name === 'custom') return `custom(${valueType.raw})`
return valueType.name || valueType.value
}).join(' | ')
})

return values.join(' | ')
}

// arrayOf, objectOf
Expand Down Expand Up @@ -110,9 +109,7 @@ const getPropType = (prop: Prop, Tooltip?: TooltipComponent) => {
return prop.flowType ? (
<Tooltip text={prop.flowType.raw}>{name}</Tooltip>
) : (
<Tooltip text={extractTypeDescribedValue(prop.type)}>
{name}
</Tooltip>
<Tooltip text={extractTypeDescribedValue(prop.type)}>{name}</Tooltip>
)
}

Expand Down Expand Up @@ -158,7 +155,8 @@ export const PropsTable: SFC<PropsTable> = ({ of: component, components }) => {
<Td>{getPropType(prop, Tooltip)}</Td>
<Td>{String(prop.required)}</Td>
<Td>
{prop.defaultValue && getValue(prop.defaultValue.value)}
{prop.defaultValue &&
prop.defaultValue.value.replace(/\'/g, '')}
</Td>
<Td>{prop.description && prop.description}</Td>
</Tr>
Expand Down

0 comments on commit 48638cc

Please sign in to comment.