Skip to content

Commit

Permalink
feat: Update ConstantReference to use CodeDef
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 16, 2020
1 parent 720e4c1 commit 361a71f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
20 changes: 12 additions & 8 deletions src/components/ConstantReference.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
import React from 'react';
import Markdown from 'react-markdown';
import PropTypes from 'prop-types';
import CodeDef from './CodeDef';
import styles from './ConstantReference.module.scss';

const ConstantReference = ({ constant }) => {
const { name, values, type } = constant;

return (
<div className={styles.container}>
<div className={styles.name}>{name}</div>
<div>{type === 'array' ? '[' : '{'}</div>
<div className={styles.constantContainer}>
<CodeDef className={styles.container}>
<h3 className={styles.name}>
<code>{name}</code>
</h3>
<CodeDef.Bracket>{type === 'array' ? '[' : '{'}</CodeDef.Bracket>
<CodeDef.Block>
{values.map((value, i) => (
<Markdown key={i} source={value} />
))}
</div>
<div>{type === 'array' ? ']' : '}'}</div>
</div>
</CodeDef.Block>
<CodeDef.Bracket>{type === 'array' ? ']' : '}'}</CodeDef.Bracket>
</CodeDef>
);
};

ConstantReference.propTypes = {
constant: PropTypes.shape({
type: PropTypes.string,
name: PropTypes.string,
values: PropTypes.array,
values: PropTypes.any,
}),
};

Expand Down
14 changes: 5 additions & 9 deletions src/components/ConstantReference.module.scss
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
.container {
color: var(--color-neutrals-500);
font-family: var(--code-font);
font-size: 0.875rem;
line-height: 1.5;
margin-top: 2rem;

&:not(:last-child) {
margin-bottom: 2rem;
}
}

.name {
font-size: 1rem;
font-family: var(--primary-font-family);
color: var(--color-neutrals-800);
font-weight: normal;
margin-bottom: 0.5rem;
}

.block {
margin-left: 0.5rem;
}

.constantContainer {
margin: 0 0 1rem 1.5rem;
}

0 comments on commit 361a71f

Please sign in to comment.