From 47c6c04444192a6e82235719c27a6f23ff1630cd Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Tue, 25 Feb 2025 21:28:55 -0700 Subject: [PATCH] use grid for media cards instead --- .../discover/components/CategoryButtons.tsx | 2 +- .../discover/components/MediaCarousel.tsx | 81 +++++++++---------- src/pages/discover/discover.css | 16 +++- src/pages/discover/discoverContent.tsx | 4 +- 4 files changed, 56 insertions(+), 47 deletions(-) diff --git a/src/pages/discover/components/CategoryButtons.tsx b/src/pages/discover/components/CategoryButtons.tsx index 1d2c52ee..6bb6bfc8 100644 --- a/src/pages/discover/components/CategoryButtons.tsx +++ b/src/pages/discover/components/CategoryButtons.tsx @@ -41,7 +41,7 @@ export function CategoryButtons({ ); return ( -
+
{(showAlwaysScroll || isMobile) && renderScrollButton("left")}
+ index === + self.findIndex((m) => m.id === media.id && m.title === media.title), + ) + .slice(0, 20); + return ( <>

@@ -70,54 +78,43 @@ export function MediaCarousel({
{ carouselRefs.current[categorySlug] = el; }} onWheel={handleWheel} > - {medias - .filter( - (media, index, self) => - index === - self.findIndex( - (m) => m.id === media.id && m.title === media.title, - ), - ) - .slice(0, 25) - .map((media, index, array) => ( -
) => - e.preventDefault() - } +
+ + {filteredMedias.map((media) => ( +
) => + e.preventDefault() + } + key={media.id} + className="relative mt-4 group cursor-pointer user-select-none rounded-xl p-2 bg-transparent transition-colors duration-300 w-[10rem] md:w-[11.5rem] h-auto" + > + - -
- ))} + media={{ + id: media.id.toString(), + title: media.title || media.name || "", + poster: `https://image.tmdb.org/t/p/w342${media.poster_path}`, + type: isTVShow ? "show" : "movie", + year: isTVShow + ? media.first_air_date + ? parseInt(media.first_air_date.split("-")[0], 10) + : undefined + : media.release_date + ? parseInt(media.release_date.split("-")[0], 10) + : undefined, + }} + /> +
+ ))} + +
{!isMobile && ( diff --git a/src/pages/discover/discover.css b/src/pages/discover/discover.css index 1b56fe86..2f2a9019 100644 --- a/src/pages/discover/discover.css +++ b/src/pages/discover/discover.css @@ -19,8 +19,20 @@ @media (max-width: 768px) { .carousel-container { - mask-image: none; - -webkit-mask-image: none; + mask-image: linear-gradient( + to right, + rgba(0, 0, 0, 0), /* Left edge */ + rgba(0, 0, 0, 1) 20px, /* visible after 80px */ + rgba(0, 0, 0, 1) calc(100% - 20px), /* invisible 80px from right */ + rgba(0, 0, 0, 0) 100% /* Right edge */ + ); + -webkit-mask-image: linear-gradient( + to right, + rgba(0, 0, 0, 0), + rgba(0, 0, 0, 1) 20px, + rgba(0, 0, 0, 1) calc(100% - 20px), + rgba(0, 0, 0, 0) 100% + ); } } diff --git a/src/pages/discover/discoverContent.tsx b/src/pages/discover/discoverContent.tsx index a66d040b..d1477f83 100644 --- a/src/pages/discover/discoverContent.tsx +++ b/src/pages/discover/discoverContent.tsx @@ -264,7 +264,7 @@ export function DiscoverContent() { }; return ( -
+
{/* Random Movie Button */} {/* Category Tabs */} -
+
{["movies", "tvshows"].map((category) => (