-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE] Feat/#592 핀 디테일의 핀 이미지 클릭 시 모달을 통해 크게 보이는 기능 구현 #595
Changes from all commits
7b828c3
a813071
15d262b
a85076a
933e4c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import Map from '../Map'; | |
import Toast from '../Toast'; | ||
import Logo from './Logo'; | ||
import Navbar from './Navbar'; | ||
import ImageModalContext from '../../context/ImageModalContext'; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
|
@@ -43,44 +44,46 @@ function Layout({ children }: LayoutProps) { | |
return ( | ||
<ToastProvider> | ||
<ModalProvider> | ||
<CoordinatesProvider> | ||
<MarkerProvider> | ||
<SeeTogetherProvider> | ||
<TagProvider> | ||
<MediaWrapper | ||
$isAddPage={navbarHighlights.addMapOrPin} | ||
$layoutWidth={width} | ||
> | ||
<LayoutFlex | ||
$flexDirection="column" | ||
$minWidth={width} | ||
height="calc(var(--vh, 1vh) * 100)" | ||
$backgroundColor="white" | ||
<ImageModalContext> | ||
<CoordinatesProvider> | ||
<MarkerProvider> | ||
<SeeTogetherProvider> | ||
<TagProvider> | ||
<MediaWrapper | ||
$isAddPage={navbarHighlights.addMapOrPin} | ||
$layoutWidth={width} | ||
> | ||
<LogoWrapper $layoutWidth={width}> | ||
<Box> | ||
<Logo /> | ||
<Space size={2} /> | ||
</Box> | ||
</LogoWrapper> | ||
<Flex | ||
<LayoutFlex | ||
$flexDirection="column" | ||
height="inherit" | ||
overflow="auto" | ||
padding="0" | ||
$minWidth={width} | ||
height="calc(var(--vh, 1vh) * 100)" | ||
$backgroundColor="white" | ||
$layoutWidth={width} | ||
Comment on lines
+56
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분 변동사항은 왜 생긴걸까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 저도 만진적이 없어서 모르겠네요.. 흠 뭐지 |
||
> | ||
{children} | ||
</Flex> | ||
<Navbar $layoutWidth={width} /> | ||
<Toast /> | ||
</LayoutFlex> | ||
<Map /> | ||
</MediaWrapper> | ||
</TagProvider> | ||
</SeeTogetherProvider> | ||
</MarkerProvider> | ||
</CoordinatesProvider> | ||
<LogoWrapper $layoutWidth={width}> | ||
<Box> | ||
<Logo /> | ||
<Space size={2} /> | ||
</Box> | ||
</LogoWrapper> | ||
<Flex | ||
$flexDirection="column" | ||
height="inherit" | ||
overflow="auto" | ||
padding="0" | ||
> | ||
{children} | ||
</Flex> | ||
<Navbar $layoutWidth={width} /> | ||
<Toast /> | ||
</LayoutFlex> | ||
<Map /> | ||
</MediaWrapper> | ||
</TagProvider> | ||
</SeeTogetherProvider> | ||
</MarkerProvider> | ||
</CoordinatesProvider> | ||
</ImageModalContext> | ||
</ModalProvider> | ||
</ToastProvider> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,17 +5,23 @@ import Image from '../common/Image'; | |
import RemoveImageButton from '../../assets/remove_image_icon.svg'; | ||
import useDelete from '../../apiHooks/useDelete'; | ||
import useToast from '../../hooks/useToast'; | ||
import { useModalContext, ImageModal } from '../../context/ImageModalContext'; | ||
import { useState } from 'react'; | ||
import Button from '../common/Button'; | ||
import Space from '../common/Space'; | ||
|
||
interface PinImageContainerProps { | ||
images: ImageProps[]; | ||
getPinData: () => void; | ||
}const NOT_FOUND_IMAGE = | ||
'https://dr702blqc4x5d.cloudfront.net/2023-map-be-fine/icon/notFound_image.svg'; | ||
} | ||
const NOT_FOUND_IMAGE = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분 공통 컴포넌트 Image랑 중복되는 것 같은데 constant에 빼주세요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분은 제가 착각했군여 무시하셔도 좋습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아하! 넹 ~! |
||
'https://dr702blqc4x5d.cloudfront.net/2023-map-be-fine/icon/notFound_image.svg'; | ||
|
||
const PinImageContainer = ({ images, getPinData }: PinImageContainerProps) => { | ||
const { fetchDelete } = useDelete(); | ||
const { showToast } = useToast(); | ||
const { isModalOpen, openModal, closeModal } = useModalContext(); | ||
const [modalImage, setModalImage] = useState<string>(''); | ||
|
||
const onRemovePinImage = (imageId: number) => { | ||
const isRemoveImage = confirm('해당 이미지를 삭제하시겠습니까?'); | ||
|
@@ -24,28 +30,35 @@ const PinImageContainer = ({ images, getPinData }: PinImageContainerProps) => { | |
fetchDelete({ | ||
url: `/pins/images/${imageId}`, | ||
errorMessage: '이미지 제거에 실패했습니다.', | ||
isThrow: true, | ||
onSuccess: () => { | ||
showToast('info', '핀에서 이미지가 삭제 되었습니다.'); | ||
getPinData(); | ||
}, | ||
}); | ||
} | ||
}; | ||
|
||
const onImageOpen = (imageUrl: string) => { | ||
setModalImage(imageUrl); | ||
openModal(); | ||
}; | ||
|
||
return ( | ||
<> | ||
<FilmList> | ||
{images.map( | ||
(image, index) => | ||
index < 3 && ( | ||
<ImageWrapper> | ||
<Image | ||
key={image.id} | ||
height="100px" | ||
width="100px" | ||
src={image.imageUrl} | ||
$errorDefaultSrc={NOT_FOUND_IMAGE} | ||
/> | ||
<div onClick={() => onImageOpen(image.imageUrl)}> | ||
<Image | ||
key={image.id} | ||
height="100px" | ||
width="100px" | ||
src={image.imageUrl} | ||
$errorDefaultSrc={NOT_FOUND_IMAGE} | ||
/> | ||
</div> | ||
<RemoveImageIconWrapper | ||
onClick={() => onRemovePinImage(image.id)} | ||
> | ||
|
@@ -54,6 +67,17 @@ const PinImageContainer = ({ images, getPinData }: PinImageContainerProps) => { | |
</ImageWrapper> | ||
), | ||
)} | ||
{isModalOpen && ( | ||
<ImageModal closeModalHandler={closeModal}> | ||
<ModalImageWrapper> | ||
<ModalImage src={modalImage} /> | ||
<Space size={3} /> | ||
<Button variant="custom" onClick={closeModal}> | ||
닫기 | ||
</Button> | ||
</ModalImageWrapper> | ||
</ImageModal> | ||
)} | ||
</FilmList> | ||
</> | ||
); | ||
|
@@ -84,4 +108,25 @@ const RemoveImageIconWrapper = styled.div` | |
} | ||
`; | ||
|
||
const ModalImageWrapper = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
margin: 0 auto; | ||
overflow: hidden; | ||
`; | ||
|
||
const ModalImage = styled.img` | ||
width: 100%; | ||
height: 100%; | ||
Comment on lines
+124
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 결국 일괄 100%가 되었군요 ㅋㅋㅋㅋ |
||
|
||
min-width: 360px; | ||
min-height: 360px; | ||
|
||
display: block; | ||
`; | ||
export default PinImageContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context가 또 생겼네여
이런건 zustand로는 무리?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
무리데스요 ~