Skip to content

Commit

Permalink
feat: Create shell for PropTypeInfo component
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 6, 2020
1 parent 87d6b7d commit a26b994
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/PropList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import PropTypeInfo from './PropTypeInfo';
import ReactMarkdown from 'react-markdown';
import styles from './PropList.module.scss';

Expand Down Expand Up @@ -29,7 +30,13 @@ const PropList = ({ propTypes }) => {
</div>
)}
</div>
<ReactMarkdown className={styles.details} source={description} />
<div className={styles.propInfo}>
<ReactMarkdown
className={styles.details}
source={description}
/>
<PropTypeInfo type={type} />
</div>
</div>
);
}
Expand All @@ -45,6 +52,7 @@ PropList.propTypes = {
description: PropTypes.string,
isRequired: PropTypes.bool,
type: PropTypes.shape({
...PropTypeInfo.propTypes.type,
name: PropTypes.string.isRequired,
}),
defaultValue: PropTypes.string,
Expand Down
13 changes: 12 additions & 1 deletion src/components/PropList.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

.info {
width: 30%;

h3 {
margin-top: 0;
}
}

.default {
Expand All @@ -26,9 +30,16 @@
color: var(--color-neutrals-600);
}

.propInfo {
width: 70%;
}

.details {
font-size: 1.25rem;
width: 70%;

> *:first-child {
margin-top: 0;
}
}

.required {
Expand Down
19 changes: 19 additions & 0 deletions src/components/PropTypeInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';

const PropTypeInfo = ({ type }) => {
switch (type.name) {
case 'function':
return <div>func</div>;
default:
return null;
}
};

PropTypeInfo.propTypes = {
type: PropTypes.shape({
name: PropTypes.string.isRequired,
}),
};

export default PropTypeInfo;

0 comments on commit a26b994

Please sign in to comment.