mirror of
https://github.com/chartdb/chartdb.git
synced 2025-11-06 06:53:34 +00:00
36 lines
930 B
TypeScript
36 lines
930 B
TypeScript
import { cn } from '@/lib/utils';
|
|
import React from 'react';
|
|
import { CopyBlock, atomOneDark } from 'react-code-blocks';
|
|
import type { CodeBlockProps } from 'react-code-blocks/dist/components/CodeBlock';
|
|
|
|
export interface CodeSnippetProps {
|
|
className?: string;
|
|
codeProps?: CodeBlockProps;
|
|
code: string;
|
|
language?: 'sql' | 'bash';
|
|
}
|
|
|
|
export const CodeSnippet: React.FC<CodeSnippetProps> = ({
|
|
className,
|
|
codeProps,
|
|
code,
|
|
language = 'sql',
|
|
}) => {
|
|
return (
|
|
<div className={cn('flex flex-1', className)}>
|
|
<CopyBlock
|
|
language={language}
|
|
text={code}
|
|
theme={atomOneDark}
|
|
customStyle={{
|
|
display: 'flex',
|
|
flex: '1',
|
|
fontSize: '14px',
|
|
width: '100%',
|
|
}}
|
|
{...codeProps}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|