'use client' // import { NpmCommands } from 'types/unist' // import { Event, trackEvent } from '@/lib/events' import { Check, Copy } from 'lucide-react' import * as React from 'react' import { Button, cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, DropdownMenuTriggerProps, } from 'ui' interface CopyButtonProps extends React.HTMLAttributes { value: string src?: string // event?: Event['name'] } export async function copyToClipboardWithMeta( value: string // event?: Event ) { navigator.clipboard.writeText(value) if (event) { // trackEvent(event) } } export function CopyButton({ value, className, src, // event, ...props }: CopyButtonProps) { const [hasCopied, setHasCopied] = React.useState(false) React.useEffect(() => { setTimeout(() => { setHasCopied(false) }, 2000) }, [hasCopied]) return ( ) } interface CopyWithClassNamesProps extends DropdownMenuTriggerProps { value: string classNames: string className?: string } export function CopyWithClassNames({ value, classNames, className, ...props }: CopyWithClassNamesProps) { const [hasCopied, setHasCopied] = React.useState(false) React.useEffect(() => { setTimeout(() => { setHasCopied(false) }, 2000) }, [hasCopied]) const copyToClipboard = React.useCallback((value: string) => { copyToClipboardWithMeta(value) setHasCopied(true) }, []) return ( copyToClipboard(value)}>Component copyToClipboard(classNames)}>Classname ) } interface CopyNpmCommandButtonProps extends DropdownMenuTriggerProps { // commands: Required } // export function CopyNpmCommandButton({ commands, className, ...props }: CopyNpmCommandButtonProps) { // const [hasCopied, setHasCopied] = React.useState(false) // React.useEffect(() => { // setTimeout(() => { // setHasCopied(false) // }, 2000) // }, [hasCopied]) // // const copyCommand = React.useCallback((value: string, pm: 'npm' | 'pnpm' | 'yarn' | 'bun') => { // // copyToClipboardWithMeta(value, // // // { // // // name: 'copy_npm_command', // // // properties: { // // // command: value, // // // pm, // // // }, // // }) // // setHasCopied(true) // // }, []) // return ( // // // // // // copyCommand(commands.__npmCommand__, 'npm')}> // npm // // copyCommand(commands.__yarnCommand__, 'yarn')}> // yarn // // copyCommand(commands.__pnpmCommand__, 'pnpm')}> // pnpm // // copyCommand(commands.__bunCommand__, 'bun')}> // bun // // // // ) // }