|
39 | 39 | </div> |
40 | 40 | </div> |
41 | 41 | <div class="flex items-center gap-4"> |
42 | | - <a href="/api/stats" class="text-sm text-gray-500 hover:text-gray-700">API</a> |
| 42 | + <a href="/api/stats" class="hidden sm:inline text-sm text-gray-500 hover:text-gray-700">API</a> |
| 43 | + <!-- Mobile menu button --> |
| 44 | + <button id="mobile-menu-button" class="sm:hidden inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500"> |
| 45 | + <span class="sr-only">Open main menu</span> |
| 46 | + <!-- Hamburger icon --> |
| 47 | + <svg class="block h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> |
| 48 | + <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" /> |
| 49 | + </svg> |
| 50 | + <!-- Close icon (hidden by default) --> |
| 51 | + <svg class="hidden h-6 w-6" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> |
| 52 | + <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /> |
| 53 | + </svg> |
| 54 | + </button> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + <!-- Mobile menu --> |
| 58 | + <div id="mobile-menu" class="hidden sm:hidden"> |
| 59 | + <div class="pt-2 pb-3 space-y-1"> |
| 60 | + <a href="/" data-nav-mobile="search" class="nav-link-mobile border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium"> |
| 61 | + Search |
| 62 | + </a> |
| 63 | + <a href="/feeds" data-nav-mobile="feeds" class="nav-link-mobile border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium"> |
| 64 | + Feeds |
| 65 | + </a> |
| 66 | + <a href="/about" data-nav-mobile="about" class="nav-link-mobile border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium"> |
| 67 | + About |
| 68 | + </a> |
| 69 | + <a href="/api/stats" class="border-transparent text-gray-500 hover:bg-gray-50 hover:border-gray-300 hover:text-gray-700 block pl-3 pr-4 py-2 border-l-4 text-base font-medium"> |
| 70 | + API |
| 71 | + </a> |
43 | 72 | </div> |
44 | 73 | </div> |
45 | 74 | </nav> |
|
66 | 95 | </div> |
67 | 96 | </footer> |
68 | 97 |
|
| 98 | + <!-- Mobile Menu Toggle Script --> |
| 99 | + <script> |
| 100 | + (function() { |
| 101 | + const menuButton = document.getElementById('mobile-menu-button'); |
| 102 | + const mobileMenu = document.getElementById('mobile-menu'); |
| 103 | + const hamburgerIcon = menuButton.querySelector('svg:first-of-type'); |
| 104 | + const closeIcon = menuButton.querySelector('svg:last-of-type'); |
| 105 | + |
| 106 | + menuButton.addEventListener('click', function() { |
| 107 | + const isHidden = mobileMenu.classList.contains('hidden'); |
| 108 | + |
| 109 | + if (isHidden) { |
| 110 | + mobileMenu.classList.remove('hidden'); |
| 111 | + hamburgerIcon.classList.add('hidden'); |
| 112 | + closeIcon.classList.remove('hidden'); |
| 113 | + } else { |
| 114 | + mobileMenu.classList.add('hidden'); |
| 115 | + hamburgerIcon.classList.remove('hidden'); |
| 116 | + closeIcon.classList.add('hidden'); |
| 117 | + } |
| 118 | + }); |
| 119 | + })(); |
| 120 | + </script> |
| 121 | + |
69 | 122 | <!-- Active Navigation Script --> |
70 | 123 | <script> |
71 | 124 | (function() { |
72 | 125 | const path = window.location.pathname; |
73 | 126 | const navLinks = document.querySelectorAll('.nav-link'); |
| 127 | + const navLinksMobile = document.querySelectorAll('.nav-link-mobile'); |
74 | 128 |
|
| 129 | + // Desktop navigation |
75 | 130 | navLinks.forEach(link => { |
76 | 131 | const navType = link.getAttribute('data-nav'); |
77 | 132 | let isActive = false; |
|
89 | 144 | link.classList.add('border-orange-600', 'text-gray-900'); |
90 | 145 | } |
91 | 146 | }); |
| 147 | + |
| 148 | + // Mobile navigation |
| 149 | + navLinksMobile.forEach(link => { |
| 150 | + const navType = link.getAttribute('data-nav-mobile'); |
| 151 | + let isActive = false; |
| 152 | + |
| 153 | + if (navType === 'search' && (path === '/' || path.startsWith('/?'))) { |
| 154 | + isActive = true; |
| 155 | + } else if (navType === 'feeds' && path.startsWith('/feeds')) { |
| 156 | + isActive = true; |
| 157 | + } else if (navType === 'about' && path.startsWith('/about')) { |
| 158 | + isActive = true; |
| 159 | + } |
| 160 | + |
| 161 | + if (isActive) { |
| 162 | + link.classList.remove('border-transparent', 'text-gray-500'); |
| 163 | + link.classList.add('border-orange-600', 'text-gray-900'); |
| 164 | + } |
| 165 | + }); |
92 | 166 | })(); |
93 | 167 | </script> |
94 | 168 | </body> |
|
0 commit comments