-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
398 additions
and
238 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
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,82 @@ | ||
import { Swiper, SwiperSlide } from "swiper/react"; | ||
import { Navigation } from "swiper/modules"; | ||
import SliderControls from "./SliderControls"; | ||
import generateRandomString from "../../../utils/uidGenerator"; | ||
import { useEffect, useRef } from "react"; | ||
import CollectionCard from "../../ui/Cards/CollectionCard"; | ||
|
||
const CollectionSlider = ({ title, shadowTitle = "", data = [] }: any) => { | ||
const sliderUid = generateRandomString(); | ||
const shadowTextRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
const adjustFontSize = () => { | ||
const container: HTMLDivElement | null = | ||
document.querySelector(".container"); | ||
const shadowText = shadowTextRef.current; | ||
|
||
if (container && shadowText) { | ||
const containerWidth = container.offsetWidth; | ||
shadowText.style.fontSize = `${containerWidth * 0.1}px`; | ||
} | ||
}; | ||
|
||
window.addEventListener("resize", adjustFontSize); | ||
adjustFontSize(); | ||
|
||
return () => { | ||
window.removeEventListener("resize", adjustFontSize); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<section className="w-full z-0 relative"> | ||
{shadowTitle !== "" && ( | ||
<div | ||
className="shadow-text font-extrabold left-0 right-0 mx-auto" | ||
ref={shadowTextRef} | ||
> | ||
{shadowTitle} | ||
</div> | ||
)} | ||
<div className="flex justify-between px-6"> | ||
<div className="text-white/60 font-bold text-4xl/normal">{title}</div> | ||
<SliderControls sliderUid={sliderUid} /> | ||
</div> | ||
<Swiper | ||
className="!px-2 !py-2 w-full" | ||
breakpoints={{ | ||
320: { | ||
slidesPerView: 2, | ||
spaceBetween: 20, | ||
}, | ||
580: { | ||
slidesPerView: 3, | ||
spaceBetween: 20, | ||
}, | ||
920: { | ||
slidesPerView: 3, | ||
spaceBetween: 20, | ||
}, | ||
1080: { | ||
slidesPerView: 4, | ||
spaceBetween: 20, | ||
}, | ||
}} | ||
modules={[Navigation]} | ||
navigation={{ | ||
nextEl: `.customSwiperNext${sliderUid}`, | ||
prevEl: `.customSwiperPrevious${sliderUid}`, | ||
}} | ||
> | ||
{data.map((item: any, index: number) => ( | ||
<SwiperSlide key={index}> | ||
<CollectionCard item={item} /> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
</section> | ||
); | ||
}; | ||
|
||
export default CollectionSlider; |
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
Oops, something went wrong.