|
3 | 3 | import { Navigation } from "@skeletonlabs/skeleton-svelte"; |
4 | 4 | import { page } from "$app/state"; |
5 | 5 | import { navSections as allNavSections, type NavigationSection } from "$lib/config/navigation"; |
| 6 | + import { SITE_MAP } from "$lib/utils/roleChecker"; |
6 | 7 |
|
7 | 8 | // Separate My Account and Banks from other sections so they render in specific positions |
8 | 9 | const myAccountSection = allNavSections.find(s => s.id === "my-account"); |
|
146 | 147 | expandedSections[id] = !expandedSections[id]; |
147 | 148 | } |
148 | 149 |
|
| 150 | + function getMenuTooltip(href: string, label: string): string { |
| 151 | + if (href.startsWith("http")) return label; |
| 152 | + const path = href.split("?")[0]; |
| 153 | + const config = SITE_MAP[path]; |
| 154 | + if (!config) return `${label}\n(Not in Site Map)`; |
| 155 | + const roles = config.required.map((r) => r.role); |
| 156 | + if (roles.length === 0) return `${label}\nRequired roles: (none)`; |
| 157 | + return `${label}\nRequired roles: ${roles.join(", ")}`; |
| 158 | + } |
| 159 | +
|
149 | 160 | logger.info("🧭 Navigation state initialized"); |
150 | 161 | const navStateTime = performance.now(); |
151 | 162 | logger.info( |
|
303 | 314 | class:border={page.url.pathname === item.href} |
304 | 315 | class:border-solid-secondary-500={page.url.pathname === |
305 | 316 | item.href} |
306 | | - title={item.label} |
| 317 | + title={getMenuTooltip(item.href, item.label)} |
307 | 318 | aria-label={item.label} |
308 | 319 | target={item.external ? "_blank" : undefined} |
309 | 320 | rel={item.external ? "noopener noreferrer" : undefined} |
|
349 | 360 | class:border-l-2={page.url.pathname === subItem.href} |
350 | 361 | class:border-primary-500={page.url.pathname === |
351 | 362 | subItem.href} |
352 | | - title={subItem.label} |
| 363 | + title={getMenuTooltip(subItem.href, subItem.label)} |
353 | 364 | aria-label={subItem.label} |
354 | 365 | target={subItem.external ? "_blank" : undefined} |
355 | 366 | rel={subItem.external ? "noopener noreferrer" : undefined} |
|
395 | 406 | class:preset-filled-primary-50-950={page.url.pathname === item.href} |
396 | 407 | class:border={page.url.pathname === item.href} |
397 | 408 | class:border-solid-secondary-500={page.url.pathname === item.href} |
398 | | - title={item.label} |
| 409 | + title={getMenuTooltip(item.href, item.label)} |
399 | 410 | aria-label={item.label} |
400 | 411 | > |
401 | 412 | <ItemIcon class="size-5" /> |
|
420 | 431 | class:border={page.url.pathname === item.href} |
421 | 432 | class:border-solid-secondary-500={page.url.pathname === |
422 | 433 | item.href} |
423 | | - title={item.label} |
| 434 | + title={getMenuTooltip(item.href, item.label)} |
424 | 435 | aria-label={item.label} |
425 | 436 | target={item.external ? "_blank" : undefined} |
426 | 437 | rel={item.external ? "noopener noreferrer" : undefined} |
|
467 | 478 | class:border-l-2={currentUrl === subItem.href} |
468 | 479 | class:border-primary-500={currentUrl === |
469 | 480 | subItem.href} |
470 | | - title={subItem.label} |
| 481 | + title={getMenuTooltip(subItem.href, subItem.label)} |
471 | 482 | aria-label={subItem.label} |
472 | 483 | target={subItem.external ? "_blank" : undefined} |
473 | 484 | rel={subItem.external ? "noopener noreferrer" : undefined} |
|
0 commit comments