diff --git a/nx-dev/ui-customers/src/lib/customer-testimonial-carousel.tsx b/nx-dev/ui-customers/src/lib/customer-testimonial-carousel.tsx index 152e310444703..441c0a2259e94 100644 --- a/nx-dev/ui-customers/src/lib/customer-testimonial-carousel.tsx +++ b/nx-dev/ui-customers/src/lib/customer-testimonial-carousel.tsx @@ -1,11 +1,14 @@ -import { Fragment, useState } from 'react'; +'use client'; +import { Fragment, useState, useRef, useEffect } from 'react'; import { Dialog, Transition } from '@headlessui/react'; import { PlayIcon } from '@heroicons/react/24/outline'; import Image from 'next/image'; +// TODO - move this to a data type file interface Testimonial { title: string; subtitle: string; + accentColor?: string; metrics?: { value: string; label: string; @@ -33,6 +36,7 @@ const testimonials: Testimonial[] = [ ], videoId: '2BLqiNnBPuU', thumbnail: '/images/customers/video-story-pavlo-grosse.avif', + accentColor: 'orange-600', }, { title: 'Customer story', @@ -115,13 +119,52 @@ const testimonials: Testimonial[] = [ export function CustomerTestimonialCarousel(): JSX.Element { const [currentIndex, setCurrentIndex] = useState(0); const [isOpen, setIsOpen] = useState(false); + const [isBelowMd, setIsBelowMd] = useState(false); const currentTestimonial = testimonials[currentIndex]; + const ulRef = useRef(null); + + useEffect(() => { + const mediaQuery = window.matchMedia('(max-width: 768px)'); + + const handleResize = () => { + setIsBelowMd(mediaQuery.matches); + }; + + // Initial check + handleResize(); + + // Attach listener + mediaQuery.addEventListener('change', handleResize); + + return () => { + // Clean up listener + mediaQuery.removeEventListener('change', handleResize); + }; + }, []); + + useEffect(() => { + let timer: NodeJS.Timeout | null = null; + + if (isBelowMd) { + timer = setInterval(() => { + setCurrentIndex((currentIndex + 1) % testimonials.length); + }, 7000); + } else if (timer) { + clearInterval(timer); + } + + return () => { + if (timer) { + clearInterval(timer); + } + }; + }, [isBelowMd, setCurrentIndex, currentIndex]); return (
-
+
{/* Left side - Quote or Metrics */} -
+
{currentTestimonial.quote ? (
@@ -177,9 +220,9 @@ export function CustomerTestimonialCarousel(): JSX.Element {
{/* Right side - Video Card */} -
+
setIsOpen(true)} > {/* Thumbnail */} @@ -192,7 +235,13 @@ export function CustomerTestimonialCarousel(): JSX.Element { /> {/* Gradient Overlay */} -
+
{/* Content Overlay */}
@@ -206,21 +255,19 @@ export function CustomerTestimonialCarousel(): JSX.Element {
- {/* Navigation dots */} -
+ {/* Mobile Navigation display dots */} +
    {testimonials.map((_, index) => ( -
+
diff --git a/nx-dev/ui-customers/src/lib/enterprise-customers.tsx b/nx-dev/ui-customers/src/lib/enterprise-customers.tsx index 2a3dc7a49f5b6..69890617f3a8e 100644 --- a/nx-dev/ui-customers/src/lib/enterprise-customers.tsx +++ b/nx-dev/ui-customers/src/lib/enterprise-customers.tsx @@ -117,7 +117,7 @@ export function EnterpriseCustomers(): JSX.Element { >