import { BookOpenIcon } from 'lucide-react' import type { MouseEvent } from 'react' import { Button } from 'ui' import { ButtonTooltip } from '@/components/ui/ButtonTooltip' import { useTrack } from '@/lib/telemetry/track' interface DocsButtonProps { href: string abbrev?: boolean className?: string topic?: string /** Custom button text, e.g. to distinguish multiple docs buttons side by side. */ label?: string /** Shows only the book icon, with the label in a tooltip */ iconOnly?: boolean } export const DocsButton = ({ href, abbrev = true, className, topic, label, iconOnly = false, }: DocsButtonProps) => { const track = useTrack() const handleClick = (e: MouseEvent) => { e.stopPropagation() track('docs_button_clicked', { ...(topic && { topic }) }) } const text = label ?? (abbrev ? 'Docs' : 'Documentation') const topicLabel = topic ? `${topic} documentation (opens in new tab)` : undefined if (iconOnly) { return ( } onClick={handleClick} tooltip={{ content: { side: 'bottom', text } }} > ) } return ( ) }