-
Notifications
You must be signed in to change notification settings - Fork 3
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 #79 from bomin0830/master
Fix: 뒤로가기 모달 이슈 수정 및 이미지 상세보기 기능 추가
- Loading branch information
Showing
30 changed files
with
128 additions
and
34 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
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,39 @@ | ||
import useClickOutside from '@/hooks/useClickOutside'; | ||
import { ImageModalState } from '@/states/ImageModalState'; | ||
import Image from 'next/image'; | ||
import { useRecoilState } from 'recoil'; | ||
|
||
export default function ImageModal() { | ||
const [ImageModal, setImageModal] = useRecoilState(ImageModalState); | ||
|
||
const contentsArea = useClickOutside<HTMLDivElement>(() => | ||
setImageModal({ ...ImageModal, isOpen: false }) | ||
); | ||
|
||
const closeModal = () => { | ||
setImageModal({ ...ImageModal, isOpen: false }); | ||
}; | ||
|
||
return ImageModal.isOpen && window ? ( | ||
<div className="fixed inset-0 p-[50px] pt-[140px] flex items-center justify-center bg-black dark:bg-opacity-90 bg-opacity-80 z-50 m:p-0"> | ||
<div ref={contentsArea} className="relative"> | ||
<img | ||
src={ImageModal.imageUrl} | ||
alt="이미지 자세히보기 모달 이미지" | ||
className="h-[600px] t:max-h-[500px] t:h-full t:min-h-[400px] t:max-w-[700px] m:w-full m:h-full" | ||
/> | ||
<button | ||
onClick={closeModal} | ||
className="absolute right-[-40px] top-[-40px] m:right-0 m:top-0" | ||
> | ||
<Image | ||
src="/icon/btn_x_medium.svg" | ||
width={40} | ||
height={40} | ||
alt="닫기" | ||
/> | ||
</button> | ||
</div> | ||
</div> | ||
) : null; | ||
} |
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,6 @@ | ||
import { ReactNode } from 'react'; | ||
|
||
export interface ImageModalProps { | ||
isOpen: boolean; | ||
imageUrl: string; | ||
} |
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
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
File renamed without changes.
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
File renamed without changes.
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
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,30 @@ | ||
import { ImageModalProps } from '@/components/ImageModal/ImageModalProps'; | ||
import { ModalProps } from '@/components/Modal/Modal.types'; | ||
import { ImageModalState } from '@/states/ImageModalState'; | ||
import { modalState } from '@/states/modalState'; | ||
import { useRecoilState } from 'recoil'; | ||
|
||
export const useImageModal = () => { | ||
const [imageModal, setImageModal] = useRecoilState(ImageModalState); | ||
|
||
const openImageModal = (props: Omit<ImageModalProps, 'isOpen'>) => { | ||
setImageModal({ | ||
...props, | ||
isOpen: true, | ||
}); | ||
}; | ||
|
||
const closeImageModal = () => { | ||
setImageModal({ | ||
...imageModal, | ||
isOpen: false, | ||
}); | ||
}; | ||
|
||
// 브라우저 뒤로가기 버튼이벤트 발생 시 모달 닫기 | ||
window.addEventListener('popstate', function (event) { | ||
closeImageModal(); | ||
}); | ||
|
||
return openImageModal; | ||
}; |
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
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
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
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,10 @@ | ||
import { ImageModalProps } from '@/components/ImageModal/ImageModalProps'; | ||
import { atom } from 'recoil'; | ||
|
||
export const ImageModalState = atom<ImageModalProps>({ | ||
key: 'ImageModalState', | ||
default: { | ||
isOpen: false, | ||
imageUrl: '', | ||
}, | ||
}); |