diff --git a/frontend/src/Components/Navbar/Navbar.jsx b/frontend/src/Components/Navbar/Navbar.jsx
index 8d0c486..b738872 100644
--- a/frontend/src/Components/Navbar/Navbar.jsx
+++ b/frontend/src/Components/Navbar/Navbar.jsx
@@ -1,4 +1,3 @@
-// src/Components/Navbar/Navbar.jsx
import React, { useEffect, useState } from "react";
import {
UserCircle,
@@ -9,11 +8,10 @@ import {
Github,
Phone,
HelpCircle,
- MessageCircle,
- MessageSquarePlus
+ X,
} from "lucide-react";
-import { FloatingNav } from "../ui/floating-navbar";
import { Link, useNavigate } from "react-router-dom";
+import { FloatingNav } from "../ui/floating-navbar";
import DarkModeToggle from "../ui/DarkModeToggle";
import { useTimer } from "../../context/TimerContext";
@@ -26,16 +24,96 @@ const publicNavItems = [
{ name: "FAQ", link: "#faq", icon: },
];
+// --- Mobile Navigation Overlay Component (defined in the same file) ---
+const MobileNavOverlay = ({ isOpen, onClose, navItems, isAuthenticated, handleLogout }) => {
+ const overlayClasses = `mobile-nav-overlay ${isOpen ? "open" : ""}`;
+
+ const handleLinkClick = () => {
+ onClose();
+ };
+
+ const handleLogoutClick = () => {
+ handleLogout();
+ onClose();
+ }
+
+ return (
+
+
+
+
+
+ {!isAuthenticated ? (
+ <>
+
+
+
+
+ >
+ ) : (
+ <>
+
+
+ >
+ )}
+
+
+ );
+};
+
+
+// --- Main Navbar Component ---
const Navbar = () => {
const [showFloating, setShowFloating] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
const [displayTime, setDisplayTime] = useState("25:00");
- const [isAuthenticated, setIsAuthenticated] = useState(
- !!localStorage.getItem("token")
- );
+ const [isAuthenticated, setIsAuthenticated] = useState(false);
const navigate = useNavigate();
const { timeLeft, isRunning } = useTimer();
+
+ useEffect(() => {
+ setIsAuthenticated(!!localStorage.getItem("token"));
+ }, []);
+
+ useEffect(() => {
+ const handleResize = () => {
+ if (window.innerWidth >= 1024) {
+ setMenuOpen(false);
+ }
+ };
+
+ window.addEventListener('resize', handleResize);
+
+ return () => window.removeEventListener('resize', handleResize);
+ }, []);
useEffect(() => {
const handleScroll = () => setShowFloating(window.scrollY > 100);
@@ -74,8 +152,6 @@ const Navbar = () => {
style={{ background: "var(--card)", borderColor: "var(--border)" }}
>
- {/* Logo */}
-
{
- {/* Desktop Navigation - visible from lg */}
- {/* Mobile & Tablet Hamburger */}
-
- {menuOpen && (
-
- {!isAuthenticated ? (
- <>
- {publicNavItems.map((item) => (
-
- {item.icon} {item.name}
-
-
- ))}
-
-
-
-
- >
- ) : (
- <>
-
-
Profile
-
-
- {isRunning && (
-
navigate("/pomodoro")}
- className="flex items-center gap-2 cursor-pointer hover:shadow-md hover:shadow-[var(--primary)]/30 transition-all duration-300"
- >
-
-
- {displayTime}
-
-
- )}
-
-
- >
- )}
-
- )}
)}
+ setMenuOpen(false)}
+ navItems={publicNavItems}
+ isAuthenticated={isAuthenticated}
+ handleLogout={handleLogout}
+ />
+
{showFloating && (
)}
@@ -231,3 +257,4 @@ const Navbar = () => {
};
export default Navbar;
+
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 9c60d6d..5113992 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -199,4 +199,86 @@
html {
scroll-behavior: smooth;
-}
\ No newline at end of file
+}
+/* --- Mobile Navigation Overlay --- */
+.mobile-nav-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: var(--color-background); /* Uses your theme color */
+ z-index: 100; /* Ensure it's on top of other content */
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ opacity: 0;
+ pointer-events: none;
+ transition: opacity 0.3s ease-in-out;
+}
+
+.mobile-nav-overlay.open {
+ opacity: 1;
+ pointer-events: auto;
+}
+
+/* --- Navigation Links --- */
+.mobile-nav-overlay nav ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ text-align: center;
+}
+
+.mobile-nav-overlay nav li {
+ margin: 1.5rem 0;
+}
+
+.mobile-nav-overlay nav a {
+ color: var(--color-foreground);
+ text-decoration: none;
+ font-size: 2rem;
+ font-weight: 500;
+ transition: color 0.2s ease;
+}
+
+.mobile-nav-overlay nav a:hover {
+ color: var(--color-primary); /* Uses your theme's primary color */
+}
+
+/* --- Footer Elements (Sign Up & Logout) --- */
+.mobile-nav-footer {
+ position: absolute;
+ bottom: 3rem;
+ display: flex;
+ align-items: center;
+ gap: 1.5rem;
+ width: calc(100% - 4rem);
+ justify-content: center;
+}
+
+.signup-btn-mobile {
+ background-color: var(--color-primary);
+ color: var(--color-primary-foreground);
+ border: none;
+ width: 100%;
+ padding: 0.8rem 1.5rem;
+ border-radius: var(--radius-md);
+ font-size: 1.1rem;
+ font-weight: 600;
+ cursor: pointer;
+}
+
+.logout-btn-mobile {
+ background-color: var(--color-destructive);
+ color: white; /* Assuming destructive buttons should have white text */
+ border: none;
+ width: 100%;
+ padding: 0.8rem 1.5rem;
+ border-radius: var(--radius-md);
+ font-size: 1.1rem;
+ font-weight: 600;
+ cursor: pointer;
+}
+