# Thumbnail Preview Feature - Admin Pages ## Overview Added hover-to-preview functionality for thumbnail images in admin tables. Now when you hover over a small thumbnail in Articles, Activities, or Players admin pages, a larger preview pops up automatically. ## Component ### ThumbnailPreview Location: `frontend/src/components/common/ThumbnailPreview.tsx` A lightweight component that shows a small thumbnail with a popover preview on hover. **Features:** - πŸ“Έ Small thumbnail in table (default 48Γ—48px) - πŸ” Hover to see larger preview (default 300px wide, max 400px high) - ⚑ Quick preview without clicking - 🎨 Respects color mode (light/dark) - πŸš€ Lazy loading for performance - ⏱️ 200ms delay before showing preview (prevents accidental popups) ## Usage ### Basic Example ```tsx import ThumbnailPreview from '../../components/common/ThumbnailPreview'; ``` ### Props ```typescript interface ThumbnailPreviewProps { src: string; // Image URL (required) alt: string; // Alt text (required) size?: string; // Thumbnail size (default: '48px') previewSize?: string; // Preview popup width (default: '300px') borderRadius?: string; // Border radius (default: 'md') objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down'; // How to fit image (default: 'cover') } ``` ## Integrated Pages ### 1. Articles Admin Page Location: `frontend/src/pages/admin/ArticlesAdminPage.tsx` **Before:** - Static 48Γ—48px thumbnails - No way to preview images without opening edit modal **After:** - Hover over thumbnail β†’ See 350Γ—400px preview - Quick visual identification of articles - No clicking required **Implementation:** ```tsx ``` ### 2. Activities Admin Page Location: `frontend/src/pages/admin/AdminActivitiesPage.tsx` **New Feature:** - Added "NΓ‘hled" (Preview) column to the table - Shows event cover images - Fallback to club logo if no image set (with 30% opacity) **Before:** - No image column in the table - Couldn't see which events have images **After:** - Visual preview column - Hover for larger view - Easy to identify events with/without images **Implementation:** ```tsx {event.image_url ? ( ) : ( No image )} ``` ### 3. Players Admin Page Location: `frontend/src/pages/admin/PlayersAdminPage.tsx` **Before:** - Static 48Γ—48px player photos - No hover preview **After:** - Hover over photo β†’ See 300Γ—400px preview - Better identification of players - Rounded corners match player photo aesthetic **Implementation:** ```tsx ``` ## User Experience ### Interaction Flow 1. **Hover** over thumbnail (mouse over) 2. **Wait** 200ms (prevents accidental triggers) 3. **Preview** appears to the right of thumbnail 4. **Move away** β†’ Preview closes after 100ms ### Visual Feedback - Thumbnail scales up 5% on hover - Box shadow appears on hover - Smooth transitions (0.2s) - Cursor changes to pointer ### Performance - Lazy loading on thumbnails - Preview image only loads when needed - Minimal re-renders - Portal-based rendering (no z-index issues) ## Benefits ### For Admins βœ… **Faster workflow** - No need to click to see images βœ… **Visual identification** - Quickly spot articles/events by cover image βœ… **Quality check** - Verify image quality without opening editor βœ… **Better overview** - See which content has images ### For Content Management βœ… **Image audit** - Easily see which articles need images βœ… **Consistency check** - Spot images that don't match style βœ… **Quick decisions** - Choose articles to feature based on visuals ## Technical Details ### Popover Configuration ```tsx ``` ### Portal Rendering The preview uses `` to render at the root level, preventing: - Z-index conflicts - Overflow clipping - Parent container constraints ### Responsive Behavior - Preview max height: 400px - Preview adapts to available space - Falls back to browser default if no space to the right ## Browser Compatibility | Feature | Chrome | Firefox | Safari | Edge | |---------|--------|---------|--------|------| | Hover trigger | βœ… | βœ… | βœ… | βœ… | | Popover | βœ… | βœ… | βœ… | βœ… | | Lazy loading | βœ… | βœ… | βœ… | βœ… | | Portal | βœ… | βœ… | βœ… | βœ… | ## Mobile Behavior On touch devices: - Hover is triggered by tap - Preview stays visible until user taps elsewhere - First tap = preview - Second tap = navigate/edit (if thumbnail is a link) ## Customization Examples ### Larger Preview ```tsx ``` ### Square Fit (for logos) ```tsx ``` ### Circular Thumbnail ```tsx ``` ## Related Components - **FilePreview** (`FilePreview.tsx`) - Full file preview with modal for attachments - **Image Upload** - Various image upload components in admin pages - **AlbumPhotoPicker** - Zonerama gallery picker ## Future Enhancements Potential improvements: 1. **Zoom controls** - Add +/- buttons in preview 2. **Multiple images** - Show gallery of images if multiple 3. **Image info** - Display dimensions, file size 4. **Edit quick action** - Add "Edit" button in preview 5. **Keyboard navigation** - Arrow keys to navigate between previews 6. **Full-screen mode** - Click to open full-screen view 7. **Crop preview** - Show how image will be cropped 8. **Compare mode** - Side-by-side comparison of OG image ## Dependencies - `@chakra-ui/react` - UI components (Popover, Portal, Image) - React - Core functionality ## Files Modified 1. `frontend/src/components/common/ThumbnailPreview.tsx` (NEW) 2. `frontend/src/pages/admin/ArticlesAdminPage.tsx` (UPDATED) 3. `frontend/src/pages/admin/AdminActivitiesPage.tsx` (UPDATED) 4. `frontend/src/pages/admin/PlayersAdminPage.tsx` (UPDATED) ## Testing Checklist - [ ] Hover over article thumbnail - preview appears - [ ] Hover over activity thumbnail - preview appears - [ ] Hover over player photo - preview appears - [ ] Preview shows correct image - [ ] Preview closes when mouse leaves - [ ] Delay prevents accidental triggers - [ ] Preview doesn't get cut off by container - [ ] Dark mode colors look correct - [ ] Fallback images work (no image set) - [ ] Lazy loading works (check network tab) - [ ] Mobile tap behavior works - [ ] No console errors