From 0479b7330ae576d81dd604244d6fe8219b27f650 Mon Sep 17 00:00:00 2001 From: sasha-astiadi Date: Fri, 19 Sep 2025 00:39:00 +0200 Subject: [PATCH] feat: add mobile carousel view with auto-play for BentoReviews component --- src/components/BentoReviews.tsx | 119 +++++++++++++++++++++++++------ src/components/ui/bento-grid.tsx | 2 +- 2 files changed, 100 insertions(+), 21 deletions(-) diff --git a/src/components/BentoReviews.tsx b/src/components/BentoReviews.tsx index 6f6909a..93ba1b2 100644 --- a/src/components/BentoReviews.tsx +++ b/src/components/BentoReviews.tsx @@ -2,8 +2,10 @@ import { cn } from "@/lib/utils"; import { H2, P } from "@/components/Texts"; -import React from "react"; +import React, { useState, useEffect, useRef } from "react"; import { BentoGrid, MotionBentoGridItem } from "@/components/ui/bento-grid"; +import { AnimatePresence, motion } from "framer-motion"; +import { ChevronLeft, ChevronRight } from "lucide-react"; import { FadeIn } from "./FadeIn"; const items = [ @@ -53,6 +55,42 @@ const items = [ ]; export function BentoReviews() { + const [activeIndex, setActiveIndex] = useState(0); + const [isPaused, setIsPaused] = useState(false); + const intervalRef = useRef(null); + + useEffect(() => { + if (!isPaused) { + intervalRef.current = setInterval(() => { + setActiveIndex((prevIndex) => (prevIndex + 1) % items.length); + }, 3000); + } else { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + } + + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + }; + }, [isPaused]); + + const handleCardTap = () => { + setIsPaused(true); + }; + + const handlePrev = () => { + setActiveIndex((prevIndex) => (prevIndex - 1 + items.length) % items.length); + setIsPaused(true); + }; + + const handleNext = () => { + setActiveIndex((prevIndex) => (prevIndex + 1) % items.length); + setIsPaused(true); + }; + return (
@@ -64,29 +102,70 @@ export function BentoReviews() {

- A robust infrastructure layer for autonomous AI agents, our technology stack - delivers a secure, efficient, and intuitive platform for deploying and managing AI agents at scale. + A robust infrastructure layer for autonomous AI agents, our technology stack + delivers a secure, efficient, and intuitive platform for deploying and managing AI agents at scale.

- - {items.map((item, i) => ( - = 3 ? "h-[22rem]" : ""} - title={item.title} - subtitle={item.subtitle} - description={item.description} - video={item.video} - /> - ))} - + + {/* Desktop Grid */} +
+ + {items.map((item, i) => ( + = 3 ? "h-[22rem]" : ""} + title={item.title} + subtitle={item.subtitle} + description={item.description} + video={item.video} + /> + ))} + +
+ + {/* Mobile Carousel */} +
+
+
+ + + + + + + +
+
); } diff --git a/src/components/ui/bento-grid.tsx b/src/components/ui/bento-grid.tsx index 831e2dd..6499c16 100644 --- a/src/components/ui/bento-grid.tsx +++ b/src/components/ui/bento-grid.tsx @@ -44,7 +44,7 @@ export const BentoGridItem = React.forwardRef -
+
{video ? (