-
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.
* feat: 메인 배너 컴포넌트 화 및 메인 페이지로 이동 * design: 오늘의 경기 탭 삭제 * fix: dayCarousel 반응형 고려 * fix: header 반응형 고려 * feat: 경기 상태 버튼 추가 * design: 경기 취소, 종료 스타일 변경 * feat: 데이터 없을 때 로직 추가 및 버튼 클릭시 이동하게 구현 * design: 반응형 반영 * design: 간격 수정 * feat: 헤더 반응형 구현 * design: 사이즈 조정 * design: margin 추가
- Loading branch information
Showing
10 changed files
with
455 additions
and
393 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { | ||
Carousel, | ||
CarouselContent, | ||
CarouselItem, | ||
} from "@/components/ui/carousel"; | ||
import Autoplay from "embla-carousel-autoplay"; | ||
import type { UseEmblaCarouselType } from "embla-carousel-react"; | ||
import { useCallback, useEffect, useState } from "react"; | ||
|
||
const imageUrl = [ | ||
"/images/banner-rules.png", | ||
"/images/banner-process.png", | ||
"/images/banner-polite.png", | ||
"/images/banner-match.png", | ||
]; | ||
|
||
function MainBannerCarousel() { | ||
const [api, setApi] = useState<UseEmblaCarouselType[1]>(); | ||
const [current, setCurrent] = useState(0); | ||
const [count, setCount] = useState(0); | ||
|
||
useEffect(() => { | ||
if (!api) { | ||
return; | ||
} | ||
|
||
setCount(api.scrollSnapList().length); | ||
setCurrent(api.selectedScrollSnap()); | ||
|
||
api.on("select", () => { | ||
setCurrent(api.selectedScrollSnap()); | ||
}); | ||
}, [api]); | ||
|
||
const scrollTo = useCallback( | ||
(index: number) => { | ||
api?.scrollTo(index); | ||
}, | ||
[api], | ||
); | ||
|
||
return ( | ||
<section> | ||
<Carousel | ||
plugins={[ | ||
Autoplay({ | ||
delay: 5000, | ||
}), | ||
]} | ||
setApi={setApi} | ||
className="w-full" | ||
> | ||
<CarouselContent> | ||
{imageUrl.map((url, index) => ( | ||
<CarouselItem key={url} className="w-full h-[346px]"> | ||
<img | ||
src={`${url}`} | ||
alt={`banner ${index + 1}`} | ||
className="w-[1048px] h-[346px] object-fit rounded-lg" | ||
/> | ||
</CarouselItem> | ||
))} | ||
</CarouselContent> | ||
</Carousel> | ||
<div className="flex justify-center space-x-2 mt-4 gap-2"> | ||
{Array.from({ length: count }).map((_, index) => ( | ||
<button | ||
type="button" | ||
key={`dots-${ | ||
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation> | ||
index | ||
}`} | ||
className={`w-2 h-2 rounded-full transition-colors duration-200 ${ | ||
index === current ? "bg-primary" : "bg-gray-300" | ||
}`} | ||
onClick={() => scrollTo(index)} | ||
/> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
export default MainBannerCarousel; |
Oops, something went wrong.