Skip to content

Commit b0fafc1

Browse files
committed
fix swapi
1 parent 930f216 commit b0fafc1

File tree

6 files changed

+179
-17
lines changed

6 files changed

+179
-17
lines changed

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
"@headlessui/react": "^1.7.17",
2020
"@heroicons/react": "^2.0.18",
2121
"@radix-ui/react-icons": "^1.3.0",
22+
"@radix-ui/react-portal": "^1.0.4",
2223
"@radix-ui/react-radio-group": "^1.1.3",
24+
"@splidejs/react-splide": "^0.7.12",
2325
"@svgr/webpack": "^8.0.1",
2426
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
2527
"@tailwindcss/typography": "^0.5.10",
28+
"@types/react-slick": "^0.23.13",
2629
"autoprefixer": "^10.4.17",
2730
"clsx": "^2.1.0",
2831
"codemirror": "5.65.1",
@@ -50,8 +53,10 @@
5053
"react": "^18.2.0",
5154
"react-dom": "^18.2.0",
5255
"react-medium-image-zoom": "5.1.8",
56+
"react-slick": "^0.30.2",
5357
"server-only": "0.0.1",
5458
"server-only-context": "^0.1.0",
59+
"slick-carousel": "^1.8.1",
5560
"string-similarity": "^4.0.4",
5661
"string-strip-html": "^13.4.5",
5762
"tailwindcss": "^3.4.1",

pnpm-lock.yaml

+100
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/conf/2023/gallery/page.tsx

+22-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Metadata } from "next"
22
import { images } from "./_conf-images"
3+
import { ImageCarousel } from "../../_components/imageCarousel"
4+
import React from "react"
35
import NextImage from "next-image-export-optimizer"
4-
import { Zoom } from "../../_components/zoom"
56

67
export const metadata: Metadata = {
78
title: "Gallery",
@@ -23,18 +24,25 @@ export default function GalleryPage() {
2324

2425
return (
2526
<div className="bg-[#f4f6f8]">
26-
<div className="container conf-block">
27+
<div className="container conf-block gallery-page-images-list">
2728
{currentImages.map((c, i) => {
28-
function getCard(index: number) {
29+
function getCard(index: number, { size }: { size: "small" | "big" }) {
30+
const { width, height } =
31+
size === "small"
32+
? { width: 370, height: 208 }
33+
: { width: 748, height: 420 }
34+
2935
return (
3036
c[index] && (
31-
<Zoom>
37+
<div className="overflow-hidden rounded-md">
3238
<NextImage
33-
alt="Gallery"
34-
className="object-cover aspect-video w-full hover:opacity-75 rounded-md"
39+
alt={"gallery image"}
40+
className="object-cover aspect-video w-full hover:opacity-75"
3541
src={c[index]}
42+
width={width}
43+
height={height}
3644
/>
37-
</Zoom>
45+
</div>
3846
)
3947
)
4048
}
@@ -43,22 +51,23 @@ export default function GalleryPage() {
4351
<div key={i} className="grid lg:grid-cols-2 gap-2 mb-2">
4452
<div className="gap-2 flex flex-col">
4553
<div className="grid grid-cols-2 gap-2">
46-
{getCard(0)}
47-
{getCard(1)}
54+
{getCard(0, { size: "small" })}
55+
{getCard(1, { size: "small" })}
4856
</div>
49-
{getCard(2)}
57+
{getCard(2, { size: "big" })}
5058
</div>
5159
<div className="gap-2 flex flex-col">
52-
{getCard(3)}
60+
{getCard(3, { size: "big" })}
5361
<div className="grid grid-cols-2 gap-2">
54-
{getCard(4)}
55-
{getCard(5)}
62+
{getCard(4, { size: "small" })}
63+
{getCard(5, { size: "small" })}
5664
</div>
5765
</div>
5866
</div>
5967
)
6068
})}
6169
</div>
70+
<ImageCarousel index={0} images={images} />
6271
</div>
6372
)
6473
}
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"use client"
2+
import "react-medium-image-zoom/dist/styles.css"
3+
4+
import NextImage from "next-image-export-optimizer"
5+
import { StaticImageData } from "next/image"
6+
import Slider from "react-slick"
7+
import "slick-carousel/slick/slick.css"
8+
import "slick-carousel/slick/slick-theme.css"
9+
import { ComponentProps } from "react"
10+
11+
const settings: ComponentProps<typeof Slider> = {
12+
speed: 500,
13+
slidesToShow: 1,
14+
slidesToScroll: 1,
15+
initialSlide: 0,
16+
adaptiveHeight: true,
17+
}
18+
19+
interface Props {
20+
images: StaticImageData[]
21+
index: number
22+
}
23+
export const ImageCarousel = ({ images, index }: Props) => {
24+
settings.initialSlide = index || 0
25+
return (
26+
<div className="z-[9999] fixed left-0 top-0 bg-[rgba(0,0,0,0.5)] h-screen w-screen flex justify-center">
27+
<div className="w-screen max-w-[1504px]">
28+
<Slider {...settings} className="rounded-2xl">
29+
{images.map(image => (
30+
<div className="w-max">
31+
<div className="flex justify-center ">
32+
<div className="max-w-max h-max flex justify-center w-full">
33+
<img
34+
key={image.src}
35+
alt={"gallery image"}
36+
className="h-full max-h-screen"
37+
src={image.src}
38+
/>
39+
</div>
40+
</div>
41+
</div>
42+
))}
43+
</Slider>
44+
</div>
45+
</div>
46+
)
47+
}

src/app/conf/_components/zoom.ts

-4
This file was deleted.

src/globals.css

+5
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,8 @@ div[id^="headlessui-menu-items"] {
486486
font-size: 13px;
487487
padding: 7px 14px;
488488
}
489+
490+
/* it means the image is still in loading state */
491+
.gallery-page-images-list img[style*="background-image"] {
492+
filter: blur(3.5px);
493+
}

0 commit comments

Comments
 (0)