-
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.
feat: add new components
- Loading branch information
Showing
16 changed files
with
338 additions
and
188 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
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,105 @@ | ||
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 GenreCard from "../../ui/Cards/GenreCard"; | ||
|
||
const GenreSlider = ({ data = [] }: any) => { | ||
data = [ | ||
{ | ||
id: 1, | ||
genre: "Action", | ||
}, | ||
{ | ||
id: 2, | ||
genre: "Adventure", | ||
}, | ||
{ | ||
id: 3, | ||
genre: "Sci-Fi", | ||
}, | ||
{ | ||
id: 4, | ||
genre: "Thriller", | ||
}, | ||
{ | ||
id: 5, | ||
genre: "Horror", | ||
}, | ||
{ | ||
id: 6, | ||
genre: "Comedy", | ||
}, | ||
]; | ||
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 space-y-4"> | ||
<div | ||
className="shadow-text-color font-extrabold left-0 right-0 mx-auto" | ||
ref={shadowTextRef} | ||
> | ||
Genres | ||
</div> | ||
<div className="flex justify-end px-6"> | ||
<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}> | ||
<GenreCard item={item} /> | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
</section> | ||
); | ||
}; | ||
|
||
export default GenreSlider; |
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,9 @@ | ||
const GenreCard = ({ item }: any) => { | ||
return ( | ||
<div className="aspect-video bg-white/20 rounded-2xl flex justify-center items-center backdrop-blur-md px-6 font-bold text-4xl"> | ||
<div>{item.genre}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GenreCard; |
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
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.