diff --git a/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx b/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx index 1a0e13c..c5c71c6 100644 --- a/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx +++ b/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx @@ -1,25 +1,182 @@ -import { ReactNode } from 'react'; -import { useCardStack } from '../../CardStackContext'; +"use client"; -export interface ButtonCarouselProps { - children: ReactNode; - className?: string; - ariaLabel?: string; -} +import { memo, Children } from "react"; +import useEmblaCarousel from "embla-carousel-react"; +import { ChevronLeft, ChevronRight } from "lucide-react"; +import CardStackTextBox from "../../CardStackTextBox"; +import { cls } from "@/lib/utils"; +import { ButtonCarouselProps } from "../../types"; +import { usePrevNextButtons } from "../../hooks/usePrevNextButtons"; +import { useScrollProgress } from "../../hooks/useScrollProgress"; +import { useCardAnimation } from "../../hooks/useCardAnimation"; -export function ButtonCarousel({ children, className = '', ariaLabel = 'Button carousel' }: ButtonCarouselProps) { - const { isVisible, getAnimationProps } = useCardStack(); - const animationProps = getAnimationProps(); +const ButtonCarousel = ({ + children, + uniformGridCustomHeightClasses, + animationType, + title, + titleSegments, + description, + tag, + tagIcon, + tagAnimation, + buttons, + buttonAnimation, + textboxLayout = "default", + useInvertedBackground, + bottomContent, + className = "", + containerClassName = "", + carouselClassName = "", + carouselItemClassName = "", + controlsClassName = "", + textBoxClassName = "", + titleClassName = "", + titleImageWrapperClassName = "", + titleImageClassName = "", + descriptionClassName = "", + tagClassName = "", + buttonContainerClassName = "", + buttonClassName = "", + buttonTextClassName = "", + ariaLabel, +}: ButtonCarouselProps) => { + const [emblaRef, emblaApi] = useEmblaCarousel({ dragFree: true }); - return ( -
- {children} -
- ); -} + const { + prevBtnDisabled, + nextBtnDisabled, + onPrevButtonClick, + onNextButtonClick, + } = usePrevNextButtons(emblaApi); -export default ButtonCarousel; + const scrollProgress = useScrollProgress(emblaApi); + + const childrenArray = Children.toArray(children); + const heightClasses = uniformGridCustomHeightClasses || "min-h-80 2xl:min-h-90"; + const { itemRefs, bottomContentRef } = useCardAnimation({ + animationType, + itemCount: childrenArray.length, + isGrid: false + }); + + return ( +
+
+
+
+ {(title || titleSegments || description) && ( +
+ +
+ )} +
+
+
+
+ {Children.map(childrenArray, (child, index) => ( +
{ itemRefs.current[index] = el; }} + > + {child} +
+ ))} +
+
+
+ +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ {bottomContent && ( +
+ {bottomContent} +
+ )} +
+
+
+
+ ); +}; + +ButtonCarousel.displayName = "ButtonCarousel"; + +export default memo(ButtonCarousel);