From dc0dadb481a40ba5b8f1a1450ad94f9427e49ce8 Mon Sep 17 00:00:00 2001 From: TechWIthTy <37724661+TechWithTy@users.noreply.github.com> Date: Mon, 17 Feb 2025 11:35:37 -0700 Subject: [PATCH] Updated List View Only Show 3 experience cards max and have option to show more if available. Also scrolls back up to experience header. --- app/components/homepage/experience/index.jsx | 107 ++++++++++++------- 1 file changed, 71 insertions(+), 36 deletions(-) diff --git a/app/components/homepage/experience/index.jsx b/app/components/homepage/experience/index.jsx index 398c2e67..b5908034 100644 --- a/app/components/homepage/experience/index.jsx +++ b/app/components/homepage/experience/index.jsx @@ -1,15 +1,37 @@ +"use client"; // @flow strict - +import { useState, useRef } from "react"; import { experiences } from "@/utils/data/experience"; import Image from "next/image"; import { BsPersonWorkspace } from "react-icons/bs"; -import experience from '../../../assets/lottie/code.json'; +import experience from "../../../assets/lottie/code.json"; import AnimationLottie from "../../helper/animation-lottie"; import GlowCard from "../../helper/glow-card"; function Experience() { + const [showAll, setShowAll] = useState(false); + const experienceRef = useRef(null); // Reference to experience section + + const toggleExperiences = () => { + setShowAll(!showAll); + + // Wait for UI update, then scroll to experience section + setTimeout(() => { + experienceRef.current?.scrollIntoView({ + behavior: "smooth", + block: "start", + }); + }, 100); // Small delay ensures the UI updates before scrolling + }; + + const visibleExperiences = showAll ? experiences : experiences.slice(0, 3); + return ( -
+
Hero
-
+
Experiences @@ -38,45 +60,58 @@ function Experience() {
- { - experiences.map(experience => ( - -
- Hero -
-

- {experience.duration} -

+ {visibleExperiences.map((experience) => ( + +
+ Hero +
+

+ {experience.duration} +

+
+
+
+
-
-
- -
-
-

- {experience.title} -

-

- {experience.company} -

-
+
+

+ {experience.title} +

+

+ {experience.company} +

- - )) - } +
+ + ))}
+ + {/* Show More / Show Less Button */} + {experiences.length > 3 && ( +
+ +
+ )}
); -}; +} -export default Experience; \ No newline at end of file +export default Experience;