From 2ec8a0618fc6543199cafef0954741b9fe461d7b Mon Sep 17 00:00:00 2001 From: kudinDmitriyUp Date: Tue, 26 May 2026 16:47:06 +0000 Subject: [PATCH] Added ImageCardCarousel to HeroBillboardCarousel --- .../sections/hero/HeroBillboardCarousel.tsx | 18 ++---- src/components/ui/ImageCardCarousel.tsx | 64 +++++++++++++++++++ 2 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 src/components/ui/ImageCardCarousel.tsx diff --git a/src/components/sections/hero/HeroBillboardCarousel.tsx b/src/components/sections/hero/HeroBillboardCarousel.tsx index b02d75a..61b0192 100644 --- a/src/components/sections/hero/HeroBillboardCarousel.tsx +++ b/src/components/sections/hero/HeroBillboardCarousel.tsx @@ -2,6 +2,7 @@ import Button from "@/components/ui/Button"; import HeroBackgroundSlot from "@/components/ui/HeroBackgroundSlot"; import TextAnimation from "@/components/ui/TextAnimation"; import ImageOrVideo from "@/components/ui/ImageOrVideo"; +import ImageCardCarousel from "@/components/ui/ImageCardCarousel"; type HeroBillboardCarouselProps = { tag: string; @@ -55,18 +56,11 @@ const HeroBillboardCarousel = ({ -
-
- {duplicated.map((item, i) => ( -
- -
- ))} -
+
+ item.imageSrc || item.videoSrc || '')} + className="aspect-video max-h-[600px]" + />
); diff --git a/src/components/ui/ImageCardCarousel.tsx b/src/components/ui/ImageCardCarousel.tsx new file mode 100644 index 0000000..73c063b --- /dev/null +++ b/src/components/ui/ImageCardCarousel.tsx @@ -0,0 +1,64 @@ +import React, { useState, useEffect } from 'react'; +import { motion } from 'motion'; +import { clsx } from 'clsx'; + +type ImageCardCarouselProps = { + images: string[]; + interval?: number; // in milliseconds + className?: string; +}; + +const ImageCardCarousel = ({ images, interval = 3000, className }: ImageCardCarouselProps) => { + const [currentIndex, setCurrentIndex] = useState(0); + const [progress, setProgress] = useState(0); + + useEffect(() => { + const imageTimer = setInterval(() => { + setCurrentIndex((prevIndex) => (prevIndex + 1) % images.length); + setProgress(0); // Reset progress for the new image + }, interval); + + return () => clearInterval(imageTimer); + }, [images, interval]); + + useEffect(() => { + const progressTimer = setInterval(() => { + setProgress((prevProgress) => { + const newProgress = prevProgress + (1000 / interval) * 100; // Increment by 100ms worth of progress + return newProgress >= 100 ? 100 : newProgress; + }); + }, 100); // Update progress every 100ms + + return () => clearInterval(progressTimer); + }, [interval]); + + if (!images || images.length === 0) { + return null; + } + + return ( +
+ {images.map((image, index) => ( + + ))} +
+ +
+
+ ); +}; + +export default ImageCardCarousel; -- 2.49.1