import { Icon, Icons } from "@/components/Icon"; import { Flare } from "@/components/utils/Flare"; interface CarouselNavButtonsProps { categorySlug: string; carouselRefs: React.MutableRefObject<{ [key: string]: HTMLDivElement | null; }>; } interface NavButtonProps { direction: "left" | "right"; onClick: () => void; } function NavButton({ direction, onClick }: NavButtonProps) { return ( ); } export function CarouselNavButtons({ categorySlug, carouselRefs, }: CarouselNavButtonsProps) { const handleScroll = (direction: "left" | "right") => { const carousel = carouselRefs.current[categorySlug]; if (!carousel) return; const movieElements = carousel.getElementsByTagName("a"); if (movieElements.length === 0) return; // Wait for next frame to ensure measurements are available requestAnimationFrame(() => { const movieWidth = movieElements[0].getBoundingClientRect().width; const carouselWidth = carousel.getBoundingClientRect().width; if (movieWidth === 0 || carouselWidth === 0) { return; } const visibleMovies = Math.floor(carouselWidth / movieWidth); const scrollAmount = movieWidth * (visibleMovies > 5 ? 4 : 2); const newScrollPosition = carousel.scrollLeft + (direction === "left" ? -scrollAmount : scrollAmount); carousel.scrollTo({ left: newScrollPosition, behavior: "smooth", }); }); }; return ( <> handleScroll("left")} /> handleScroll("right")} /> ); }