'use client'; import React, { useRef, useState } from 'react'; interface CarouselItem { title: string; content: string; icon?: React.ReactNode; } interface CarouselProps { items: CarouselItem[]; className?: string; } export const Carousel: React.FC = ({ items, className = '' }) => { const scrollRef = useRef(null); const [activeIndex, setActiveIndex] = useState(0); const scrollTo = (index: number) => { if (!scrollRef.current) return; const width = scrollRef.current.clientWidth; scrollRef.current.scrollTo({ left: index * width, behavior: 'smooth' }); setActiveIndex(index); }; const handleScroll = () => { if (!scrollRef.current) return; const width = scrollRef.current.clientWidth; const index = Math.round(scrollRef.current.scrollLeft / width); if (index !== activeIndex) setActiveIndex(index); }; // Icons helper (default icon if none provided) const DefaultIcon = () => ( ); return (
{/* Scroll Container */}
{(items || []).map((item, index) => (
{item.icon || }

{item.title}

{item.content && (

{item.content}

)}
))}
{/* Nav Buttons (Outside) */}
{/* Dots */}
{(items || []).map((_, index) => (
); };