1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-10-23 18:56:29 +02:00
Files
csslayout/client/components/SampleCode.tsx
2019-11-29 10:17:41 +07:00

28 lines
708 B
TypeScript

import React from 'react';
import highlight from '../helpers/highlight';
interface SampleCodeProps {
code: string;
fullHeight?: boolean;
lang: string;
}
const SampleCode: React.FC<SampleCodeProps> = ({ code, fullHeight = false, lang }) => {
return code === ''
? <></>
: (
<pre
className="hljs"
style={{
height: fullHeight ? '100%' : 'auto',
lineHeight: 1.5,
margin: 0,
}}
dangerouslySetInnerHTML={{ __html: highlight(code, lang) }}
/>
);
};
export default SampleCode;