-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from newrelic/jerel/polish-component-docs
Polish component docs
- Loading branch information
Showing
39 changed files
with
651 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styles from './CodeDef.module.scss'; | ||
|
||
const Block = ({ children }) => <div className={styles.block}>{children}</div>; | ||
|
||
Block.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default Block; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Bracket = ({ children }) => ( | ||
<span className={styles.bracket}>{children}</span> | ||
); | ||
|
||
Bracket.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default Bracket; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import cx from 'classnames'; | ||
import styles from './CodeDef.module.scss'; | ||
import Block from './Block'; | ||
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 }) => ( | ||
<code className={cx(styles.container, className)}>{children}</code> | ||
); | ||
|
||
CodeDef.propTypes = { | ||
className: PropTypes.string, | ||
children: PropTypes.node, | ||
}; | ||
|
||
CodeDef.Block = Block; | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.container { | ||
display: block; | ||
line-height: 2; | ||
} | ||
|
||
.identifier { | ||
color: var(--color-neutrals-700); | ||
} | ||
|
||
.type { | ||
padding: 0.125rem; | ||
border-radius: 0.125rem; | ||
color: var(--color-green-500); | ||
background: var(--color-green-050); | ||
} | ||
|
||
.comment { | ||
color: var(--color-neutrals-500); | ||
|
||
> p { | ||
display: inline; | ||
} | ||
} | ||
|
||
.keyword, | ||
.bracket, | ||
.operator { | ||
color: var(--color-neutrals-600); | ||
} | ||
|
||
.block { | ||
margin-left: 1rem; | ||
} | ||
|
||
.string { | ||
color: var(--color-green-500); | ||
} | ||
|
||
.number { | ||
color: var(--color-red-400); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { Children } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Markdown from 'react-markdown'; | ||
import styles from './CodeDef.module.scss'; | ||
|
||
const Content = ({ children, ...props }) => { | ||
if (Children.toArray(children).length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<span {...props} className={styles.comment}> | ||
{`//`} {children} | ||
</span> | ||
); | ||
}; | ||
|
||
const renderers = { | ||
root: Content, | ||
}; | ||
|
||
const Comment = ({ text }) => <Markdown source={text} renderers={renderers} />; | ||
|
||
Content.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
Comment.propTypes = { | ||
text: PropTypes.string, | ||
}; | ||
|
||
export default Comment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Identifier = ({ children }) => ( | ||
<span className={styles.identifier}>{children}</span> | ||
); | ||
|
||
Identifier.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default Identifier; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Keyword = ({ children }) => ( | ||
<span className={styles.keyword}>{children}</span> | ||
); | ||
|
||
Keyword.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default Keyword; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Operator = ({ children }) => ( | ||
<span className={styles.operator}>{children}</span> | ||
); | ||
|
||
Operator.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default Operator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styles from './CodeDef.module.scss'; | ||
|
||
const Type = ({ children }) => <span className={styles.type}>{children}</span>; | ||
|
||
Type.propTypes = { | ||
children: PropTypes.node, | ||
}; | ||
|
||
export default Type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './CodeDef'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
.container { | ||
color: var(--color-neutrals-500); | ||
font-family: var(--code-font); | ||
color: var(--color-neutrals-600); | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.