Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yejin0O0 committed Nov 27, 2024
2 parents 76143e8 + df91644 commit 4c7ed4c
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 393 deletions.
14 changes: 8 additions & 6 deletions components/DayCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function MonthlyDateCarousel({
return (
<section
className="w-full sticky top-[4rem] z-10 bg-white mb-5"
aria-label="Monthly Date Carousel"
aria-label="경기 날짜 선택"
>
<div className="relative w-full">
<Carousel
Expand All @@ -68,11 +68,11 @@ export default function MonthlyDateCarousel({
>
<ChevronLeft size={18} className="text-indigo-600" />
</CarouselPrevious>
<CarouselContent className="flex items-center gap-2 p-4">
<CarouselContent className="flex items-center gap-2 px-2 md:px-4 p-2">
{dates.map((date) => {
let textColor = "text-gray-600";
let dateStyles =
"cursor-pointer transition-all duration-200 transform rounded-full w-28 h-14 flex flex-col items-center justify-center";
"cursor-pointer transition-all duration-200 transform rounded-full w-16 h-14 flex flex-col items-center justify-center md:w-28";

if (selectedDate.toDateString() === date.date.toDateString()) {
dateStyles +=
Expand All @@ -95,7 +95,7 @@ export default function MonthlyDateCarousel({
return (
<CarouselItem
key={date.date.toISOString()}
className="flex-none basis-1/6"
className="flex-none basis-[20%] sm:basis-[14.2857%] md:basis-1/6"
>
<button
className={`${dateStyles} ${textColor}`}
Expand All @@ -109,10 +109,12 @@ export default function MonthlyDateCarousel({
type="button"
>
<div className="flex flex-col items-center justify-center p-0">
<span className={`text-sm font-medium ${textColor}`}>
<span
className={`text-xs md:text-sm font-medium ${textColor}`}
>
{format(date.date, "EEE", { locale: ko })}
</span>
<span className="text-xl font-bold">
<span className="text-lg md:text-xl font-bold">
{format(date.date, "d")}
</span>
</div>
Expand Down
84 changes: 84 additions & 0 deletions components/MainBannerCarousel.tsx
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;
Loading

0 comments on commit 4c7ed4c

Please sign in to comment.