'use client' import { useState, useEffect } from 'react' import { cn, getInitials } from '@/lib/utils' import { ClipboardList } from 'lucide-react' import { Dialog, DialogContent, DialogTitle, } from '@/components/ui/dialog' import { VisuallyHidden } from '@radix-ui/react-visually-hidden' type ProjectLogoProps = { project: { title: string logoKey?: string | null } logoUrl?: string | null size?: 'sm' | 'md' | 'lg' fallback?: 'icon' | 'initials' className?: string /** When true, clicking the logo opens a lightbox */ clickToEnlarge?: boolean } const sizeClasses = { sm: 'h-8 w-8', md: 'h-10 w-10', lg: 'h-16 w-16', } const iconSizeClasses = { sm: 'h-4 w-4', md: 'h-5 w-5', lg: 'h-8 w-8', } const textSizeClasses = { sm: 'text-xs', md: 'text-sm', lg: 'text-lg', } export function ProjectLogo({ project, logoUrl, size = 'md', fallback = 'icon', className, clickToEnlarge, }: ProjectLogoProps) { const [imageError, setImageError] = useState(false) const [lightboxOpen, setLightboxOpen] = useState(false) const initials = getInitials(project.title) // Reset error state when logoUrl changes useEffect(() => { setImageError(false) }, [logoUrl]) const showImage = logoUrl && !imageError const canEnlarge = clickToEnlarge && showImage const logoElement = showImage ? (
setLightboxOpen(true) : undefined} > {`${project.title} setImageError(true)} />
) : (
{fallback === 'icon' ? ( ) : ( {initials} )}
) return ( <> {logoElement} {canEnlarge && ( {project.title} logo {`${project.title} )} ) }