import React, { useRef, useState, useEffect } from 'react'; import { SubsonicArtist } from '../api/subsonic'; import ArtistCardLocal from './ArtistCardLocal'; import { ChevronLeft, ChevronRight, ArrowRight } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; interface Props { title: string; artists: SubsonicArtist[]; moreLink?: string; moreText?: string; } export default function ArtistRow({ title, artists, moreLink, moreText }: Props) { const scrollRef = useRef(null); const navigate = useNavigate(); const [showLeft, setShowLeft] = useState(false); const [showRight, setShowRight] = useState(true); const handleScroll = () => { if (!scrollRef.current) return; const { scrollLeft, scrollWidth, clientWidth } = scrollRef.current; setShowLeft(scrollLeft > 0); setShowRight(scrollLeft < scrollWidth - clientWidth - 5); }; useEffect(() => { handleScroll(); window.addEventListener('resize', handleScroll); return () => window.removeEventListener('resize', handleScroll); }, [artists]); const scroll = (dir: 'left' | 'right') => { if (!scrollRef.current) return; const amount = scrollRef.current.clientWidth * 0.75; scrollRef.current.scrollBy({ left: dir === 'left' ? -amount : amount, behavior: 'smooth' }); }; if (artists.length === 0) return null; return (

{title}

{artists.map(a => )} {moreLink && (
navigate(moreLink)}>
{moreText}
)}
); }