1+ ---
2+ const navItems = [' Home' , ' Bio' , ' Skills' , ' Projects' , ' Contact' ];
3+ ---
4+
5+ <header class =" fixed top-0 left-0 right-0 z-20 bg-grayblue-800 bg-opacity-90" >
6+ <nav class =" container mx-auto px-6 py-3" >
7+ <!-- Mobile menu button -->
8+ <div class =" flex items-center justify-between md:hidden" >
9+ <a href =" #home" class =" text-grayblue-100 font-medium text-lg" >Jonas <span class =" text-blue-300" >PM</span ></a >
10+ <button id =" mobile-menu-button" class =" text-grayblue-300 hover:text-blue-300 transition-colors focus:outline-none" >
11+ <span class =" material-symbols-rounded transition-transform duration-300" id =" menu-icon" >menu</span >
12+ </button >
13+ </div >
14+
15+ <!-- Desktop navigation -->
16+ <ul class =" hidden md:flex justify-center gap-6" >
17+ { navItems .map ((item ) => (
18+ <li >
19+ <a href = { ` #${item .toLowerCase ()} ` } class = " text-sm font-light uppercase tracking-wider transition-colors text-grayblue-300 hover:text-blue-300" >
20+ { item }
21+ </a >
22+ </li >
23+ ))}
24+ </ul >
25+
26+ <!-- Mobile navigation menu -->
27+ <ul id =" mobile-menu" class =" max-h-0 overflow-hidden md:hidden flex-col flex gap-4 transition-all duration-300 ease-in-out" >
28+ { navItems .map ((item ) => (
29+ <li class = " text-center" >
30+ <a href = { ` #${item .toLowerCase ()} ` } class = " block text-sm font-light uppercase tracking-wider transition-colors text-grayblue-300 hover:text-blue-300" >
31+ { item }
32+ </a >
33+ </li >
34+ ))}
35+ </ul >
36+ </nav >
37+ </header >
38+
39+ <script >
40+ // Mobile menu toggle functionality
41+ const mobileMenuButton = document.getElementById('mobile-menu-button');
42+ const mobileMenu = document.getElementById('mobile-menu');
43+ const menuIcon = document.getElementById('menu-icon');
44+
45+ if (mobileMenuButton && mobileMenu && menuIcon) {
46+ mobileMenuButton.addEventListener('click', () => {
47+ // Toggle menu visibility with animation
48+ if (mobileMenu.classList.contains('max-h-0')) {
49+ mobileMenu.classList.remove('max-h-0');
50+ mobileMenu.classList.add('max-h-96', 'py-2'); // Set a large enough height to accommodate content
51+ menuIcon.textContent = 'close';
52+ menuIcon.classList.add('rotate-180');
53+ } else {
54+ mobileMenu.classList.add('max-h-0');
55+ mobileMenu.classList.remove('max-h-96', 'py-2');
56+ menuIcon.textContent = 'menu';
57+ menuIcon.classList.remove('rotate-180');
58+ }
59+ });
60+
61+ // Close mobile menu when clicking on a link
62+ const mobileMenuLinks = mobileMenu.querySelectorAll('a');
63+ mobileMenuLinks.forEach(link => {
64+ link.addEventListener('click', () => {
65+ mobileMenu.classList.add('max-h-0');
66+ mobileMenu.classList.remove('max-h-96', 'py-2');
67+ menuIcon.textContent = 'menu';
68+ menuIcon.classList.remove('rotate-180');
69+ });
70+ });
71+ }
72+ </script >
0 commit comments