From 7391bd436a7d8415da7d59bec93a5dfbfd1a69a8 Mon Sep 17 00:00:00 2001 From: Vaishnavi Thakur Date: Wed, 27 May 2026 12:10:21 +0530 Subject: [PATCH 1/3] feat: add Back to Top button for better navigation on long pages Signed-off-by: Vaishnavi Thakur --- .../src/components/Layout/BackToTop.jsx | 53 +++++++++++++++++++ .../src/components/Layout/MainLayout.jsx | 3 +- .../src/pages/LandingPage/index.jsx | 3 +- 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 apps/web-dashboard/src/components/Layout/BackToTop.jsx diff --git a/apps/web-dashboard/src/components/Layout/BackToTop.jsx b/apps/web-dashboard/src/components/Layout/BackToTop.jsx new file mode 100644 index 000000000..f49967cd9 --- /dev/null +++ b/apps/web-dashboard/src/components/Layout/BackToTop.jsx @@ -0,0 +1,53 @@ +import { useState, useEffect } from 'react'; +function BackToTop() { + const [isVisible, setIsVisible] = useState(false); + useEffect(() => { + const handleScroll = () => { + if (window.scrollY > 300) { + setIsVisible(true); + } else { + setIsVisible(false); + } + }; + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }, []); + const handleClick = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth' + }); + }; + if (!isVisible) { + return null; + } + return ( + + ); +} +export default BackToTop; \ No newline at end of file diff --git a/apps/web-dashboard/src/components/Layout/MainLayout.jsx b/apps/web-dashboard/src/components/Layout/MainLayout.jsx index c4139efa4..a16bcc5c9 100644 --- a/apps/web-dashboard/src/components/Layout/MainLayout.jsx +++ b/apps/web-dashboard/src/components/Layout/MainLayout.jsx @@ -4,7 +4,7 @@ import Sidebar from './Sidebar'; import Header from './Header'; import ProjectNavbar from './ProjectNavbar'; import { useLayout } from '../../context/LayoutContext'; - +import BackToTop from './BackToTop'; // Use the new official logo from public directory const logoImage = "https://cdn.jsdelivr.net/gh/yash-pouranik/urBackend@main/frontend/public/logo.png"; @@ -68,6 +68,7 @@ function MainLayout({ children }) { {children} + ); } diff --git a/apps/web-dashboard/src/pages/LandingPage/index.jsx b/apps/web-dashboard/src/pages/LandingPage/index.jsx index 2d91cccba..55094e8f9 100644 --- a/apps/web-dashboard/src/pages/LandingPage/index.jsx +++ b/apps/web-dashboard/src/pages/LandingPage/index.jsx @@ -1,7 +1,7 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { useAuth } from '../../context/AuthContext'; - +import BackToTop from '../../components/Layout/BackToTop'; import { Database, Shield, @@ -907,6 +907,7 @@ function LandingPage() {