import React, { useRef, useState } from "react"; import { ChevronLeft, ChevronRight, GalleryHorizontal, LayoutGrid, } from "lucide-react"; import { cn } from "@/lib/utils"; import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"; import type { ResourceCarouselProps } from "./types"; export function ResourceCarousel({ title, items, headerAction, onViewModeChange, className, }: ResourceCarouselProps) { const scrollRef = useRef(null); const [viewMode, setViewMode] = useState<"compact" | "grid">("compact"); function scrollLeft() { scrollRef.current?.scrollBy({ left: -380, behavior: "smooth" }); } function scrollRight() { scrollRef.current?.scrollBy({ left: 380, behavior: "smooth" }); } return (
{/* Header row */} {(title || headerAction) && (
{title &&

{title}

} {headerAction && (
{headerAction}
)}
{ if (v.length > 0) { const mode = v[0] as "compact" | "grid"; setViewMode(mode); onViewModeChange?.(mode); } }} aria-label="View mode" >
)} {/* Content */} {items.length === 0 ? (

No items available

) : viewMode === "grid" ? (
{items.map((item, i) => (
{item}
))}
) : (
{items.map((item, i) => (
{item}
))}
)}
); }