Skip to content

Commit a8df9d4

Browse files
authored
feat: adds syntax highlighting to a11y demo (#836)
Signed-off-by: Anthony D. Mays <[email protected]>
1 parent 7f1e43b commit a8df9d4

File tree

4 files changed

+398
-126
lines changed

4 files changed

+398
-126
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use client';
2+
3+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
4+
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
5+
6+
interface CodeBlockProps {
7+
code: string;
8+
language?: 'tsx' | 'jsx' | 'html' | 'css' | 'javascript' | 'typescript';
9+
}
10+
11+
export function CodeBlock({ code, language = 'tsx' }: CodeBlockProps) {
12+
return (
13+
<div className="mt-4">
14+
<SyntaxHighlighter
15+
language={language}
16+
style={vscDarkPlus}
17+
customStyle={{
18+
margin: 0,
19+
borderRadius: '0.375rem',
20+
fontSize: '0.75rem',
21+
lineHeight: '1rem',
22+
}}
23+
codeTagProps={{
24+
style: {
25+
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',
26+
},
27+
}}
28+
>
29+
{code}
30+
</SyntaxHighlighter>
31+
</div>
32+
);
33+
}

0 commit comments

Comments
 (0)