generated from uclaacm/teach-la-ts-react-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Added CodeBlock Component Using Syntax Highlighter (#241)
* Using SyntaxHighlighter package * Added CodeBlock Component
- Loading branch information
Showing
6 changed files
with
81 additions
and
148 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
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
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,29 @@ | ||
import SyntaxHighlighter from 'react-syntax-highlighter/dist/esm/default-highlight'; | ||
import { atomOneLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'; | ||
|
||
interface CodeBlockProps { | ||
code: string; | ||
language: string; | ||
} | ||
|
||
const customStyle = { | ||
lineHeight: '1.5', | ||
fontSize: '1rem', | ||
}; | ||
|
||
const CodeBlock = (props: CodeBlockProps): JSX.Element => { | ||
return ( | ||
<div> | ||
<SyntaxHighlighter | ||
language={props.language} | ||
showLineNumbers={false} | ||
style={atomOneLight} | ||
customStyle={customStyle} | ||
> | ||
{props.code} | ||
</SyntaxHighlighter> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CodeBlock; |
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.