From 44b55ced5dcd922f3482394ac65adeb54ec56a97 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Mon, 8 Jun 2020 08:54:59 -0700 Subject: [PATCH] refactor: Move PropTypeInfo into PropList because of recursiveness --- src/components/PropList.js | 41 ++++++++++++++++++++++- src/components/PropList.module.scss | 10 ++++++ src/components/PropTypeInfo.js | 43 ------------------------- src/components/PropTypeInfo.module.scss | 9 ------ 4 files changed, 50 insertions(+), 53 deletions(-) delete mode 100644 src/components/PropTypeInfo.js delete mode 100644 src/components/PropTypeInfo.module.scss diff --git a/src/components/PropList.js b/src/components/PropList.js index 6aebca894..58b9473d4 100644 --- a/src/components/PropList.js +++ b/src/components/PropList.js @@ -1,11 +1,50 @@ import React from 'react'; import cx from 'classnames'; import PropTypes from 'prop-types'; -import PropTypeInfo from './PropTypeInfo'; +import FunctionDefinition from './FunctionDefinition'; import Markdown from 'react-markdown'; import styles from './PropList.module.scss'; import { format } from 'date-fns'; +const PropTypeInfo = ({ type }) => { + switch (type.raw) { + case 'func': + return ( + + ); + case 'oneOf': + return ( +
+
{' +
+ {type.meta.constants.map((constant) => ( +
{constant},
+ ))} +
+
{'>'}
+
+ ); + case 'oneOfType': + return type.meta.types.map((type, idx) => ( + + )); + case 'shape': + return
Shape
; + default: + return null; + } +}; + +PropTypeInfo.propTypes = { + type: PropTypes.shape({ + raw: PropTypes.string.isRequired, + meta: PropTypes.object, + }), +}; + const PropList = ({ propTypes }) => { if (propTypes.length === 0) { return

There are no props for this component.

; diff --git a/src/components/PropList.module.scss b/src/components/PropList.module.scss index 74a374199..710efc841 100644 --- a/src/components/PropList.module.scss +++ b/src/components/PropList.module.scss @@ -60,3 +60,13 @@ text-transform: uppercase; margin-left: 0.5rem; } + +.arg { + padding-left: 1rem; +} + +.listLike { + font-family: var(--code-font); + font-size: 0.875rem; + color: var(--color-neutrals-600); +} diff --git a/src/components/PropTypeInfo.js b/src/components/PropTypeInfo.js deleted file mode 100644 index c42f990db..000000000 --- a/src/components/PropTypeInfo.js +++ /dev/null @@ -1,43 +0,0 @@ -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) { - case 'func': - return ( - - ); - case 'oneOf': - return ( -
-
{' -
- {type.meta.constants.map((constant) => ( -
{constant},
- ))} -
-
{'>'}
-
- ); - case 'oneOfType': - return type.meta.types.map((type, idx) => ( - - )); - default: - return null; - } -}; - -PropTypeInfo.propTypes = { - type: PropTypes.shape({ - raw: PropTypes.string.isRequired, - meta: PropTypes.object, - }), -}; - -export default PropTypeInfo; diff --git a/src/components/PropTypeInfo.module.scss b/src/components/PropTypeInfo.module.scss deleted file mode 100644 index 5cd48a505..000000000 --- a/src/components/PropTypeInfo.module.scss +++ /dev/null @@ -1,9 +0,0 @@ -.arg { - padding-left: 1rem; -} - -.listLike { - font-family: var(--code-font); - font-size: 0.875rem; - color: var(--color-neutrals-600); -}