From 0ef6ee570261fcb3cc817e47d789dc39977afdab Mon Sep 17 00:00:00 2001 From: Tejas Panchal Date: Sun, 27 Jul 2025 19:10:34 +0530 Subject: [PATCH] fixed genre --- src/components/genres/Genre.jsx | 111 ++++++++++++++++++++------------ src/pages/Home/Home.jsx | 4 +- 2 files changed, 74 insertions(+), 41 deletions(-) diff --git a/src/components/genres/Genre.jsx b/src/components/genres/Genre.jsx index c74424d..dd7c60e 100644 --- a/src/components/genres/Genre.jsx +++ b/src/components/genres/Genre.jsx @@ -1,51 +1,82 @@ -import React, { useState } from "react"; +import React, { useRef, useEffect } from "react"; import { Link } from "react-router-dom"; function Genre({ data }) { - const colors = [ - "#A4B389", - "#FFBADE", - "#935C5F", - "#AD92BC", - "#ABCCD8", - "#D8B2AB", - "#85E1CD", - "#B7C996", - ]; + const scrollContainerRef = useRef(null); - const [showAll, setShowAll] = useState(false); - const toggleGenres = () => { - setShowAll((prev) => !prev); + const scroll = (direction) => { + if (scrollContainerRef.current) { + const scrollAmount = direction === 'left' ? -300 : 300; + scrollContainerRef.current.scrollBy({ + left: scrollAmount, + behavior: 'smooth' + }); + } }; + // Instant scroll on mount without animation + useEffect(() => { + if (scrollContainerRef.current) { + // Direct manipulation of scrollLeft for instant scroll + scrollContainerRef.current.scrollLeft = 300; + } + }, []); + return ( -
-

Genres

-
-
- {data && - (showAll ? data : data.slice(0, 24)).map((item, index) => { - const textColor = colors[index % colors.length]; - return ( - -
- {item.charAt(0).toUpperCase() + item.slice(1)} -
- - ); - })} -
- +
+ {data && data.map((item, index) => ( + +
+ {item.charAt(0).toUpperCase() + item.slice(1)} +
+ + ))} +
+
+ + {/* Left button and gradient */} +
+ +
+
+ + {/* Spacer for content */} +
+ + {/* Right button and gradient */} +
+
+ +
); diff --git a/src/pages/Home/Home.jsx b/src/pages/Home/Home.jsx index cdb86ee..0557494 100644 --- a/src/pages/Home/Home.jsx +++ b/src/pages/Home/Home.jsx @@ -20,6 +20,9 @@ function Home() { <>
+
+ +
@@ -70,7 +73,6 @@ function Home() { />
-