diff --git a/src/app/_components/testimonials/page.tsx b/src/app/_components/testimonials/page.tsx index d7f7886..4b17d3c 100644 --- a/src/app/_components/testimonials/page.tsx +++ b/src/app/_components/testimonials/page.tsx @@ -1,84 +1,122 @@ "use client"; +import React, { useEffect, useRef, useState, MouseEvent } from "react"; -import React, { useEffect, useState } from "react"; +interface Testimonial { + name: string; + position: string; + image: string; + quote: string; +} export default function Testimonials() { - const [currentIndex, setCurrentIndex] = useState(0); - // const [autoSlideInterval, setAutoSlideInterval] = useState(null); - - const nextSlide = () => { - setCurrentIndex((prevIndex) => - prevIndex === testimonials.length - 1 ? 0 : prevIndex + 1, - ); - }; - - // const prevSlide = () => { - // setCurrentIndex((prevIndex) => - // prevIndex === 0 ? testimonials.length - 1 : prevIndex - 1, - // ); - // }; - useEffect(() => { - const interval = setInterval(nextSlide, 5000); // Slide every 5 seconds - // setAutoSlideInterval(interval); - return () => clearInterval(interval); // Clean up interval on component unmount - }, []); - - const testimonials = [ + const [currentIndex, setCurrentIndex] = useState(0); // شروع با آیتم وسطی + const sliderRef = useRef(null); + const [isHovered, setIsHovered] = useState(false); + const [bulletClicked, setBulletClicked] = useState(false); + const [maxHeight, setMaxHeight] = useState(0); + const testimonials: Testimonial[] = [ { name: "Sarah Johnson", position: "Founder & CEO of Innovate Solutions", image: "/images/user-1.svg", quote: - "Lorem ipsum dolor sit amet consectetur. In enim cursus odio accumsan. Id leo urna velit neque mattis id tellus arcu ondimentum. Augue dictum dolor elementum convallis dignissim malesuada commodo ultrices.", + 'The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.', }, { name: "Michael Lee", position: "Chief Executive Officer at Tech Innovators", image: "/images/user-1.svg", quote: - "Lorem ipsum dolor sit amet consectetur. In enim cursus odio accumsan. Id leo urna velit neque mattis id tellus arcu ondimentum. Augue dictum dolor elementum convallis dignissim malesuada commodo ultrices.", + "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.", }, { name: "Emma Davis", position: "CEO & Lead Strategist at Visionary Ventures", image: "/images/user-1.svg", quote: - "Lorem ipsum dolor sit amet consectetur. In enim cursus odio accumsan. Id leo urna velit neque mattis id tellus arcu ondimentum. Augue dictum dolor elementum convallis dignissim malesuada commodo ultrices.", + "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.", + }, + { + name: "John Doe", + position: "COO at Startup Labs", + image: "/images/user-1.svg", + quote: + "All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet.", + }, + { + name: "Jane Smith", + position: "Founder at Health Innovations", + image: "/images/user-1.svg", + quote: + "It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.", }, ]; + // Auto-scroll every 5 seconds + useEffect(() => { + if (sliderRef.current) { + let maxHeight = 0; + + // Iterate through each child of the slider + Array.from(sliderRef.current.children).forEach((child) => { + const childHeight = child.clientHeight; // Get the height of the child + if (childHeight > maxHeight) { + maxHeight = childHeight; // Update maxHeight if current child is taller + } + }); + + setMaxHeight(maxHeight + 20); // Set the maximum height + } + + if (!isHovered && !bulletClicked) { + const interval = setInterval(() => { + setCurrentIndex((prevIndex) => + prevIndex === testimonials.length - 1 ? 0 : prevIndex + 1, + ); + }, 2000); + return () => clearInterval(interval); + } + }, [isHovered, bulletClicked]); + return (
-

Testominials

+

Testimonials

Lorem ipsum dolor sit amet consectetur. Mollis erat duis aliquam mauris est risus lectus. Phasellus consequat urna tellus

-
+
setIsHovered(true)} + onMouseLeave={() => { + setIsHovered(false); + setBulletClicked(false); + }} + > {testimonials.map((testimonial, index) => (
-
+
user profile picture
-
+

- + {testimonial.quote} - @@ -93,6 +131,7 @@ export default function Testimonials() {

))}
+
    {testimonials.map((_, index) => (
  • setCurrentIndex(index)} + onClick={() => { + setCurrentIndex(index); + setBulletClicked(true); + }} >
  • ))}
diff --git a/src/app/globals.css b/src/app/globals.css index ac16160..1a36b35 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -272,3 +272,13 @@ html { opacity: 0.95; transition: all ease-in-out 0.5s; } +.no-scrollbar::-webkit-scrollbar { + display: none; +} +.no-scrollbar { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ +} +.testimonial{ + transition: all ease-in-out 0.5s; +} \ No newline at end of file