Skip to content

Commit

Permalink
feat: Add prop type examples for each component
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 8, 2020
1 parent 521801f commit 0d5fb69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/PropList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -72,6 +73,7 @@ const PropList = ({ propTypes }) => {
name,
description,
deprecation,
examples,
isRequired,
type,
defaultValue,
Expand Down Expand Up @@ -113,6 +115,9 @@ const PropList = ({ propTypes }) => {
source={description}
/>
<PropTypeInfo type={type} />
{examples.map((example, idx) => (
<ReferenceExample key={idx} example={example} />
))}
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/utils/propTypeInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 0d5fb69

Please sign in to comment.