-
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.
fix: merge various sliders and remove redundant code
- Loading branch information
Showing
16 changed files
with
386 additions
and
450 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 |
---|---|---|
@@ -1,11 +1,95 @@ | ||
{ | ||
"server_path": "http://localhost:8000", | ||
"server_path": "http://localhost:8803", | ||
"home_path": "home", | ||
"movie_path": "movie", | ||
"tv_path": "tv", | ||
"season_path": "season", | ||
"episode_path": "episode", | ||
"stream_path": "stream", | ||
"image_path": "image", | ||
"optimization": false | ||
"optimization": false, | ||
"genreSlider": { | ||
"title": "Genres", | ||
"placeholderCount": 6, | ||
"breakpoints": { | ||
"300": { | ||
"slidesPerView": 2, | ||
"spaceBetween": 20 | ||
}, | ||
"920": { | ||
"slidesPerView": 4, | ||
"spaceBetween": 20 | ||
}, | ||
"1080": { | ||
"slidesPerView": 6, | ||
"spaceBetween": 20 | ||
} | ||
} | ||
}, | ||
"collectionSlider": { | ||
"title": "Collections", | ||
"placeholderCount": 4, | ||
"breakpoints": { | ||
"320": { | ||
"slidesPerView": 2, | ||
"spaceBetween": 20 | ||
}, | ||
"580": { | ||
"slidesPerView": 3, | ||
"spaceBetween": 20 | ||
}, | ||
"920": { | ||
"slidesPerView": 3, | ||
"spaceBetween": 20 | ||
}, | ||
"1080": { | ||
"slidesPerView": 4, | ||
"spaceBetween": 20 | ||
} | ||
} | ||
}, | ||
"movieSlider": { | ||
"title": "Movies", | ||
"placeholderCount": 4, | ||
"breakpoints": { | ||
"320": { | ||
"slidesPerView": 2, | ||
"spaceBetween": 20 | ||
}, | ||
"580": { | ||
"slidesPerView": 3, | ||
"spaceBetween": 20 | ||
}, | ||
"920": { | ||
"slidesPerView": 3, | ||
"spaceBetween": 20 | ||
}, | ||
"1080": { | ||
"slidesPerView": 4, | ||
"spaceBetween": 20 | ||
} | ||
} | ||
}, | ||
"tvSlider": { | ||
"title": "TV Shows", | ||
"placeholderCount": 4, | ||
"breakpoints": { | ||
"320": { | ||
"slidesPerView": 2, | ||
"spaceBetween": 20 | ||
}, | ||
"580": { | ||
"slidesPerView": 3, | ||
"spaceBetween": 20 | ||
}, | ||
"920": { | ||
"slidesPerView": 3, | ||
"spaceBetween": 20 | ||
}, | ||
"1080": { | ||
"slidesPerView": 4, | ||
"spaceBetween": 20 | ||
} | ||
} | ||
} | ||
} |
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,71 @@ | ||
import { Swiper, SwiperSlide } from "swiper/react"; | ||
import { Navigation } from "swiper/modules"; | ||
import generateRandomString from "../../utils/generateRandomString"; | ||
import React from "react"; | ||
import IconButton from "../actions/IconButton"; | ||
|
||
interface SliderControls { | ||
sliderUid: string; | ||
} | ||
|
||
const SliderControls = ({ sliderUid }: SliderControls) => { | ||
return ( | ||
<div className="w-fit space-x-2 flex justify-between items-center"> | ||
<IconButton | ||
rounded | ||
className={`customSwiperPrevious${sliderUid}`} | ||
icon="ChevronLeftIcon" | ||
variant="secondary" | ||
iconType="outline" | ||
/> | ||
<IconButton | ||
rounded | ||
className={`customSwiperNext${sliderUid}`} | ||
icon="ChevronRightIcon" | ||
variant="secondary" | ||
iconType="outline" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
const ContentSlider = ({ sliderConfig, data, children }: any) => { | ||
const sliderUid = generateRandomString(); | ||
|
||
return ( | ||
<section className="w-full z-0 relative"> | ||
<div className="flex justify-between px-6"> | ||
<div className="text-white/60 font-bold text-4xl/normal"> | ||
{sliderConfig.title} | ||
</div> | ||
<SliderControls sliderUid={sliderUid} /> | ||
</div> | ||
<Swiper | ||
className="!py-2 w-full" | ||
breakpoints={sliderConfig.breakpoints} | ||
modules={[Navigation]} | ||
navigation={{ | ||
nextEl: `.customSwiperNext${sliderUid}`, | ||
prevEl: `.customSwiperPrevious${sliderUid}`, | ||
}} | ||
> | ||
{data && data.length > 0 | ||
? data.map((item: any, index: number) => ( | ||
<SwiperSlide key={item.id || index}> | ||
{React.cloneElement(children as React.ReactElement, { item })} | ||
</SwiperSlide> | ||
)) | ||
: Array(sliderConfig.placeholderCount) | ||
.fill(null) | ||
.map((_, index) => index + 1) | ||
.map((_, index) => ( | ||
<SwiperSlide key={index}> | ||
{React.cloneElement(children, { placeholder: true })} | ||
</SwiperSlide> | ||
))} | ||
</Swiper> | ||
</section> | ||
); | ||
}; | ||
|
||
export default ContentSlider; |
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.