-
Notifications
You must be signed in to change notification settings - Fork 0
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
피드 상세 뷰 이미지 캐러셀 UI 추가 #409
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
34d6ffb
build: add embla-carousel-react package
eunsukimme 6a52109
feat: add ImageCarouselModal
eunsukimme 55b7485
feat: integrate ImageCarouselModal with FeedPostViewer
eunsukimme cafbbe5
build: edit storybook preview to add OverlayProvider
eunsukimme 5d6a3c2
chore: edit FeedPostViewer story to pass multiple images
eunsukimme a6b1cae
style: edit image cursor styles
eunsukimme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,124 @@ | ||
import { Box } from '@components/box/Box'; | ||
import { styled } from 'stitches.config'; | ||
import ModalContainer from './ModalContainer'; | ||
import useEmblaCarousel from 'embla-carousel-react'; | ||
import ArrowLeft from 'public/assets/svg/arrow_big_left.svg'; | ||
import ArrowRight from 'public/assets/svg/arrow_big_right.svg'; | ||
import CloseIcon from 'public/assets/svg/x_big.svg'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
interface ImageCarouselModalProps { | ||
isOpen: boolean; | ||
close: () => void; | ||
images: string[]; | ||
startIndex?: number; | ||
} | ||
|
||
export default function ImageCarouselModal({ isOpen, close, images, startIndex = 0 }: ImageCarouselModalProps) { | ||
const [emblaRef, api] = useEmblaCarousel({ startIndex, duration: 0 }); | ||
const [currentIndex, setCurrentIndex] = useState(startIndex + 1); | ||
|
||
useEffect(() => { | ||
if (!api) return; | ||
api.on('select', () => setCurrentIndex(api.selectedScrollSnap() + 1)); | ||
|
||
return () => { | ||
api.destroy(); | ||
}; | ||
}, [api]); | ||
|
||
return ( | ||
<ModalContainer isModalOpened={isOpen} handleModalClose={close}> | ||
<ModalWrapper> | ||
<Container> | ||
{/* top 고정 요소 */} | ||
{/* eslint-disable-next-line prettier/prettier */} | ||
<Counter>{currentIndex}/{images.length}</Counter> | ||
<CloseButton onClick={close}> | ||
<CloseIcon /> | ||
</CloseButton> | ||
|
||
<ArrowButton style={{ marginLeft: '24px' }} onClick={() => api?.scrollPrev()}> | ||
<ArrowLeft /> | ||
</ArrowButton> | ||
<CarouselContainer ref={emblaRef}> | ||
<CarouselScrollContainer> | ||
{images.map(image => ( | ||
<CarouselItem> | ||
<Image src={image} /> | ||
</CarouselItem> | ||
))} | ||
</CarouselScrollContainer> | ||
</CarouselContainer> | ||
<ArrowButton style={{ marginRight: '24px' }} onClick={() => api?.scrollNext()}> | ||
<ArrowRight /> | ||
</ArrowButton> | ||
</Container> | ||
</ModalWrapper> | ||
</ModalContainer> | ||
); | ||
} | ||
const ModalWrapper = styled(Box, { | ||
position: 'fixed', | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
flexType: 'center', | ||
zIndex: '$2', | ||
backgroundColor: '#181818', | ||
width: '100%', | ||
height: '100vh', | ||
}); | ||
const Container = styled('div', { | ||
position: 'relative', | ||
width: '100%', | ||
height: '100%', | ||
color: 'white', | ||
flexType: 'verticalCenter', | ||
justifyContent: 'space-between', | ||
}); | ||
const Counter = styled('div', { | ||
position: 'absolute', | ||
top: '28px', | ||
left: '48px', | ||
color: 'white', | ||
fontStyle: 'T1', | ||
}); | ||
const CloseButton = styled('button', { | ||
position: 'absolute', | ||
top: '32px', | ||
right: '48px', | ||
width: '24px', | ||
height: '24px', | ||
border: 'none', | ||
outline: 'none', | ||
}); | ||
const CarouselContainer = styled('div', { | ||
overflow: 'hidden', | ||
}); | ||
const CarouselScrollContainer = styled('div', { | ||
display: 'flex', | ||
maxWidth: '1280px', | ||
height: '100vh', | ||
maxHeight: '600px', | ||
}); | ||
const CarouselItem = styled('div', { | ||
flexType: 'center', | ||
width: '100%', | ||
height: '100%', | ||
flex: '0 0 100%', | ||
minWidth: 0, | ||
}); | ||
const Image = styled('img', { | ||
width: '100%', | ||
height: '100%', | ||
objectFit: 'contain', | ||
}); | ||
const ArrowButton = styled('button', { | ||
flexType: 'center', | ||
width: '72px', | ||
height: '72px', | ||
flexShrink: 0, | ||
borderRadius: '20px', | ||
background: '$black80', | ||
}); |
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 |
---|---|---|
|
@@ -6969,6 +6969,24 @@ elliptic@^6.5.3: | |
minimalistic-assert "^1.0.1" | ||
minimalistic-crypto-utils "^1.0.1" | ||
|
||
embla-carousel-react@^8.0.0-rc13: | ||
version "8.0.0-rc13" | ||
resolved "https://registry.yarnpkg.com/embla-carousel-react/-/embla-carousel-react-8.0.0-rc13.tgz#faf388744d8261b0dda0dfe33bf3cd4b84ac891e" | ||
integrity sha512-Yq8TXVtTTPIF5dmLzedamS2h+gDEY56x1kp6W4g+phL7DyLV2KJKHCUvfeRlVsbG90Q0if27IIUUNKKNLfN7mQ== | ||
dependencies: | ||
embla-carousel "8.0.0-rc13" | ||
embla-carousel-reactive-utils "8.0.0-rc13" | ||
|
||
[email protected]: | ||
version "8.0.0-rc13" | ||
resolved "https://registry.yarnpkg.com/embla-carousel-reactive-utils/-/embla-carousel-reactive-utils-8.0.0-rc13.tgz#383271c9cd20b20fb71328ddd3aa546978a7a542" | ||
integrity sha512-sH8JRUYTjSAeEJw01YWPLjBOHOCnl9GuqLJKWqMxkYJAluUbB/koshjeewa78und6pZkWUsHUYv/dm0YJ4ZdHg== | ||
|
||
[email protected]: | ||
version "8.0.0-rc13" | ||
resolved "https://registry.yarnpkg.com/embla-carousel/-/embla-carousel-8.0.0-rc13.tgz#2b3e7100f86492f3eae1409ee8bbb343de448931" | ||
integrity sha512-77U2nJRl5YtKCXiVuUqD4U8FQSqDjwVdNPO3KoOgi5WfVHnKgMn0bVOLOd3ehCPGyB/r1Mqd1Gbcwhip7bedlw== | ||
|
||
emoji-regex@^8.0.0: | ||
version "8.0.0" | ||
resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
이 부분 궁금해서 찾아봤는데 문서도 넘 친절하고 좋네요!
또 배워갑니다😊