add typecheck script and fix TypeScript errors (#48)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-01-04 17:11:53 -05:00
1 parent e853660ad3
commit ed4bc17987
14 files changed
+371 -137

No files matched your search

+32 -8
View File
@@ -1,17 +1,32 @@
import { Copy } from 'lucide-react'
import { useState } from 'react'
import { Copy, Check } from 'lucide-react'
import { cn } from '@/lib/utils'
interface CopyButtonProps {
content: string
title: string
title?: string
className?: string
iconSize?: 'sm' | 'md'
variant?: 'default' | 'ghost'
}
export function CopyButton({ content, title, className = "" }: CopyButtonProps) {
export function CopyButton({
content,
title = 'Copy',
className = '',
iconSize = 'md',
variant = 'default'
}: CopyButtonProps) {
const [copied, setCopied] = useState(false)
const handleCopy = async () => {
if (!content.trim()) return
try {
await navigator.clipboard.writeText(content)
} catch (error) {
console.error('Failed to copy content:', error)
setCopied(true)
setTimeout(() => setCopied(false), 2000)
} catch {
// Clipboard access denied or not supported
}
}
@@ -19,13 +34,22 @@ export function CopyButton({ content, title, className = "" }: CopyButtonProps)
return null
}
const sizeClasses = iconSize === 'sm' ? 'w-3.5 h-3.5' : 'w-4 h-4'
const variantClasses = variant === 'ghost'
? 'p-1 hover:bg-accent rounded'
: 'p-1.5 rounded bg-card hover:bg-card-hover text-muted-foreground hover:text-foreground'
return (
<button
onClick={handleCopy}
className={`p-1.5 rounded bg-card hover:bg-card-hover text-muted-foreground hover:text-foreground ${className}`}
title={title}
className={cn(variantClasses, className)}
title={copied ? 'Copied!' : title}
>
<Copy className="w-4 h-4" />
{copied ? (
<Check className={cn(sizeClasses, 'text-green-500')} />
) : (
<Copy className={cn(sizeClasses, copied && 'text-green-500')} />
)}
</button>
)
}