Spaces:
Paused
Paused
File size: 3,392 Bytes
ebde876 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | "use client"
import { useState } from "react"
import Link from "next/link"
import Image from "next/image"
import { Button } from "@/components/ui/button"
import { GalleryModal } from "@/components/gallery-modal"
import { Search } from "lucide-react"
interface GalleryGridProps {
generations: any[]
}
export function GalleryGrid({ generations }: GalleryGridProps) {
const [selectedGen, setSelectedGen] = useState<any | null>(null)
return (
<>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
{generations.map((gen) => (
<div
key={gen.id}
className="group relative neo-brutalist bg-card rounded-none overflow-hidden aspect-square border-2 border-border cursor-pointer"
onClick={() => setSelectedGen(gen)}
>
{/* Username Overlay - Always Visible */}
<div className="absolute top-3 left-3 z-10">
<div className="bg-black/70 backdrop-blur-md text-white px-3 py-1 text-xs font-bold uppercase tracking-wider rounded-full border border-white/20 flex items-center gap-2 shadow-lg">
<div className="h-2 w-2 rounded-full bg-green-500 animate-pulse" />
@{gen.user.username || "user"}
</div>
</div>
<Image
src={gen.imageUrl} // Direct URL
alt={gen.prompt}
fill
className="object-cover transition-transform duration-700 group-hover:scale-110 group-hover:rotate-1"
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
unoptimized
/>
{/* Hover Overlay */}
<div className="absolute inset-0 bg-background/80 backdrop-blur-sm opacity-0 group-hover:opacity-100 transition-all duration-300 flex flex-col justify-center items-center p-6 text-center border-2 border-transparent group-hover:border-primary/50 m-2">
<Search className="h-8 w-8 text-primary mb-4" />
<p className="font-bold line-clamp-3 text-foreground leading-tight">"{gen.prompt}"</p>
<p className="text-xs font-bold uppercase tracking-widest text-muted-foreground mt-4">Click to view details</p>
</div>
</div>
))}
</div>
{generations.length === 0 && (
<div className="glass-panel p-12 rounded-none border-2 border-dashed border-border text-center">
<p className="text-xl font-bold text-muted-foreground uppercase tracking-widest">No Masterpieces Yet</p>
<div className="mt-6">
<Button className="neo-brutalist" asChild><Link href="/create">Be The First</Link></Button>
</div>
</div>
)}
<GalleryModal
isOpen={!!selectedGen}
onClose={() => setSelectedGen(null)}
generation={selectedGen}
/>
</>
)
}
|