diff --git a/frontend/src/Components/Navbar/Navbar.jsx b/frontend/src/Components/Navbar/Navbar.jsx index df3a19c..20b0531 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, @@ -8,11 +7,13 @@ import { Github, Phone, HelpCircle, + X, } from "lucide-react"; import { FloatingNav } from "../ui/floating-navbar"; import { Link, useNavigate } from "react-router-dom"; import DarkModeToggle from "../ui/DarkModeToggle"; import { useTimer } from "../../context/TimerContext"; +// import "./MobileNav.css"; // Import the new CSS file - REMOVED const publicNavItems = [ { @@ -42,6 +43,74 @@ const publicNavItems = [ }, ]; +// --- Mobile Navigation Overlay Component --- +// Kept in the same file for simplicity +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); @@ -90,8 +159,6 @@ const Navbar = () => { style={{ background: "var(--card)", borderColor: "var(--border)" }} >
- {/* Logo */} -

{

- {/* Desktop Navigation - visible from lg */} + {/* Desktop Navigation */} {/* 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} - -
- )} - - - - )} -
- )}
)} + {/* Render the full-screen overlay */} + setMenuOpen(false)} + navItems={publicNavItems} + isAuthenticated={isAuthenticated} + handleLogout={handleLogout} + /> + {showFloating && ( )} @@ -247,3 +267,4 @@ const Navbar = () => { }; export default Navbar; + diff --git a/frontend/src/Components/Navbar/NavbarOverlay.jsx b/frontend/src/Components/Navbar/NavbarOverlay.jsx new file mode 100644 index 0000000..470c7dd --- /dev/null +++ b/frontend/src/Components/Navbar/NavbarOverlay.jsx @@ -0,0 +1,73 @@ +// src/Components/Navbar/MobileNavOverlay.jsx + +import React from "react"; +import { Link } from "react-router-dom"; +import { X, UserCircle, Clock } from "lucide-react"; +import DarkModeToggle from "../ui/DarkModeToggle"; + +const MobileNavOverlay = ({ + isOpen, + onClose, + navItems, + isAuthenticated, + handleLogout, +}) => { + // Use a template literal to conditionally apply the 'open' class + const overlayClasses = `mobile-nav-overlay ${isOpen ? "open" : ""}`; + + return ( +
+ + + {/* Main Navigation Links */} + + + {/* Footer Actions */} +
+ {!isAuthenticated ? ( + <> + + + + + + ) : ( + <> + + + + )} +
+
+ ); +}; + +export default MobileNavOverlay; \ No newline at end of file diff --git a/frontend/src/index.css b/frontend/src/index.css index 6c6c280..45d0df6 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -134,4 +134,96 @@ html{ scroll-behavior: smooth; +} + +.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 */ + 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; +} + +/* --- Close Button --- */ +.close-btn { + position: absolute; + top: 2rem; + right: 2rem; + background: none; + border: none; + color: var(--color-foreground); + cursor: pointer; +} + +/* --- 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; + border: none; + width: 100%; + padding: 0.8rem 1.5rem; + border-radius: var(--radius-md); + font-size: 1.1rem; + font-weight: 600; + cursor: pointer; } \ No newline at end of file