Skip to content

Commit 296181b

Browse files
committed
feat: 이미지 크게 보기 기능 추가
1 parent 21b1f91 commit 296181b

File tree

5 files changed

+44
-67
lines changed

5 files changed

+44
-67
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"react-kakao-maps-sdk": "^1.1.27",
4141
"react-responsive": "^10.0.0",
4242
"tailwind-merge": "^2.5.4",
43+
"yet-another-react-lightbox": "^3.21.7",
4344
"zod": "^3.23.8",
4445
"zustand": "^5.0.1"
4546
},

public/og-image.png

-176 KB
Loading

src/app/(pages)/(workform)/work/[formId]/components/FormImage.tsx

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import Image from "next/image";
44
import Indicator from "@/app/components/pagination/Indicator";
55
import { isValidS3Url } from "@/utils/checkS3Url";
66
import { useState } from "react";
7-
import ImageViewerModal from "./ImageViewerModal";
7+
import Lightbox from "yet-another-react-lightbox";
8+
import "yet-another-react-lightbox/styles.css";
9+
import Zoom from "yet-another-react-lightbox/plugins/zoom";
10+
import Counter from "yet-another-react-lightbox/plugins/counter";
11+
import "yet-another-react-lightbox/plugins/counter.css";
812

913
interface FormImageProps {
1014
imageUrls: string[];
@@ -13,15 +17,15 @@ interface FormImageProps {
1317
}
1418

1519
export default function FormImage({ imageUrls, currentPage, onPageChange }: FormImageProps) {
16-
const [isModalOpen, setIsModalOpen] = useState(false);
20+
const [isOpen, setIsOpen] = useState(false);
1721

1822
const handleImageClick = () => {
19-
setIsModalOpen(true);
23+
setIsOpen(true);
2024
};
2125

22-
const handleCloseModal = () => {
23-
setIsModalOpen(false);
24-
};
26+
const slides = imageUrls.map((url) => ({
27+
src: url,
28+
}));
2529

2630
return (
2731
<>
@@ -34,6 +38,13 @@ export default function FormImage({ imageUrls, currentPage, onPageChange }: Form
3438
index === currentPage ? "opacity-100" : "opacity-0"
3539
}`}
3640
onClick={handleImageClick}
41+
role="button"
42+
tabIndex={0}
43+
onKeyDown={(e) => {
44+
if (e.key === "Enter" || e.key === " ") {
45+
handleImageClick();
46+
}
47+
}}
3748
>
3849
<Image
3950
src={imageUrl}
@@ -53,15 +64,18 @@ export default function FormImage({ imageUrls, currentPage, onPageChange }: Form
5364
)}
5465
</div>
5566

56-
{/* 이미지 뷰어 모달 */}
57-
{isModalOpen && (
58-
<ImageViewerModal
59-
imageUrls={imageUrls}
60-
currentPage={currentPage}
61-
onPageChange={onPageChange}
62-
onClose={handleCloseModal}
63-
/>
64-
)}
67+
{/* Lightbox */}
68+
<Lightbox
69+
open={isOpen}
70+
close={() => setIsOpen(false)}
71+
slides={slides}
72+
index={currentPage}
73+
plugins={[Zoom, Counter]}
74+
counter={{ container: { style: { top: "unset", bottom: 0 } } }}
75+
on={{
76+
view: ({ index }) => onPageChange(index),
77+
}}
78+
/>
6579
</>
6680
);
6781
}

src/app/(pages)/(workform)/work/[formId]/components/ImageViewerModal.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)