From 0d5fb69c1d089878f93f0da1ab3bcead424b0577 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Mon, 8 Jun 2020 14:37:59 -0700 Subject: [PATCH] feat: Add prop type examples for each component --- src/components/PropList.js | 5 +++++ src/utils/propTypeInfo.js | 1 + 2 files changed, 6 insertions(+) diff --git a/src/components/PropList.js b/src/components/PropList.js index 54cc17c0c..cb340b661 100644 --- a/src/components/PropList.js +++ b/src/components/PropList.js @@ -3,6 +3,7 @@ import cx from 'classnames'; import PropTypes from 'prop-types'; import FunctionDefinition from './FunctionDefinition'; import Markdown from 'react-markdown'; +import ReferenceExample from './ReferenceExample'; import styles from './PropList.module.scss'; import { format } from 'date-fns'; @@ -72,6 +73,7 @@ const PropList = ({ propTypes }) => { name, description, deprecation, + examples, isRequired, type, defaultValue, @@ -113,6 +115,9 @@ const PropList = ({ propTypes }) => { source={description} /> + {examples.map((example, idx) => ( + + ))} ); diff --git a/src/utils/propTypeInfo.js b/src/utils/propTypeInfo.js index 33e0adcf9..9303bd927 100644 --- a/src/utils/propTypeInfo.js +++ b/src/utils/propTypeInfo.js @@ -156,6 +156,7 @@ export const getPropTypeDefinition = (component, name, propType) => { description: propDocs?.text, deprecation: propDocs?.tags?.deprecated?.[0] ?? null, isRequired: propMeta?.some((item) => item.name === 'isRequired') ?? false, + examples: propDocs?.tags?.examples ?? [], type: { meta: getTypeMeta(name, propType, { component }), raw: getRawTypeName(propType),