|
1 | | -'use client' |
2 | | - |
3 | | -import{useState}from'react' |
4 | | -import{Card,CardBody,CardFooter,CardHeader}from'@heroui/card' |
5 | | -import{Image}from'@heroui/image' |
6 | | -import{KunCardStats}from'~/components/kun/CardStats' |
7 | | -importLinkfrom'next/link' |
8 | | -import{KunPatchAttribute}from'~/components/kun/PatchAttribute' |
9 | | -import{cn}from'~/utils/cn' |
10 | | - |
11 | | -interfaceProps{ |
12 | | -patch:GalgameCard |
13 | | -} |
14 | | - |
15 | | -exportconstGalgameCard=({ patch}:Props)=>{ |
16 | | -const[imageLoaded,setImageLoaded]=useState(false) |
17 | | - |
18 | | -return( |
19 | | -<Card |
20 | | -isPressable |
21 | | -as={Link} |
22 | | -href={`/${patch.uniqueId}`} |
23 | | -target="_blank" |
24 | | -className="w-full border border-default-100 dark:border-default-200" |
25 | | -> |
26 | | -<CardHeaderclassName="p-0"> |
27 | | -<divclassName="relative w-full mx-auto overflow-hidden text-center rounded-t-lg opacity-90"> |
28 | | -<div |
29 | | -className={cn( |
30 | | -'absolute inset-0 animate-pulse bg-default-100', |
31 | | -imageLoaded ?'opacity-0' :'opacity-90', |
32 | | -'transition-opacity duration-300' |
33 | | -)} |
34 | | -style={{aspectRatio:'16/9'}} |
35 | | -/> |
36 | | -<Image |
37 | | -radius="none" |
38 | | -alt={patch.name} |
39 | | -className={cn( |
40 | | -'size-full object-cover transition-all duration-300', |
41 | | -imageLoaded ?'scale-100 opacity-90' :'scale-105 opacity-0' |
42 | | -)} |
43 | | -removeWrapper={true} |
44 | | -src={ |
45 | | -patch.banner |
46 | | - ?patch.banner.replace(/\.avif$/,'-mini.avif') |
47 | | - :'/touchgal.avif' |
48 | | -} |
49 | | -style={{aspectRatio:'16/9'}} |
50 | | -onLoad={()=>setImageLoaded(true)} |
51 | | -/> |
52 | | -</div> |
53 | | -</CardHeader> |
54 | | -<CardBodyclassName="justify-between space-y-2"> |
55 | | -<h2className="font-semibold transition-colors text-small sm:text-lg line-clamp-2 hover:text-primary-500"> |
56 | | -{patch.name} |
57 | | -</h2> |
58 | | -<KunCardStatspatch={patch}isMobile={true}/> |
59 | | -</CardBody> |
60 | | -<CardFooterclassName="pt-0"> |
61 | | -<KunPatchAttributetypes={patch.type}size="sm"/> |
62 | | -</CardFooter> |
63 | | -</Card> |
64 | | -) |
65 | | -} |
| 1 | +'use client' |
| 2 | + |
| 3 | +import{useState}from'react' |
| 4 | +import{Card,CardBody,CardFooter,CardHeader}from'@heroui/card' |
| 5 | +import{Image}from'@heroui/image' |
| 6 | +import{KunCardStats}from'~/components/kun/CardStats' |
| 7 | +importLinkfrom'next/link' |
| 8 | +import{KunPatchAttribute}from'~/components/kun/PatchAttribute' |
| 9 | +import{cn}from'~/utils/cn' |
| 10 | + |
| 11 | +interfaceProps{ |
| 12 | +patch:GalgameCard |
| 13 | +openOnNewTab?:boolean |
| 14 | +} |
| 15 | + |
| 16 | +exportconstGalgameCard=({ patch, openOnNewTab=true}:Props)=>{ |
| 17 | +const[imageLoaded,setImageLoaded]=useState(false) |
| 18 | + |
| 19 | +return( |
| 20 | +<Card |
| 21 | +isPressable |
| 22 | +as={Link} |
| 23 | +href={`/${patch.uniqueId}`} |
| 24 | +target={openOnNewTab ?'_blank' :'_self'} |
| 25 | +className="w-full border border-default-100 dark:border-default-200" |
| 26 | +> |
| 27 | +<CardHeaderclassName="p-0"> |
| 28 | +<divclassName="relative w-full mx-auto overflow-hidden text-center rounded-t-lg opacity-90"> |
| 29 | +<div |
| 30 | +className={cn( |
| 31 | +'absolute inset-0 animate-pulse bg-default-100', |
| 32 | +imageLoaded ?'opacity-0' :'opacity-90', |
| 33 | +'transition-opacity duration-300' |
| 34 | +)} |
| 35 | +style={{aspectRatio:'16/9'}} |
| 36 | +/> |
| 37 | +<Image |
| 38 | +radius="none" |
| 39 | +alt={patch.name} |
| 40 | +className={cn( |
| 41 | +'size-full object-cover transition-all duration-300', |
| 42 | +imageLoaded ?'scale-100 opacity-90' :'scale-105 opacity-0' |
| 43 | +)} |
| 44 | +removeWrapper={true} |
| 45 | +src={ |
| 46 | +patch.banner |
| 47 | + ?patch.banner.replace(/\.avif$/,'-mini.avif') |
| 48 | + :'/touchgal.avif' |
| 49 | +} |
| 50 | +style={{aspectRatio:'16/9'}} |
| 51 | +onLoad={()=>setImageLoaded(true)} |
| 52 | +/> |
| 53 | +</div> |
| 54 | +</CardHeader> |
| 55 | +<CardBodyclassName="justify-between space-y-2"> |
| 56 | +<h2className="font-semibold transition-colors text-small sm:text-lg line-clamp-2 hover:text-primary-500"> |
| 57 | +{patch.name} |
| 58 | +</h2> |
| 59 | +<KunCardStatspatch={patch}isMobile={true}/> |
| 60 | +</CardBody> |
| 61 | +<CardFooterclassName="pt-0"> |
| 62 | +<KunPatchAttributetypes={patch.type}size="sm"/> |
| 63 | +</CardFooter> |
| 64 | +</Card> |
| 65 | +) |
| 66 | +} |