'use client' import { RefObject, useState } from 'react' import { Button } from '../common/button' export function CopyButton({ copy, className, }: { copy: string | RefObject className?: string }) { const [copied, setCopied] = useState(false) const handleClick = () => { const code: string = typeof copy === 'string' ? copy : (copy.current?.innerText ?? '') navigator.clipboard.writeText(code) if (window.tlanalytics?.trackCopyCode) { window.tlanalytics.trackCopyCode({ page_category: 'docs', text_snippet: code, }) } setCopied(true) setTimeout(() => setCopied(false), 1500) } return (