-
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.
feat: add usage info for each component
- Loading branch information
1 parent
de44a6c
commit 430149f
Showing
3 changed files
with
47 additions
and
0 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,39 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Highlight, { defaultProps } from 'prism-react-renderer'; | ||
import github from 'prism-react-renderer/themes/github'; | ||
import styles from './InlineCodeSnippet.module.scss'; | ||
import cx from 'classnames'; | ||
|
||
const InlineCodeSnippet = ({ children, language }) => { | ||
return ( | ||
<Highlight | ||
{...defaultProps} | ||
theme={github} | ||
code={children} | ||
language={language} | ||
> | ||
{({ style, className, tokens, getLineProps, getTokenProps }) => ( | ||
<pre | ||
className={cx(styles.container, className)} | ||
style={{ ...style, background: 'none' }} | ||
> | ||
{tokens.map((line, i) => ( | ||
<div key={i} {...getLineProps({ line, key: i })}> | ||
{line.map((token, key) => ( | ||
<span key={key} {...getTokenProps({ token, key })} /> | ||
))} | ||
</div> | ||
))} | ||
</pre> | ||
)} | ||
</Highlight> | ||
); | ||
}; | ||
|
||
InlineCodeSnippet.propTypes = { | ||
children: PropTypes.node.isRequired, | ||
language: PropTypes.string, | ||
}; | ||
|
||
export default InlineCodeSnippet; |
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,3 @@ | ||
.container { | ||
margin: 0; | ||
} |
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