"use client"; import { useState, useMemo } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { Search, Filter, Heart, Monitor, Palette, FileImage, Grid, LayoutGrid, X, ChevronDown, Eye } from "lucide-react"; // Mock data - In production, this would come from the API const mockArtworks = [ { id: "1", title: "Digital Dreams", artist: "Rahul K.", category: "digital-art", imageUrl: "https://images.unsplash.com/photo-1549490349-8643362247b5?w=600&h=600&fit=crop", department: "CSE", year: "3rd Year", }, { id: "2", title: "Ocean Serenity", artist: "Priya M.", category: "paintings", imageUrl: "https://images.unsplash.com/photo-1579783902614-a3fb3927b6a5?w=600&h=600&fit=crop", department: "ECE", year: "2nd Year", }, { id: "3", title: "Climate Action Now", artist: "Arun S.", category: "poster-making", imageUrl: "https://images.unsplash.com/photo-1561214115-f2f134cc4912?w=600&h=600&fit=crop", department: "ISE", year: "4th Year", }, { id: "4", title: "Neon Nights", artist: "Sneha R.", category: "digital-art", imageUrl: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=600&h=600&fit=crop", department: "CSE", year: "2nd Year", }, { id: "5", title: "Mountain Sunrise", artist: "Karthik V.", category: "paintings", imageUrl: "https://images.unsplash.com/photo-1460661419201-fd4cecdf8a8b?w=600&h=600&fit=crop", department: "ME", year: "3rd Year", }, { id: "6", title: "Tech Innovation", artist: "Divya N.", category: "poster-making", imageUrl: "https://images.unsplash.com/photo-1513364776144-60967b0f800f?w=600&h=600&fit=crop", department: "AIML", year: "2nd Year", }, { id: "7", title: "Abstract Emotions", artist: "Vijay K.", category: "digital-art", imageUrl: "https://images.unsplash.com/photo-1547826039-bfc35e0f1ea8?w=600&h=600&fit=crop", department: "CSE", year: "4th Year", }, { id: "8", title: "Sunset Reflections", artist: "Meera S.", category: "paintings", imageUrl: "https://images.unsplash.com/photo-1578926288207-a90a5366759d?w=600&h=600&fit=crop", department: "EEE", year: "3rd Year", }, { id: "9", title: "Save Our Planet", artist: "Nikhil B.", category: "poster-making", imageUrl: "https://images.unsplash.com/photo-1482160549825-59d1b23cb208?w=600&h=600&fit=crop", department: "CE", year: "2nd Year", }, ]; const categories = [ { id: "all", label: "All Categories", icon: LayoutGrid }, { id: "digital-art", label: "Digital Art", icon: Monitor }, { id: "paintings", label: "Paintings", icon: Palette }, { id: "poster-making", label: "Poster Making", icon: FileImage }, ]; // Seeded random shuffle function function seededShuffle(array: T[], seed: number): T[] { const shuffled = [...array]; let currentIndex = shuffled.length; // Simple seeded random number generator const seededRandom = () => { seed = (seed * 9301 + 49297) % 233280; return seed / 233280; }; while (currentIndex > 0) { const randomIndex = Math.floor(seededRandom() * currentIndex); currentIndex--; [shuffled[currentIndex], shuffled[randomIndex]] = [shuffled[randomIndex], shuffled[currentIndex]]; } return shuffled; } export default function GalleryPage() { const [selectedCategory, setSelectedCategory] = useState("all"); const [searchQuery, setSearchQuery] = useState(""); const [viewMode, setViewMode] = useState<"grid" | "large">("grid"); const [selectedArtwork, setSelectedArtwork] = useState(null); const [votedArtworks, setVotedArtworks] = useState>(new Set()); const [showFilters, setShowFilters] = useState(false); // Use a daily seed for consistent randomization throughout the day const dailySeed = useMemo(() => { const today = new Date(); return today.getFullYear() * 10000 + (today.getMonth() + 1) * 100 + today.getDate(); }, []); // Filter and shuffle artworks const filteredArtworks = useMemo(() => { let result = mockArtworks; // Filter by category if (selectedCategory !== "all") { result = result.filter(art => art.category === selectedCategory); } // Filter by search query if (searchQuery) { const query = searchQuery.toLowerCase(); result = result.filter( art => art.title.toLowerCase().includes(query) || art.artist.toLowerCase().includes(query) ); } // Shuffle with seed return seededShuffle(result, dailySeed); }, [selectedCategory, searchQuery, dailySeed]); const handleVote = (artworkId: string) => { if (votedArtworks.has(artworkId)) { // Already voted - in production, show a message return; } setVotedArtworks(prev => new Set([...prev, artworkId])); // TODO: Send vote to API }; return (
{/* Header */} GALLERY

Explore Artworks

Browse through amazing artworks submitted by talented artists from SJEC. Vote for your favorites to help them win!

{/* Filters Bar */}
{/* Search */}
setSearchQuery(e.target.value)} placeholder="Search by title or artist..." className="w-full bg-zinc-900 border border-zinc-800 rounded-xl pl-12 pr-4 py-3 text-white placeholder-zinc-500 focus:outline-none focus:border-lime-400 transition-colors" />
{/* Category Pills - Desktop */}
{categories.map((cat) => ( ))}
{/* Mobile Filter Button */} {/* View Toggle */}
{/* Mobile Category Filters */} {showFilters && (
{categories.map((cat) => ( ))}
)}
{/* Results Count */}
Showing {filteredArtworks.length} artwork{filteredArtworks.length !== 1 ? "s" : ""}
{/* Gallery Grid */} {filteredArtworks.length > 0 ? ( {filteredArtworks.map((artwork, index) => ( {/* Image */}
setSelectedArtwork(artwork)} > {artwork.title}
{/* Category Badge */}
{artwork.category === "digital-art" && } {artwork.category === "paintings" && } {artwork.category === "poster-making" && } {categories.find(c => c.id === artwork.category)?.label}
{/* Info */}

{artwork.title}

by {artwork.artist} • {artwork.department}

{/* Vote Button */}
))}
) : (

No artworks found

Try adjusting your search or filter criteria

)}
{/* Artwork Modal */} {selectedArtwork && ( setSelectedArtwork(null)} > e.stopPropagation()} >
{selectedArtwork.title}

{selectedArtwork.title}

by {selectedArtwork.artist}

{selectedArtwork.category === "digital-art" && } {selectedArtwork.category === "paintings" && } {selectedArtwork.category === "poster-making" && } {categories.find(c => c.id === selectedArtwork.category)?.label}

Department

{selectedArtwork.department}

Year

{selectedArtwork.year}

)}
); }