diff --git a/CarouselSection.tsx b/CarouselSection.tsx new file mode 100644 index 0000000..56e9ee9 --- /dev/null +++ b/CarouselSection.tsx @@ -0,0 +1,49 @@ +import React, { useState } from 'react'; +import { ChevronLeft, ChevronRight } from 'lucide-react'; +import { Button } from "@/components/ui/button"; +import { Card, CardContent } from "@/components/ui/card"; + +interface CarouselSectionProps { + title: string; + items: any[]; + renderItem: (item: any, index: number) => React.ReactNode; +} + +export function CarouselSection({ title, items, renderItem }: CarouselSectionProps) { + const [startIndex, setStartIndex] = useState(0); + + const handlePrev = () => { + setStartIndex((prevIndex) => (prevIndex > 0 ? prevIndex - 1 : items.length - 2)); + }; + + const handleNext = () => { + setStartIndex((prevIndex) => (prevIndex < items.length - 2 ? prevIndex + 1 : 0)); + }; + + return ( +
+

{title}

+
+
+ {items.slice(startIndex, startIndex + 2).map((item, index) => renderItem(item, index))} +
+ + +
+
+ ); +} \ No newline at end of file