Skip to content

Commit

Permalink
feat: Render union type info for union props
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 7, 2020
1 parent 918d6e0 commit 09d8a69
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/FunctionDefinition.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.container {
font-family: 'Menlo', 'Consolas', monospace;
font-family: var(--code-font);
font-size: 0.875rem;
line-height: 1.5;
}
Expand Down
13 changes: 13 additions & 0 deletions src/components/PropTypeInfo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import FunctionDefinition from './FunctionDefinition';
import styles from './PropTypeInfo.module.scss';

const PropTypeInfo = ({ type }) => {
switch (type.raw) {
Expand All @@ -11,6 +12,18 @@ const PropTypeInfo = ({ type }) => {
params={type.meta.params}
/>
);
case 'oneOf':
return (
<div className={styles.listLike}>
<div>{'<One of'}</div>
<div className={styles.arg}>
{type.meta.constants.map((constant) => (
<div key={constant}>{constant},</div>
))}
</div>
<div>{'>'}</div>
</div>
);
default:
return null;
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/PropTypeInfo.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.arg {
padding-left: 1rem;
}

.listLike {
font-family: var(--code-font);
font-size: 0.875rem;
color: var(--color-neutrals-600);
}
1 change: 1 addition & 0 deletions src/components/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
--primary-font-family: 'open sans', sans-serif;
--secondary-font-family: 'effra', sans-serif;
--tertiary-font-family: 'Ovo', serif;
--code-font: 'Menlo', 'Consolas', monospace;
}

/*-- Reset --*/
Expand Down

0 comments on commit 09d8a69

Please sign in to comment.