'use client' import { useEffect, useRef } from 'react' import { getVideoUrl } from '@/lib/utils' interface LightboxProps { isOpen: boolean onClose: () => void src: string alt: string type: 'image' | 'video' } export function Lightbox({ isOpen, onClose, src, alt, type }: LightboxProps) { const overlayRef = useRef(null) useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape') { onClose() } } const handleClickOutside = (event: MouseEvent) => { if (overlayRef.current && event.target === overlayRef.current) { onClose() } } if (isOpen) { document.addEventListener('keydown', handleKeyDown) document.addEventListener('click', handleClickOutside) document.body.style.overflow = 'hidden' } return () => { document.removeEventListener('keydown', handleKeyDown) document.removeEventListener('click', handleClickOutside) document.body.style.overflow = 'unset' } }, [isOpen, onClose]) if (!isOpen) return null return (
{type === 'image' ? ( {alt} ) : (
) }