diff --git a/src/components/cardStack/layouts/carousels/FullWidthCarousel.tsx b/src/components/cardStack/layouts/carousels/FullWidthCarousel.tsx index 528d79e..99656f0 100644 --- a/src/components/cardStack/layouts/carousels/FullWidthCarousel.tsx +++ b/src/components/cardStack/layouts/carousels/FullWidthCarousel.tsx @@ -1,155 +1,18 @@ -"use client"; +'use client'; -import { memo, Children, cloneElement, isValidElement, useCallback, useEffect, useState } from "react"; -import useEmblaCarousel from "embla-carousel-react"; -import { EmblaCarouselType } from "embla-carousel"; -import CardStackTextBox from "../../CardStackTextBox"; -import { cls } from "@/lib/utils"; -import { FullWidthCarouselProps } from "../../types"; +import React from 'react'; +import { FullWidthCarouselProps } from '@/components/cardStack/types'; -const FullWidthCarousel = ({ - children, - title, - titleSegments, - description, - tag, - tagIcon, - tagAnimation, - buttons, - buttonAnimation, - textboxLayout = "default", - useInvertedBackground, - className = "", - containerClassName = "", - carouselClassName = "", - dotsClassName = "", - textBoxClassName = "", - titleClassName = "", - titleImageWrapperClassName = "", - titleImageClassName = "", - descriptionClassName = "", - tagClassName = "", - buttonContainerClassName = "", - buttonClassName = "", - buttonTextClassName = "", - ariaLabel = "Carousel section", -}: FullWidthCarouselProps) => { - const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true, align: "center" }); - const [selectedIndex, setSelectedIndex] = useState(0); - - const childrenArray = Children.toArray(children); - - const onSelect = useCallback((emblaApi: EmblaCarouselType) => { - setSelectedIndex(emblaApi.selectedScrollSnap()); - }, []); - - const scrollTo = useCallback( - (index: number) => { - if (!emblaApi) return; - emblaApi.scrollTo(index); - }, - [emblaApi] - ); - - useEffect(() => { - if (!emblaApi) return; - - onSelect(emblaApi); - emblaApi.on("select", onSelect).on("reInit", onSelect); - - return () => { - emblaApi.off("select", onSelect).off("reInit", onSelect); - }; - }, [emblaApi, onSelect]); - - useEffect(() => { - if (!emblaApi) return; - - const autoplay = setInterval(() => { - emblaApi.scrollNext(); - }, 5000); - - return () => clearInterval(autoplay); - }, [emblaApi]); - - return ( - - - - - - - - - - {Children.map(childrenArray, (child, index) => ( - - {isValidElement(child) - ? cloneElement(child, { isActive: selectedIndex === index } as Record) - : child} - - ))} - - - - - {childrenArray.map((_, index) => ( - scrollTo(index)} - className={cls( - "relative cursor-pointer h-2 rounded-theme bg-accent transition-all duration-300", - selectedIndex === index - ? "w-8 opacity-100" - : "w-2 opacity-20" - )} - aria-label={`Go to slide ${index + 1}`} - aria-current={selectedIndex === index} - /> - ))} - - - - ); +const FullWidthCarousel: React.FC = ({ items, className = '' }) => { + return ( + + {items.map((item, index) => ( + + {item.title} + + ))} + + ); }; -FullWidthCarousel.displayName = "FullWidthCarousel"; - -export default memo(FullWidthCarousel); +export default FullWidthCarousel;