Spaces:
Sleeping
Sleeping
Download src/components/gallery-modal.tsx from veltrixcode/Iot: direct link, hf CLI and curl.
- Browser
- Download file 7.57 kB
-
https://huggingface.co/spaces/veltrixcode/Iot/resolve/main/src/components/gallery-modal.tsx
- Command line
-
hf download hf://spaces/veltrixcode/Iot/src/components/gallery-modal.tsx
-
curl -L -o gallery-modal.tsx https://huggingface.co/spaces/veltrixcode/Iot/resolve/main/src/components/gallery-modal.tsx
7.57 kB
| "use client" | |
| import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog" | |
| import { VisuallyHidden } from "@radix-ui/react-visually-hidden" | |
| import Image from "next/image" | |
| import { Button } from "@/components/ui/button" | |
| import { Download, Info, X, User, Calendar, Cpu } from "lucide-react" | |
| import { ShareMenu } from "@/components/share-menu" | |
| interface GalleryModalProps { | |
| isOpen: boolean | |
| onClose: () => void | |
| generation: any | |
| } | |
| export function GalleryModal({ isOpen, onClose, generation }: GalleryModalProps) { | |
| if (!generation) return null | |
| const imageUrl = generation.imageUrl | |
| return ( | |
| <Dialog open={isOpen} onOpenChange={onClose}> | |
| <DialogContent className="max-w-6xl w-[95vw] p-0 overflow-hidden bg-background/98 backdrop-blur-xl border-2 border-border neo-brutalist gap-0 max-h-[95vh] flex flex-col"> | |
| <VisuallyHidden> | |
| <DialogTitle>Artwork Details</DialogTitle> | |
| </VisuallyHidden> | |
| {/* Close Button */} | |
| <Button | |
| className="absolute top-3 right-3 z-50 rounded-full h-10 w-10 bg-background/80 backdrop-blur-sm border-2 border-border hover:bg-destructive hover:text-white transition-colors" | |
| size="icon" | |
| variant="ghost" | |
| onClick={onClose} | |
| > | |
| <X className="h-5 w-5" /> | |
| </Button> | |
| <div className="flex flex-col lg:flex-row h-full overflow-hidden flex-1"> | |
| {/* Image Section - Takes more space */} | |
| <div className="relative bg-black/5 dark:bg-white/5 flex items-center justify-center lg:w-3/5 min-h-[250px] lg:min-h-0 flex-shrink-0"> | |
| <div className="absolute inset-0 bg-[linear-gradient(45deg,transparent_25%,rgba(255,255,255,.02)_25%,rgba(255,255,255,.02)_50%,transparent_50%,transparent_75%,rgba(255,255,255,.02)_75%)] bg-[size:20px_20px]" /> | |
| <Image | |
| src={imageUrl} | |
| alt={generation.prompt} | |
| fill | |
| className="object-contain p-2" | |
| unoptimized | |
| /> | |
| </div> | |
| {/* Details Section */} | |
| <div className="flex flex-col lg:w-2/5 border-t lg:border-t-0 lg:border-l border-border bg-card overflow-hidden"> | |
| {/* Scrollable Content */} | |
| <div className="flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar"> | |
| {/* Creator Info */} | |
| <div className="flex items-center gap-3 p-4 rounded-xl bg-gradient-to-r from-primary/10 to-secondary/10 border border-primary/20"> | |
| <div className="h-12 w-12 rounded-full bg-gradient-to-br from-primary to-secondary flex items-center justify-center text-white text-lg font-bold shadow-lg"> | |
| {generation.user.name?.[0] || "U"} | |
| </div> | |
| <div> | |
| <p className="font-bold text-lg">{generation.user.name || "Anonymous Creator"}</p> | |
| <p className="text-sm text-muted-foreground">@{generation.user.username || "artist"}</p> | |
| </div> | |
| </div> | |
| {/* Prompt */} | |
| <div className="space-y-3"> | |
| <div className="flex items-center gap-2 text-xs font-bold uppercase tracking-widest text-primary"> | |
| <Info className="h-3.5 w-3.5" /> | |
| Prompt | |
| </div> | |
| <div className="relative"> | |
| <div className="absolute left-0 top-0 bottom-0 w-1 bg-gradient-to-b from-primary via-secondary to-accent rounded-full" /> | |
| <p className="pl-4 text-base leading-relaxed text-foreground/90 max-h-48 overflow-y-auto custom-scrollbar"> | |
| {generation.prompt} | |
| </p> | |
| </div> | |
| </div> | |
| {/* Metadata Grid */} | |
| <div className="grid grid-cols-2 gap-3"> | |
| <div className="p-4 rounded-xl bg-secondary/5 border border-border space-y-1"> | |
| <div className="flex items-center gap-2 text-xs uppercase font-bold text-muted-foreground"> | |
| <Cpu className="h-3 w-3" /> Model | |
| </div> | |
| <p className="font-bold text-sm truncate" title={generation.model}> | |
| {generation.model.split('/').pop()} | |
| </p> | |
| </div> | |
| <div className="p-4 rounded-xl bg-secondary/5 border border-border space-y-1"> | |
| <div className="flex items-center gap-2 text-xs uppercase font-bold text-muted-foreground"> | |
| <Calendar className="h-3 w-3" /> Created | |
| </div> | |
| <p className="font-bold text-sm"> | |
| {new Date(generation.createdAt).toLocaleDateString()} | |
| </p> | |
| </div> | |
| </div> | |
| {/* Dimensions */} | |
| <div className="flex items-center justify-center gap-4 p-3 rounded-xl bg-muted/30 text-sm"> | |
| <span className="font-medium text-muted-foreground">Resolution:</span> | |
| <span className="font-bold">{generation.width} × {generation.height}</span> | |
| </div> | |
| </div> | |
| {/* Fixed Action Bar - Always Visible */} | |
| <div className="p-4 border-t border-border bg-background/80 backdrop-blur-sm flex gap-3 flex-shrink-0"> | |
| <Button | |
| className="flex-1 h-11 neo-brutalist bg-primary hover:bg-primary/90 text-white font-bold text-sm uppercase tracking-wider" | |
| onClick={() => { | |
| const a = document.createElement('a') | |
| a.href = imageUrl | |
| a.download = `wildart-${generation.id}.jpg` | |
| a.click() | |
| }} | |
| > | |
| <Download className="mr-2 h-4 w-4" /> | |
| Download | |
| </Button> | |
| <ShareMenu | |
| artworkId={generation.id} | |
| prompt={generation.prompt} | |
| className="flex-1 h-11 neo-brutalist font-bold text-sm uppercase tracking-wider" | |
| /> | |
| </div> | |
| </div> | |
| </div> | |
| </DialogContent> | |
| </Dialog> | |
| ) | |
| } | |