import { forwardRef } from 'react'; import { twMerge } from 'tailwind-merge'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import { atomDark } from 'react-syntax-highlighter/dist/cjs/styles/prism'; import { IconButton } from './IconButton'; import { useTemporaryState } from '../hooks/useTemporaryState'; import { Check } from '../icons/Check'; import { Copy2 } from '../icons/Copy2'; import type { ComponentPropsWithoutRef, ElementRef } from 'react'; import type { SyntaxHighlighterProps } from 'react-syntax-highlighter'; export type RootProps = ComponentPropsWithoutRef<'div'>; export const Root = forwardRef(function Root({ className, ...other }, forwardedRef) { return
; }); export type HeaderProps = ComponentPropsWithoutRef<'div'> & { copyText: string; }; export const Header = forwardRef(function Header( { children, className, copyText, ...other }, forwardedRef, ) { const [clicked, setClicked] = useTemporaryState(false, 2000); return (
{children}
{!clicked ? ( { navigator.clipboard.writeText(copyText); setClicked(true); }} > ) : (
Copied
)}
); }); export type ContentProps = SyntaxHighlighterProps & {}; export const Content = forwardRef, ContentProps>(function Content( { customStyle = {}, codeTagProps, language = 'bash', style = atomDark, ...other }, forwardedRef, ) { const { style: codeTagStyle = {}, ...otherCodeTagProps } = codeTagProps || {}; return ( ); });