'use client'; import { LeagueCard } from '@/components/leagues/LeagueCardWrapper'; import { LeagueSummaryViewModel } from '@/lib/view-models/LeagueSummaryViewModel'; import { routes } from '@/lib/routing/RouteConfig'; import type { LeaguesViewData } from '@/lib/view-data/LeaguesViewData'; import { Button } from '@/ui/Button'; import { Heading } from '@/ui/Heading'; import { Icon } from '@/ui/Icon'; import { Link } from '@/ui/Link'; import { Stack } from '@/ui/Stack'; import { Text } from '@/ui/Text'; import { ChevronLeft, ChevronRight, type LucideIcon } from 'lucide-react'; import { useCallback, useRef, useState } from 'react'; interface LeagueSliderProps { title: string; icon: LucideIcon; description: string; leagues: LeaguesViewData['leagues']; autoScroll?: boolean; iconColor?: string; scrollSpeedMultiplier?: number; scrollDirection?: 'left' | 'right'; } export function LeagueSlider({ title, icon: IconComp, description, leagues, iconColor = 'text-primary-blue', }: LeagueSliderProps) { const scrollRef = useRef(null); const [canScrollLeft, setCanScrollLeft] = useState(false); const [canScrollRight, setCanScrollRight] = useState(true); const checkScrollButtons = useCallback(() => { if (scrollRef.current) { const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; setCanScrollLeft(scrollLeft > 0); setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 10); } }, []); const scroll = useCallback((direction: 'left' | 'right') => { if (scrollRef.current) { const cardWidth = 340; const scrollAmount = direction === 'left' ? -cardWidth : cardWidth; scrollRef.current.scrollBy({ left: scrollAmount, behavior: 'smooth' }); } }, []); if (leagues.length === 0) return null; return ( {/* Section header */} {title} {description} {leagues.length} {/* Navigation arrows */} {/* Scrollable container with fade edges */} {leagues.map((league) => { const viewModel = new LeagueSummaryViewModel(league); return ( ); })} ); }