-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The hamburger menu is working perfectly when clicked on it.
- Loading branch information
1 parent
dcd355c
commit 1f8d10d
Showing
2 changed files
with
22 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,42 @@ | ||
import React from "react"; | ||
import React, { useState } from "react"; | ||
import { NavLink, useLocation } from "react-router-dom"; | ||
|
||
const Navbar = () => { | ||
const location = useLocation(); | ||
const [isMenuOpen, setMenuOpen] = useState(false); | ||
|
||
const isActive = (path) => location.pathname === path ? 'text-[#00bfff] underline' : 'text-white'; | ||
|
||
return ( | ||
<nav className="z-50 h-16 flex justify-center sticky top-0 w-screen backdrop-filter backdrop-blur-lg bg-opacity-40 p-4"> | ||
<nav className="z-50 h-16 flex items-center justify-between sticky top-0 w-screen backdrop-filter backdrop-blur-lg bg-opacity-40 p-4"> | ||
<style> | ||
@import url('https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css'); | ||
@import url('https://cdn.jsdelivr.net/npm/[email protected]/fonts/remixicon.css'); | ||
</style> | ||
<ul className="flex flex-col md:flex-row justify-center items-center list-none m-0 p-4 gap-x-0 md:gap-x-10 text-sm md:text-base lg:text-lg xl:text-xl 2xl:text-3xl"> | ||
<li className="hover:underline block md:hidden"> | ||
<span className="fa fa-bars"></span> | ||
<button | ||
className="block md:hidden p-2" | ||
onClick={() => setMenuOpen(!isMenuOpen)} | ||
aria-label="Toggle navigation menu" | ||
> | ||
<i className="ri-menu-line text-white text-2xl"></i> | ||
</button> | ||
<ul className={`absolute md:relative top-full left-0 md:left-auto md:top-auto w-full md:flex md:items-center md:justify-center md:bg-transparent transition-all duration-300 ease-in-out ${isMenuOpen ? 'flex' : 'hidden'} flex-col md:flex-row list-none m-0 p-4 gap-x-10 text-sm md:text-base lg:text-lg xl:text-xl 2xl:text-3xl`}> | ||
<li className="hover:underline text-white md:text-black text-center md:text-left"> | ||
<NavLink to="/" className={isActive('/')}><i className="ri-home-fill"></i> Home</NavLink> | ||
</li> | ||
<li className="hover:underline hidden md:block"> | ||
<NavLink to="/" className={isActive('/')}><i class="ri-home-fill"></i> Home</NavLink> | ||
<li className="hover:underline text-white md:text-black text-center md:text-left"> | ||
<NavLink to="/AboutUs" className={isActive('/AboutUs')}><i className="ri-building-fill"></i> About Us</NavLink> | ||
</li> | ||
<li className="hover:underline hidden md:block"> | ||
<NavLink to="/AboutUs" className={isActive('/AboutUs')}><i class="ri-building-fill"></i> About Us</NavLink> | ||
<li className="hover:underline text-white md:text-black text-center md:text-left"> | ||
<NavLink to="/DemoSection" className={isActive('/DemoSection')}><i className="ri-service-fill"></i> Demo Section</NavLink> | ||
</li> | ||
<li className="hover:underline hidden md:block"> | ||
<NavLink to="/DemoSection" className={isActive('/DemoSection')}><i class="ri-service-fill"></i> Demo Section</NavLink> | ||
<li className="hover:underline text-white md:text-black text-center md:text-left"> | ||
<NavLink to="/Models" className={isActive('/Models')}><i className="ri-layout-2-fill"></i> Models</NavLink> | ||
</li> | ||
<li className="hover:underline hidden md:block"> | ||
<NavLink to="/Models" className={isActive('/Models')}><i class="ri-layout-2-fill"></i> Models</NavLink> | ||
</li> | ||
<li className="hover:underline hidden md:block"> | ||
<NavLink to="/ContactUs" className={isActive('/ContactUs')}><i class="ri-customer-service-2-fill"></i> Contact Us</NavLink> | ||
<li className="hover:underline text-white md:text-black text-center md:text-left"> | ||
<NavLink to="/ContactUs" className={isActive('/ContactUs')}><i className="ri-customer-service-2-fill"></i> Contact Us</NavLink> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
); | ||
}; | ||
export default Navbar; |