From 795de61d9ae098575f13cfab9bc25126415edf6c Mon Sep 17 00:00:00 2001 From: Nitish Date: Tue, 28 Apr 2026 00:56:19 +0530 Subject: [PATCH] feat(ui): make instructor cards fully clickable and add scroll-to-top button --- components/InstructorCard.tsx | 21 +++++++++++++------ components/ScrollToTop.tsx | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 components/ScrollToTop.tsx diff --git a/components/InstructorCard.tsx b/components/InstructorCard.tsx index ec6a5ee..3fead4c 100644 --- a/components/InstructorCard.tsx +++ b/components/InstructorCard.tsx @@ -3,30 +3,39 @@ import type { Instructor } from '@/lib/data'; export function InstructorCard({ instructor }: { instructor: Instructor }) { return ( -
+
+

{instructor.location}

{instructor.name}

- + ${instructor.ratePerHour}/hr
+

{instructor.description}

-
+ +
{instructor.specialties.map((tag) => ( {tag} ))}
-
+ +

{instructor.languages.join(' • ')}

- + + View profile
+
); -} +} \ No newline at end of file diff --git a/components/ScrollToTop.tsx b/components/ScrollToTop.tsx new file mode 100644 index 0000000..a5a5101 --- /dev/null +++ b/components/ScrollToTop.tsx @@ -0,0 +1,39 @@ +"use client"; + +import { useEffect, useState } from "react"; + +export function ScrollToTop() { + const [isVisible, setIsVisible] = useState(false); + + useEffect(() => { + const toggleVisibility = () => { + if (window.scrollY > 300) { + setIsVisible(true); + } else { + setIsVisible(false); + } + }; + + window.addEventListener("scroll", toggleVisibility); + return () => window.removeEventListener("scroll", toggleVisibility); + }, []); + + const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: "smooth", + }); + }; + + if (!isVisible) return null; + + return ( + + ); +} \ No newline at end of file