diff --git a/frontend/src/components/MainNavbar.tsx b/frontend/src/components/MainNavbar.tsx index ce548fa..359a996 100644 --- a/frontend/src/components/MainNavbar.tsx +++ b/frontend/src/components/MainNavbar.tsx @@ -1,177 +1,104 @@ import React, { useEffect, useState, useRef } from "react"; -import { Outlet, useNavigate, Link } from "react-router-dom"; +import { Outlet, useNavigate, Link, useLocation } from "react-router-dom"; import { gsap } from "gsap"; interface NavbarProps { btnName: string; navigateUrl: string; display: boolean; + loadingUsr: boolean; } -const Navbar: React.FC = ({ btnName, navigateUrl, display }) => { +const Navbar: React.FC = ({ btnName, navigateUrl, display, loadingUsr }) => { const navigate = useNavigate(); + const location = useLocation(); const [isSidebarOpen, setIsSidebarOpen] = useState(false); - const sidebarRef = useRef(null); // Ref for the sidebar + const sidebarRef = useRef(null); useEffect(() => { if (isSidebarOpen) { - gsap.fromTo( - sidebarRef.current, - { x: -250, opacity: 0 }, // Start position and opacity - { x: 0, opacity: 1, duration: 0.3 } // End position and opacity - ); + gsap.fromTo(sidebarRef.current, { x: -250, opacity: 0 }, { x: 0, opacity: 1, duration: 0.3 }); } }, [isSidebarOpen]); useEffect(() => { if (location.pathname === "/") navigate("/homepage"); - }, [location, navigate]); + }, [location.pathname, navigate]); - // Close sidebar function with GSAP animation const closeSidebar = () => { gsap.to(sidebarRef.current, { x: -250, opacity: 0, duration: 0.3, - onComplete: () => setIsSidebarOpen(false), // Set sidebar state after animation + onComplete: () => setIsSidebarOpen(false), }); }; return ( <> - {/* Sidebar for Small Screens */} {isSidebarOpen && ( -
+
e.stopPropagation()} // Prevent closing on inner click + onClick={(e) => e.stopPropagation()} > - )} {userDetails && ( - - )} - - -
-
-

- Grow your network,
- all are connected in{" "} - Campus Chatter -

-

- Our platform offers a variety of features to help you stay - connected, including instant messaging, video chat, and news feeds. -

- {!userDetails && ( - - )} - {userDetails && ( +
- )} -
+
+ )} + + )} +
hero
-
-
- -
-
- {} -
-
-
-

{"Engage In Community"}

- -
-
-
-
- {} -
-
-
-

{"Discover New Connections"}

- -
-
-
-
- {} -
-
-
-

{"Share Ideas And Creativity"}

- -
-
-
-
- {} -
-
-
-

{"Access Information And News"}

- -
-
- - -
-
-

Why
Campus Chatter?

-

- Campus Chatter can provide users with a wide range of benefits, from staying connected with loved ones to discovering new connections and engaging in creative expression and community building. -

- -
+
+
+ {/* Feature Cards */} + {["Engage In Community", "Discover New Connections", "Share Ideas And Creativity", "Access Information And News"].map((title, index) => ( +
+
+ {index === 0 && } + {index === 1 && } + {index === 2 && } + {index === 3 && }
-
+
+
+

{title}

+ +
+
+ ))} +
+
+

Why
Campus Chatter?

+

+ Campus Chatter can provide users with a wide range of benefits, from staying connected with loved ones to discovering new connections and engaging in creative expression and community building. +

+ +
+ + ); };