|
2 | 2 | <nav class="bg-stone-800 text-white shadow-lg sticky top-0 z-50" role="navigation" aria-label="Main navigation"> |
3 | 3 | <div class="max-w-7xl mx-auto"> |
4 | 4 | <!-- Top Bar: Domain Links & Auth --> |
5 | | - <div class="bg-stone-900 border-b border-stone-700 px-4 py-2"> |
| 5 | + <div class="bg-stone-900 border-b border-stone-700 container-padding py-2"> |
6 | 6 | <div class="flex flex-wrap items-center justify-between gap-2"> |
7 | 7 | <!-- Domain Links --> |
8 | | - <ol class="inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-xs sm:text-sm text-stone-400" role="list"> |
| 8 | + <ol class="inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-stone-400" role="list"> |
9 | 9 | <li> |
10 | | - <a href="https://coderic.co" class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-1 transition-colors" |
| 10 | + <a href="https://coderic.co" class="nav-link-sm" |
11 | 11 | title="Coderic FinTech" aria-label="Visit Coderic FinTech"> |
12 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"> |
| 12 | + <svg class="nav-icon" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"> |
13 | 13 | <path d="M6,16.5L3,19.44V11H6M11,14.66L9.43,13.32L8,14.64V7H11M16,13L13,16V3H16M18.81,12.81L17,11H22V16L20.21,14.21L13,21.36L9.53,18.34L5.75,22H3L9.47,15.66L13,18.64" /> |
14 | 14 | </svg> |
15 | 15 | <span class="hidden sm:inline">FINTECH</span> |
16 | 16 | </a> |
17 | 17 | </li> |
18 | 18 | <li aria-hidden="true" class="text-stone-600">·</li> |
19 | 19 | <li> |
20 | | - <a href="https://coderic.cloud" class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-1 transition-colors" |
| 20 | + <a href="https://coderic.cloud" class="nav-link-sm" |
21 | 21 | title="Coderic Cloud" aria-label="Visit Coderic Cloud"> |
22 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> |
| 22 | + <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> |
23 | 23 | <path d="M12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6m0-2C9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96C18.67 6.59 15.64 4 12 4z" /> |
24 | 24 | </svg> |
25 | 25 | <span class="hidden sm:inline">CLOUD</span> |
26 | 26 | </a> |
27 | 27 | </li> |
28 | 28 | <li aria-hidden="true" class="text-stone-600">·</li> |
29 | 29 | <li> |
30 | | - <a href="https://coderic.net" class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-1 transition-colors" |
| 30 | + <a href="https://coderic.net" class="nav-link-sm" |
31 | 31 | title="Coderic Hub Content" aria-label="Visit Coderic Hub"> |
32 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> |
| 32 | + <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> |
33 | 33 | <rect x="6" y="7" width="8" height="2" /> |
34 | 34 | <rect x="6" y="11" width="12" height="2" /> |
35 | 35 | <rect x="6" y="15" width="2.99" height="2" /> |
|
41 | 41 | </li> |
42 | 42 | <li aria-hidden="true" class="text-stone-600">·</li> |
43 | 43 | <li> |
44 | | - <a href="https://coderic.org" class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-1 transition-colors" |
| 44 | + <a href="https://coderic.org" class="nav-link-sm" |
45 | 45 | title="Coderic Organization" aria-label="Visit Coderic Organization"> |
46 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> |
| 46 | + <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"> |
47 | 47 | <path d="M19,9A7,7,0,1,0,8.0257,14.75928L5,20l2.25562.09314L8.46411,22l3.46613-6.00354C11.95374,15.9967,11.97644,16,12,16s.04626-.0033.06976-.00354L15.53589,22l1.232-1.866L19,20l-3.02576-5.24072A6.98951,6.98951,0,0,0,19,9ZM7,9a5,5,0,1,1,5,5A5,5,0,0,1,7,9Z" /> |
48 | 48 | <circle cx="12" cy="9" r="3" /> |
49 | 49 | </svg> |
|
53 | 53 | </ol> |
54 | 54 |
|
55 | 55 | <!-- Auth Buttons --> |
56 | | - <ol class="inline-flex items-center gap-2 text-xs sm:text-sm" role="list"> |
| 56 | + <ol class="inline-flex items-center gap-2" role="list"> |
57 | 57 | <li class="guest hidden"> |
58 | | - <a class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-2 py-1 transition-colors" |
| 58 | + <a class="nav-link-md" |
59 | 59 | href="/" title="Sign in" aria-label="Sign in to Coderic" onclick="if(typeof login === 'function') { login(); return false; }"> |
60 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"> |
| 60 | + <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"> |
61 | 61 | <path d="M26,30H14a2,2,0,0,1-2-2V25h2v3H26V4H14V7H12V4a2,2,0,0,1,2-2H26a2,2,0,0,1,2,2V28A2,2,0,0,1,26,30Z" /> |
62 | 62 | <polygon points="14.59 20.59 18.17 17 4 17 4 15 18.17 15 14.59 11.41 16 10 22 16 16 22 14.59 20.59" /> |
63 | 63 | </svg> |
64 | 64 | <span class="hidden sm:inline">Sign in</span> |
65 | 65 | </a> |
66 | 66 | </li> |
67 | 67 | <li class="authenticated hidden"> |
68 | | - <a href="/profile" class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-2 py-1 transition-colors" |
| 68 | + <a href="/profile" class="nav-link-md" |
69 | 69 | title="Profile" aria-label="View profile"> |
70 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"> |
| 70 | + <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"> |
71 | 71 | <path d="M16,8a5,5,0,1,0,5,5A5,5,0,0,0,16,8Zm0,8a3,3,0,1,1,3-3A3.0034,3.0034,0,0,1,16,16Z" /> |
72 | 72 | <path d="M16,2A14,14,0,1,0,30,16,14.0158,14.0158,0,0,0,16,2ZM10,26.3765V25a3.0033,3.0033,0,0,1,3-3h6a3.0033,3.0033,0,0,1,3,3v1.3765a11.8989,11.8989,0,0,1-12,0Zm13.9925-1.4507A5.0016,5.0016,0,0,0,19,20H13a5.0016,5.0016,0,0,0-4.9925,4.9258,12,12,0,1,1,15.985,0Z" /> |
73 | 73 | </svg> |
74 | 74 | <span class="hidden sm:inline" id="username"></span> |
75 | 75 | </a> |
76 | 76 | </li> |
77 | 77 | <li class="authenticated hidden"> |
78 | | - <a href="/dashboard" class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-2 py-1 transition-colors" |
| 78 | + <a href="/dashboard" class="nav-link-md" |
79 | 79 | title="Dashboard" aria-label="View dashboard"> |
80 | | - <svg class="w-3 h-3 sm:w-4 sm:h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"> |
| 80 | + <svg class="nav-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" aria-hidden="true"> |
81 | 81 | <rect x="24" y="21" width="2" height="5" /> |
82 | 82 | <rect x="20" y="16" width="2" height="10" /> |
83 | 83 | <path d="M11,26a5.0059,5.0059,0,0,1-5-5H8a3,3,0,1,0,3-3V16a5,5,0,0,1,0,10Z" /> |
|
88 | 88 | </li> |
89 | 89 | <li class="authenticated hidden"> |
90 | 90 | <button type="button" onclick="if(typeof logout === 'function') { logout(); return false; }" |
91 | | - class="inline-flex items-center gap-1 hover:text-orange-500 focus:outline-none focus:ring-2 focus:ring-orange-500 rounded px-2 py-1 transition-colors" |
| 91 | + class="nav-link-md" |
92 | 92 | aria-label="Sign out"> |
93 | | - <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-3 h-3 sm:w-4 sm:h-4" aria-hidden="true"> |
| 93 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="nav-icon" aria-hidden="true"> |
94 | 94 | <path stroke-linecap="round" stroke-linejoin="round" d="M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z" /> |
95 | 95 | </svg> |
96 | 96 | <span class="hidden sm:inline">Sign out</span> |
|
101 | 101 | </div> |
102 | 102 |
|
103 | 103 | <!-- Main Menu Bar --> |
104 | | - <div class="px-4 sm:px-6 lg:px-8"> |
| 104 | + <div class="container-padding"> |
105 | 105 | <div class="flex items-center justify-between"> |
106 | 106 | <!-- Mobile menu button --> |
107 | 107 | <button |
|
111 | 111 | aria-controls="main-menu" |
112 | 112 | aria-label="Toggle navigation menu" |
113 | 113 | id="mobile-menu-button"> |
114 | | - <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6" aria-hidden="true"> |
| 114 | + <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="nav-icon-lg" aria-hidden="true"> |
115 | 115 | <path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" /> |
116 | 116 | </svg> |
117 | 117 | </button> |
118 | 118 |
|
119 | 119 | <!-- Desktop Navigation --> |
120 | 120 | <ul class="hidden lg:flex flex-row items-center" role="menubar" id="main-menu-desktop"> |
| 121 | + {% assign nav_items = "development,crowdfunding,coworking,freelancers,learning,community,organization" | split: "," %} |
| 122 | + {% for item in nav_items %} |
121 | 123 | <li role="none"> |
122 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
123 | | - href="/development" |
| 124 | + <a class="nav-menu-item" |
| 125 | + href="/{{ item }}" |
124 | 126 | role="menuitem" |
125 | | - aria-label="Development"> |
126 | | - DEVELOPMENT |
127 | | - </a> |
128 | | - </li> |
129 | | - <li role="none"> |
130 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
131 | | - href="/crowdfunding" |
132 | | - role="menuitem" |
133 | | - aria-label="Crowdfunding"> |
134 | | - CROWDFUNDING |
135 | | - </a> |
136 | | - </li> |
137 | | - <li role="none"> |
138 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
139 | | - href="/coworking" |
140 | | - role="menuitem" |
141 | | - aria-label="Coworking"> |
142 | | - CO-WORKING |
143 | | - </a> |
144 | | - </li> |
145 | | - <li role="none"> |
146 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
147 | | - href="/freelancers" |
148 | | - role="menuitem" |
149 | | - aria-label="Freelancers"> |
150 | | - FREELANCERS |
151 | | - </a> |
152 | | - </li> |
153 | | - <li role="none"> |
154 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
155 | | - href="/learning" |
156 | | - role="menuitem" |
157 | | - aria-label="Learning"> |
158 | | - LEARNING |
159 | | - </a> |
160 | | - </li> |
161 | | - <li role="none"> |
162 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
163 | | - href="/community" |
164 | | - role="menuitem" |
165 | | - aria-label="Community"> |
166 | | - COMMUNITY |
167 | | - </a> |
168 | | - </li> |
169 | | - <li role="none"> |
170 | | - <a class="flex items-center justify-center h-16 px-4 font-semibold text-white transition-colors hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500" |
171 | | - href="/organization" |
172 | | - role="menuitem" |
173 | | - aria-label="Organization"> |
174 | | - ORGANIZATION |
| 127 | + aria-label="{{ item | capitalize }}"> |
| 128 | + {{ item | upcase | replace: "-", "-" }} |
175 | 129 | </a> |
176 | 130 | </li> |
| 131 | + {% endfor %} |
177 | 132 | </ul> |
178 | 133 | </div> |
179 | 134 |
|
180 | 135 | <!-- Mobile Navigation (hidden by default) --> |
181 | 136 | <ul class="lg:hidden hidden flex-col w-full absolute left-0 bg-stone-800 shadow-lg z-50 border-t border-stone-700" id="mobile-menu" role="menu"> |
| 137 | + {% for item in nav_items %} |
182 | 138 | <li role="none"> |
183 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
184 | | - href="/development" |
185 | | - role="menuitem" |
186 | | - aria-label="Development"> |
187 | | - DEVELOPMENT |
188 | | - </a> |
189 | | - </li> |
190 | | - <li role="none"> |
191 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
192 | | - href="/crowdfunding" |
193 | | - role="menuitem" |
194 | | - aria-label="Crowdfunding"> |
195 | | - CROWDFUNDING |
196 | | - </a> |
197 | | - </li> |
198 | | - <li role="none"> |
199 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
200 | | - href="/coworking" |
201 | | - role="menuitem" |
202 | | - aria-label="Coworking"> |
203 | | - CO-WORKING |
204 | | - </a> |
205 | | - </li> |
206 | | - <li role="none"> |
207 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
208 | | - href="/freelancers" |
209 | | - role="menuitem" |
210 | | - aria-label="Freelancers"> |
211 | | - FREELANCERS |
212 | | - </a> |
213 | | - </li> |
214 | | - <li role="none"> |
215 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
216 | | - href="/learning" |
217 | | - role="menuitem" |
218 | | - aria-label="Learning"> |
219 | | - LEARNING |
220 | | - </a> |
221 | | - </li> |
222 | | - <li role="none"> |
223 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
224 | | - href="/community" |
| 139 | + <a class="nav-menu-item-mobile" |
| 140 | + href="/{{ item }}" |
225 | 141 | role="menuitem" |
226 | | - aria-label="Community"> |
227 | | - COMMUNITY |
228 | | - </a> |
229 | | - </li> |
230 | | - <li role="none"> |
231 | | - <a class="block px-4 py-3 text-white font-semibold hover:bg-stone-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-orange-500 transition-colors" |
232 | | - href="/organization" |
233 | | - role="menuitem" |
234 | | - aria-label="Organization"> |
235 | | - ORGANIZATION |
| 142 | + aria-label="{{ item | capitalize }}"> |
| 143 | + {{ item | upcase | replace: "-", "-" }} |
236 | 144 | </a> |
237 | 145 | </li> |
| 146 | + {% endfor %} |
238 | 147 | </ul> |
239 | 148 | </div> |
240 | 149 | </div> |
241 | 150 | </nav> |
242 | 151 |
|
243 | 152 | {% if page.title %} |
244 | 153 | <header class="bg-white border-b border-stone-200" role="banner"> |
245 | | - <div class="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8"> |
246 | | - <h1 class="text-2xl sm:text-3xl font-semibold text-gray-900"> |
| 154 | + <div class="max-w-7xl mx-auto container-padding py-4"> |
| 155 | + <h1 class="heading-3 text-gray-900"> |
247 | 156 | {{ page.title }} |
248 | 157 | </h1> |
249 | 158 | </div> |
250 | 159 | </header> |
251 | 160 | {% endif %} |
252 | 161 |
|
253 | 162 | <script> |
254 | | - // Mobile menu toggle |
255 | | - document.addEventListener('DOMContentLoaded', function() { |
| 163 | + // Mobile menu toggle with better practices |
| 164 | + (function() { |
| 165 | + 'use strict'; |
| 166 | + |
256 | 167 | const mobileMenuButton = document.getElementById('mobile-menu-button'); |
257 | 168 | const mobileMenu = document.getElementById('mobile-menu'); |
258 | 169 |
|
259 | | - if (mobileMenuButton && mobileMenu) { |
260 | | - mobileMenuButton.addEventListener('click', function() { |
261 | | - const isExpanded = mobileMenuButton.getAttribute('aria-expanded') === 'true'; |
262 | | - mobileMenu.classList.toggle('hidden'); |
263 | | - mobileMenuButton.setAttribute('aria-expanded', !isExpanded); |
264 | | - |
265 | | - // Update icon |
| 170 | + if (!mobileMenuButton || !mobileMenu) return; |
| 171 | + |
| 172 | + const toggleMenu = () => { |
| 173 | + const isExpanded = mobileMenuButton.getAttribute('aria-expanded') === 'true'; |
| 174 | + mobileMenu.classList.toggle('hidden'); |
| 175 | + mobileMenuButton.setAttribute('aria-expanded', String(!isExpanded)); |
| 176 | + |
| 177 | + // Update icon |
| 178 | + const icon = mobileMenuButton.querySelector('svg path'); |
| 179 | + if (icon) { |
| 180 | + icon.setAttribute('d', isExpanded |
| 181 | + ? 'M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5' |
| 182 | + : 'M6 18L18 6M6 6l12 12' |
| 183 | + ); |
| 184 | + icon.setAttribute('stroke-linecap', 'round'); |
| 185 | + icon.setAttribute('stroke-linejoin', 'round'); |
| 186 | + } |
| 187 | + }; |
| 188 | + |
| 189 | + const closeMenu = () => { |
| 190 | + if (!mobileMenu.classList.contains('hidden')) { |
| 191 | + mobileMenu.classList.add('hidden'); |
| 192 | + mobileMenuButton.setAttribute('aria-expanded', 'false'); |
266 | 193 | const icon = mobileMenuButton.querySelector('svg path'); |
267 | 194 | if (icon) { |
268 | | - if (!isExpanded) { |
269 | | - // Change to X icon |
270 | | - icon.setAttribute('d', 'M6 18L18 6M6 6l12 12'); |
271 | | - icon.setAttribute('stroke-linecap', 'round'); |
272 | | - icon.setAttribute('stroke-linejoin', 'round'); |
273 | | - } else { |
274 | | - // Change back to hamburger |
275 | | - icon.setAttribute('d', 'M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5'); |
276 | | - icon.setAttribute('stroke-linecap', 'round'); |
277 | | - icon.setAttribute('stroke-linejoin', 'round'); |
278 | | - } |
279 | | - } |
280 | | - }); |
281 | | - |
282 | | - // Close menu when clicking outside |
283 | | - document.addEventListener('click', function(event) { |
284 | | - if (!mobileMenuButton.contains(event.target) && !mobileMenu.contains(event.target)) { |
285 | | - if (!mobileMenu.classList.contains('hidden')) { |
286 | | - mobileMenu.classList.add('hidden'); |
287 | | - mobileMenuButton.setAttribute('aria-expanded', 'false'); |
288 | | - const icon = mobileMenuButton.querySelector('svg path'); |
289 | | - if (icon) { |
290 | | - icon.setAttribute('d', 'M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5'); |
291 | | - } |
292 | | - } |
| 195 | + icon.setAttribute('d', 'M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5'); |
293 | 196 | } |
294 | | - }); |
295 | | - } |
296 | | - }); |
| 197 | + } |
| 198 | + }; |
| 199 | + |
| 200 | + mobileMenuButton.addEventListener('click', toggleMenu); |
| 201 | + |
| 202 | + // Close menu when clicking outside or pressing Escape |
| 203 | + document.addEventListener('click', (e) => { |
| 204 | + if (!mobileMenuButton.contains(e.target) && !mobileMenu.contains(e.target)) { |
| 205 | + closeMenu(); |
| 206 | + } |
| 207 | + }); |
| 208 | + |
| 209 | + document.addEventListener('keydown', (e) => { |
| 210 | + if (e.key === 'Escape') { |
| 211 | + closeMenu(); |
| 212 | + } |
| 213 | + }); |
| 214 | + })(); |
297 | 215 | </script> |
0 commit comments