File size: 7,571 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"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>
    )
}