Files
cidwa-components/src/components/docs/code-block.tsx
T

21 lines
653 B
TypeScript
Raw Normal View History

2025-03-22 18:08:10 -05:00
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism';
2025-03-22 14:25:11 -06:00
export const CodeBlock = ({ code }: { code: string }) => (
<div className="position-relative">
2025-03-22 18:08:10 -05:00
<SyntaxHighlighter
language="tsx"
style={vscDarkPlus}
customStyle={{ margin: 0, padding: '1rem', borderRadius: '0.5rem' }}
>
{code}
</SyntaxHighlighter>
2025-03-22 14:25:11 -06:00
<button
className="btn btn-sm btn-light position-absolute top-0 end-0 m-2"
onClick={() => navigator.clipboard.writeText(code)}
>
2025-03-22 18:08:10 -05:00
<i className="bi bi-clipboard"></i>
2025-03-22 14:25:11 -06:00
</button>
</div>
);