diff --git a/app/components/HeroCarousel.tsx b/app/components/HeroCarousel.tsx new file mode 100644 index 0000000..63ad831 --- /dev/null +++ b/app/components/HeroCarousel.tsx @@ -0,0 +1,66 @@ +import type React from 'react'; +import {useEffect, useState} from 'react'; +import {cn} from '~/lib/utils'; + +interface CarouselProps { + items: React.ReactNode[]; + autoPlay?: boolean; + autoPlayInterval?: number; +} + +export default function HeroCarousel({ + items, + autoPlay, + autoPlayInterval, +}: CarouselProps) { + const [currentIndex, setCurrentIndex] = useState(0); + + const goToSlide = (index: number) => { + setCurrentIndex(index); + }; + + useEffect(() => { + if (!autoPlay) return; // Only run if autoplay is enabled + + const interval = setInterval(() => { + setCurrentIndex((prev) => (prev + 1) % items.length); + }, autoPlayInterval); + + return () => clearInterval(interval); // Cleanup on unmount + }, [autoPlay, autoPlayInterval, items.length]); + + return ( +
+ {/* Carousel Content */} +
+
+ {items.map((item, index) => ( +
+ {item} +
+ ))} +
+
+ + {/* Dot Navigation */} +
+ {items.map((_, index) => ( +
+
+ ); +} diff --git a/app/components/PageLayout.tsx b/app/components/PageLayout.tsx index e7e6626..fe5f083 100644 --- a/app/components/PageLayout.tsx +++ b/app/components/PageLayout.tsx @@ -45,7 +45,7 @@ export function PageLayout({ publicStoreDomain={publicStoreDomain} /> )} -
{children}
+
{children}