diff --git a/.gitignore b/.gitignore index 85ff08a..ef8488a 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ dist-ssr *.sln *.sw? +.env.local + .next/ \ No newline at end of file diff --git a/public/Online_hvit.png b/public/Online_hvit.png deleted file mode 100644 index f5e07dd..0000000 Binary files a/public/Online_hvit.png and /dev/null differ diff --git a/public/Online_hvit_o.svg b/public/Online_hvit_o.svg new file mode 100644 index 0000000..1bc5db7 --- /dev/null +++ b/public/Online_hvit_o.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/public/Bekk_navnetrekk_hvit.svg b/public/bekk_white.svg similarity index 99% rename from public/Bekk_navnetrekk_hvit.svg rename to public/bekk_white.svg index 4f9b281..67818f7 100644 --- a/public/Bekk_navnetrekk_hvit.svg +++ b/public/bekk_white.svg @@ -19,4 +19,4 @@ L360.7,183.5z"/> - + \ No newline at end of file diff --git a/src/components/all/Navbar.tsx b/src/components/all/Navbar.tsx index 8d38c74..c687949 100644 --- a/src/components/all/Navbar.tsx +++ b/src/components/all/Navbar.tsx @@ -13,16 +13,39 @@ const navLinks = [ const Navbar = () => { const [showNavbar, setShowNavbar] = useState(true); const [lastScroll, setLastScroll] = useState(0); - const [showNavMenu, setShowNavMenu] = useState(false); - const dropdownRef = useRef(null); + useEffect(() => { + const controlNavbar = () => { + const currentScroll = window.scrollY; + + setShowNavbar(currentScroll <= lastScroll); + setLastScroll(currentScroll); + }; + window.addEventListener('scroll', controlNavbar); + + return () => { + window.removeEventListener('scroll', controlNavbar); + }; + }, [lastScroll]); - const controlNavbar = () => { - const currentScroll = window.scrollY; + return ( +
+ + +
+ ); +}; + +export default Navbar; - setShowNavbar(currentScroll <= lastScroll); - setLastScroll(currentScroll); - }; +const MobileNavbar = () => { + const [showNavMenu, setShowNavMenu] = useState(false); + const dropdownRef = useRef(null); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { @@ -35,21 +58,14 @@ const Navbar = () => { }; document.addEventListener('mousedown', handleClickOutside); - window.addEventListener('scroll', controlNavbar); return () => { document.removeEventListener('mousedown', handleClickOutside); - window.removeEventListener('scroll', controlNavbar); }; - }, [lastScroll]); + }, []); return ( -
+
{ Onlinefondet - {/* DESKTOP NAVBAR */} -
- {navLinks.map((link) => ( - - {link.title} - - ))} -
- - {/* MOBILE HAMBURGER MENU */} -
+ {/* HAMBURGER MENU */} +
{showNavMenu && ( { key={link.title} to={link.path} className="block py-2 px-4 hover:bg-[#1e2334] transition text-lg" + onClick={() => setShowNavMenu(false)} > {link.title} @@ -92,16 +96,35 @@ const Navbar = () => { )}
- - - Bekk logo -
); }; -export default Navbar; +const DesktopNavbar = () => ( +
+ + Onlinefondet + + + {/* NAV-ITEMS */} +
+ {navLinks.map((link) => ( + + {link.title} + + ))} +
+ + + Bekk logo + +
+); diff --git a/tsconfig.json b/tsconfig.json index 1ffef60..c452f43 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,4 +4,4 @@ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ] -} +} \ No newline at end of file