Skip to content

Commit b948ab1

Browse files
committed
style: 컨텐츠 1개일 경우 캐러셀 가운데 정렬 (#111)
1 parent 851dbec commit b948ab1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/pages/home/ui/LoopCarousel.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ const LoopCarousel = ({ data, onCenterChange }: LoopCarouselProps) => {
4444
return () => {
4545
emblaApi.off('select', handleSelect) // 언마운트 시 이벤트 해제
4646
}
47-
}, [emblaApi, handleSelect, data])
47+
}, [emblaApi, handleSelect])
4848

4949
return (
5050
<div ref={emblaRef}>
51-
<EmblaContainer>
51+
<EmblaContainer $single={data.length === 1}>
5252
{data.map((slide, index: Key) => (
5353
<EmblaSlide key={index}>
5454
<Slide $active={activeIndex === index}>
5555
<Cd
5656
variant="carousel"
5757
bgColor="none"
58-
stickers={activeIndex === index ? (slide.onlyCdResponse?.cdItems ?? []) : []}
58+
stickers={activeIndex === index ? slide.onlyCdResponse.cdItems : []}
5959
/>
6060
</Slide>
6161
</EmblaSlide>
@@ -67,10 +67,11 @@ const LoopCarousel = ({ data, onCenterChange }: LoopCarouselProps) => {
6767

6868
export default LoopCarousel
6969

70-
const EmblaContainer = styled.div`
70+
const EmblaContainer = styled.div<{ $single?: boolean }>`
7171
display: flex;
7272
touch-action: pan-y pinch-zoom;
7373
padding: 16px 0;
74+
justify-content: ${({ $single }) => ($single ? 'center' : 'flex-start')};
7475
`
7576

7677
const EmblaSlide = styled.div`

0 commit comments

Comments
 (0)