import React from 'react'; import { Download, Maximize2, Check, MessageSquare, Star, Heart } from 'lucide-react'; import { useInView } from 'react-intersection-observer'; import { useTheme } from '../../../contexts/ThemeContext'; import { AuthenticatedImage } from '../../common'; import type { BaseGalleryLayoutProps } from './BaseGalleryLayout'; import type { Photo } from '../../../types'; interface GridPhotoProps { photo: Photo; isSelected: boolean; isSelectionMode: boolean; onClick: (e: React.MouseEvent) => void; onDownload: (e: React.MouseEvent) => void; onToggleSelect: () => void; animationType?: string; allowDownloads?: boolean; slug?: string; protectionLevel?: 'basic' | 'standard' | 'enhanced' | 'maximum'; useEnhancedProtection?: boolean; feedbackEnabled?: boolean; } const GridPhoto: React.FC = ({ photo, isSelected, isSelectionMode, onClick, onDownload, onToggleSelect, animationType = 'fade', allowDownloads = true, slug, protectionLevel = 'standard', useEnhancedProtection = false, feedbackEnabled = false }) => { const { ref, inView } = useInView({ triggerOnce: true, threshold: 0.1, }); const animationClass = animationType === 'scale' ? 'transition-transform duration-300 hover:scale-105' : animationType === 'fade' ? 'transition-opacity duration-300' : ''; return (
{inView ? ( <> { console.warn(`Protection violation on grid photo ${photo.id}: ${violationType}`); }} />
{!isSelectionMode && ( <> {allowDownloads && ( )} )}
{/* Selection Checkbox (visible on hover or when selected) */} {/* Feedback Indicators */} {feedbackEnabled && (photo.comment_count > 0 || photo.average_rating > 0 || photo.like_count > 0) && (
{photo.comment_count > 0 && (
{photo.comment_count}
)} {photo.average_rating > 0 && (
{Number(photo.average_rating).toFixed(1)}
)} {photo.like_count > 0 && (
{photo.like_count}
)}
)} {photo.type === 'collage' && (
Collage
)} ) : (
)}
); }; export const GridGalleryLayout: React.FC = ({ photos, slug, onPhotoClick, onDownload, selectedPhotos = new Set(), isSelectionMode = false, onPhotoSelect, allowDownloads = true, protectionLevel = 'standard', useEnhancedProtection = false, feedbackEnabled = false }) => { const { theme } = useTheme(); const gallerySettings = theme.gallerySettings || {}; const columns = gallerySettings.gridColumns || { mobile: 2, tablet: 3, desktop: 4 }; const spacing = gallerySettings.spacing || 'normal'; const animation = gallerySettings.photoAnimation || 'fade'; const spacingClass = spacing === 'tight' ? 'gap-2' : spacing === 'relaxed' ? 'gap-6' : 'gap-4'; const gridClass = `grid ${spacingClass} grid-cols-${columns.mobile} sm:grid-cols-${columns.tablet} lg:grid-cols-${columns.desktop} xl:grid-cols-${columns.desktop + 1}`; return (
{photos.map((photo, index) => ( onPhotoClick(index)} onToggleSelect={() => onPhotoSelect && onPhotoSelect(photo.id)} onDownload={(e) => onDownload(photo, e)} animationType={animation} allowDownloads={allowDownloads} slug={slug} protectionLevel={protectionLevel} useEnhancedProtection={useEnhancedProtection} feedbackEnabled={feedbackEnabled} /> ))}
); };