-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from TripInfoWeb/dev_informations
Feature: 이미지 뷰어 생성
- Loading branch information
Showing
5 changed files
with
131 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { useDragScrollType } from "@/hooks/useDragScroll"; | ||
import Image from "next/image"; | ||
import { Dispatch, SetStateAction } from "react"; | ||
import ImageViewer from "./ImageViewer"; | ||
|
||
interface Props { | ||
scrollHook: useDragScrollType; | ||
images: Array<Readonly<{ imageStatus: string; address: string }>>; | ||
mainImageUrl: string; | ||
viewerVisible: boolean; | ||
setMainImageUrl: Dispatch<SetStateAction<string>>; | ||
openViewer: () => void; | ||
closeViewer: () => void; | ||
} | ||
|
||
const ImageList = ({ | ||
scrollHook, | ||
images, | ||
mainImageUrl, | ||
viewerVisible, | ||
setMainImageUrl, | ||
openViewer, | ||
closeViewer, | ||
}: Props) => { | ||
return ( | ||
<div className="dark:opacity-65"> | ||
{viewerVisible && ( | ||
<ImageViewer imageUrl={mainImageUrl} closeViewer={closeViewer} /> | ||
)} | ||
<div className="relative h-[26.0625rem] w-full max-[744px]:h-[19.125rem]"> | ||
<Image | ||
className="cursor-pointer rounded-2xl border-[0.0625rem] hover:border-main" | ||
src={mainImageUrl} | ||
alt={"/background"} | ||
fill={true} | ||
style={{ | ||
objectFit: "cover", | ||
}} | ||
onClick={() => openViewer()} | ||
/> | ||
</div> | ||
<div | ||
className="flex flex-row items-center gap-[0.875rem] overflow-x-auto pt-[0.875rem]" | ||
ref={scrollHook.listRef} | ||
onMouseDown={(e) => { | ||
e.preventDefault(); | ||
scrollHook.onDragStart(e); | ||
}} | ||
onMouseMove={scrollHook.onDragMove} | ||
onMouseUp={scrollHook.onDragEnd} | ||
onMouseLeave={scrollHook.onDragEnd} | ||
onTouchStart={scrollHook.onTouchStart} | ||
onTouchMove={scrollHook.onTouchMove} | ||
onTouchEnd={scrollHook.onTouchEnd} | ||
> | ||
{images.map((image, index) => ( | ||
<div | ||
key={index} | ||
className="relative h-[6.6875rem] w-[6.6875rem] rounded-lg border-[0.0625rem]" | ||
onClick={() => { | ||
setMainImageUrl(image.address); | ||
}} | ||
onTouchEnd={() => { | ||
setMainImageUrl(image.address); | ||
}} | ||
> | ||
<Image | ||
className="cursor-pointer rounded-lg" | ||
src={image.address} | ||
alt={"/background"} | ||
fill={true} | ||
style={{ objectFit: "cover" }} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ImageList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import ImageList from "@/components/informations/detail/ImageList"; | ||
import useDragScroll from "@/hooks/useDragScroll"; | ||
import { useState } from "react"; | ||
|
||
interface Props { | ||
images: Array<Readonly<{ imageStatus: string; address: string }>>; | ||
} | ||
|
||
const ImageListContainer = ({ images }: Props) => { | ||
const scrollHook = useDragScroll(); | ||
const [mainImageUrl, setMainImageUrl] = useState<string>( | ||
images.find((image) => image.imageStatus === "썸네일")?.address ?? "", | ||
); | ||
const [viewerVisible, setViewerVisible] = useState<boolean>(false); | ||
|
||
return ( | ||
<ImageList | ||
scrollHook={scrollHook} | ||
images={images} | ||
mainImageUrl={mainImageUrl} | ||
viewerVisible={viewerVisible} | ||
setMainImageUrl={setMainImageUrl} | ||
openViewer={() => setViewerVisible(true)} | ||
closeViewer={() => setViewerVisible(false)} | ||
/> | ||
); | ||
}; | ||
|
||
export default ImageListContainer; |
25 changes: 0 additions & 25 deletions
25
src/containers/informations/detail/ImageViewerContainer.tsx
This file was deleted.
Oops, something went wrong.