Skip to content

Commit

Permalink
feat: Add number and string components for code def
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 16, 2020
1 parent 361a71f commit b0ecdfc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/CodeDef/CodeDef.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import Bracket from './Bracket';
import Comment from './Comment';
import Identifier from './Identifier';
import Keyword from './Keyword';
import NumberValue from './Number';
import Operator from './Operator';
import StringValue from './String';
import Type from './Type';

const CodeDef = ({ className, children }) => (
Expand All @@ -24,7 +26,9 @@ CodeDef.Bracket = Bracket;
CodeDef.Comment = Comment;
CodeDef.Keyword = Keyword;
CodeDef.Identifier = Identifier;
CodeDef.Number = NumberValue;
CodeDef.Operator = Operator;
CodeDef.String = StringValue;
CodeDef.Type = Type;

export default CodeDef;
8 changes: 8 additions & 0 deletions src/components/CodeDef/CodeDef.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@
.block {
margin-left: 1rem;
}

.string {
color: var(--color-green-500);
}

.number {
color: var(--color-red-400);
}
13 changes: 13 additions & 0 deletions src/components/CodeDef/Number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import styles from './CodeDef.module.scss';

const NumberValue = ({ value }) => (
<span className={styles.number}>{value}</span>
);

NumberValue.propTypes = {
value: PropTypes.number.isRequired,
};

export default NumberValue;
13 changes: 13 additions & 0 deletions src/components/CodeDef/String.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import styles from './CodeDef.module.scss';

const StringValue = ({ value }) => (
<span className={styles.string}>"{value}"</span>
);

StringValue.propTypes = {
value: PropTypes.string.isRequired,
};

export default StringValue;

0 comments on commit b0ecdfc

Please sign in to comment.