diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index c0c210c..20769cc 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -1,6 +1,6 @@ import { Link, useNavigate } from 'react-router-dom' import { HiUserCircle } from 'react-icons/hi' -import { Fragment } from 'react' +import { Fragment,useEffect,useState } from 'react' import { Menu, Transition } from '@headlessui/react' import "./nav-style.css" @@ -18,18 +18,42 @@ const Navbar = () => { 'About', 'Contact Us', ] + const [navbar, setNavbar] = useState(false) const navigate = useNavigate() let token = sessionStorage.getItem('token') const page = (item) => { if (item === 'Contact Us') navigate('/contact') else if (item === 'About') navigate('/about-us') } + + + //navbar scroll changeBackground function + const changeBackground = () => { + if (window.scrollY >= 100) { + setNavbar(true) + } + else { + setNavbar(false) + } + } + + useEffect(() => { + changeBackground() + // adding the event when scroll change background + window.addEventListener("scroll", changeBackground) + }) + + + return ( + +
-
+
{ ) : ( -
+
Login
diff --git a/src/components/Navbar/nav-style.css b/src/components/Navbar/nav-style.css index 957a439..1139d60 100644 --- a/src/components/Navbar/nav-style.css +++ b/src/components/Navbar/nav-style.css @@ -6,8 +6,42 @@ transition: background-size 300ms ease-in; } +.login:hover{ + background-color: black; + color: white; + transition: all ease-in 0.4s; +} + +/* @media (top:10vh) { + + .navbar{ + background-color: black; + } +} */ + +.navbar.active { + background-color: rgb(0, 0, 0); + +} + +.navbar.active a{ + transition: all ease 0.3s; + color:white; +} + +.navbar.active button{ + transition: all ease-in 0.3s; + + color: white; +} + +.login:hover{ + border: 0.5px white solid; +} + .nav-btn:hover { transform: scale(1.15); background-size: 1100% ; -} \ No newline at end of file +} +