mirror of
https://github.com/pure-css/pure.git
synced 2024-11-24 10:44:21 +00:00
19 lines
681 B
JavaScript
19 lines
681 B
JavaScript
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import SyntaxHighlighter from 'react-syntax-highlighter';
|
|
import { docco } from 'react-syntax-highlighter/dist/esm/styles/hljs';
|
|
|
|
function CodeBlock({ children, language = 'html', full = false, wrap = false }) {
|
|
var fullClass = classnames({ 'is-code-full': full });
|
|
var codeClass = classnames({ code: true, 'code-wrap': wrap });
|
|
return (
|
|
<div className={fullClass}>
|
|
<div className={codeClass}>
|
|
<SyntaxHighlighter language={language} style={docco} wrapLongLines={full}>{children}</SyntaxHighlighter>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default CodeBlock;
|