From cc413c8c5352a297417bbfdcb3cd83e306240279 Mon Sep 17 00:00:00 2001 From: bender Date: Mon, 9 Mar 2026 08:26:27 +0000 Subject: [PATCH] Switch to version 1: modified src/components/cardStack/layouts/carousels/ButtonCarousel.tsx --- .../layouts/carousels/ButtonCarousel.tsx | 202 ++++++++++++++++-- 1 file changed, 179 insertions(+), 23 deletions(-) diff --git a/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx b/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx index baaa4f4..c5c71c6 100644 --- a/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx +++ b/src/components/cardStack/layouts/carousels/ButtonCarousel.tsx @@ -1,26 +1,182 @@ -import React, { useRef } from "react"; -import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation"; +"use client"; -interface ButtonCarouselProps { - items?: any[]; -} +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 default function ButtonCarousel({ items = [] }: ButtonCarouselProps) { - const state = useCardAnimation({ - rotationX: 0, - rotationY: 0, - rotationZ: 0, - perspective: 1000, - duration: 0.3, - }); +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 ( -
- {items.map((item, index) => ( -
- {item.label} -
- ))} -
- ); -} + const { + prevBtnDisabled, + nextBtnDisabled, + onPrevButtonClick, + onNextButtonClick, + } = usePrevNextButtons(emblaApi); + + 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);