1
- import Image from 'next/image' ;
2
- import Link from 'next/link' ;
1
+ 'use client' ;
3
2
4
- type Props = {
5
- slug : string ;
6
- } ;
3
+ import Image from 'next/image' ;
4
+ import Modal from './modal' ;
5
+ import { useState } from 'react' ;
7
6
8
- export default function SkyboxCard ( { slug } : Props ) {
9
- const imgBase = `/Source_Skyboxes_NextJS/skyboxes/${ slug } /images` ;
10
- const details = `/${ slug } ` ;
7
+ type Props = { slug : string } ;
11
8
12
- const thumbnail = `${ imgBase } /thumbnail.webp` ;
9
+ export default function SkyboxCard ( { slug } : Props ) {
10
+ const [ open , setOpen ] = useState ( false ) ;
11
+ const imgBase = `/Source_Skyboxes_NextJS/skyboxes/${ slug } /images` ;
13
12
14
- //placeholder
15
- const description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' ;
16
-
17
- return (
18
- < Link href = { details } >
13
+ return (
14
+ < >
15
+ < button
16
+ onClick = { ( ) => setOpen ( true ) }
17
+ className = "group block w-full text-left"
18
+ >
19
19
< article
20
+ className = "
21
+ relative flex flex-col
22
+ bg-neutral-800 ring-1 ring-neutral-700/60
23
+ shadow-lg shadow-black/40
24
+ transition hover:scale-105
25
+ overflow-hidden aspect-[16/9] w-full
26
+ "
27
+ style = { {
28
+ backgroundImage : `url(${ imgBase } /thumbnail.webp)` ,
29
+ backgroundSize : 'cover' ,
30
+ backgroundPosition : 'center' ,
31
+ } }
32
+ >
33
+ < Image
34
+ src = { `${ imgBase } /thumbnail.webp` }
35
+ alt = { `${ slug } preview` }
36
+ fill
37
+ className = "opacity-0"
38
+ unoptimized
39
+ />
40
+
41
+ < div
20
42
className = "
21
- group
22
- relative flex flex-col items-center
23
- bg-neutral-800 ring-1 ring-neutral-700/60
24
- shadow-lg shadow-black/40
25
- transition duration-150 hover:scale-105
26
- overflow-hidden
27
- aspect-[16/9]
43
+ absolute inset-x-0 bottom-0
44
+ translate-y-0 opacity-100
45
+ md:translate-y-full md:opacity-0
46
+ md:group-hover:translate-y-0 md:group-hover:opacity-100
47
+ bg-black/60 backdrop-blur-xs px-3 py-2
48
+ transition
28
49
"
29
- style = { {
30
- backgroundImage : `url(${ thumbnail } )` ,
31
- backgroundSize : 'cover' ,
32
- backgroundPosition : 'center' ,
33
- } }
34
- >
35
-
36
- { /* Visually hidden image for SEO/alt text */ }
37
- < Image
38
- src = { thumbnail }
39
- alt = { `${ slug } preview` }
40
- fill
41
- className = "opacity-0"
42
- unoptimized
43
- />
44
- < div
45
- className = "
46
- absolute inset-x-0 bottom-0
47
- translate-y-0 opacity-100
48
- md:translate-y-full
49
- md:opacity-0
50
- md:group-hover:translate-y-0
51
- md:group-hover:opacity-100
52
- bg-black/60 backdrop-blur-xs
53
- px-3 py-2
54
- transition duration-150
55
- "
56
- >
57
- < h2 className = "text-sm font-semibold text-neutral-100 truncate" >
58
- { slug }
59
- </ h2 >
60
- </ div >
50
+ >
51
+ < h2 className = "text-sm font-semibold text-neutral-100 truncate" >
52
+ { slug }
53
+ </ h2 >
54
+ </ div >
61
55
</ article >
62
- </ Link >
63
- ) ;
64
- }
56
+ </ button >
57
+
58
+ { open && < Modal slug = { slug } onClose = { ( ) => setOpen ( false ) } /> }
59
+ </ >
60
+ ) ;
61
+ }
0 commit comments