|
127 | 127 |
|
128 | 128 | const currentScript = document.currentScript || document.querySelector("script[src*='gamefoundry-partials.js']"); |
129 | 129 | const assetRoot = currentScript ? new URL("../", currentScript.src) : null; |
| 130 | + let themeIconRegistry = window.ThemeV2Icons || null; |
130 | 131 | let navigationAdminMenuCache = null; |
131 | 132 | let publicConfigCache = null; |
132 | 133 | let publicConfigDataCache = null; |
|
325 | 326 | return new URL(path.replace(/^assets\//, ""), assetRoot).href; |
326 | 327 | } |
327 | 328 |
|
| 329 | + function fallbackThemeIconFileName(name) { |
| 330 | + return "gfs-" + name + ".svg"; |
| 331 | + } |
| 332 | + |
| 333 | + function createThemeIconNode(name, className) { |
| 334 | + if (themeIconRegistry && typeof themeIconRegistry.createThemeIcon === "function") { |
| 335 | + return themeIconRegistry.createThemeIcon(name, { className }); |
| 336 | + } |
| 337 | + |
| 338 | + const icon = document.createElement("span"); |
| 339 | + icon.className = ["theme-icon", "theme-icon--" + name, className].filter(Boolean).join(" "); |
| 340 | + icon.dataset.themeIcon = name; |
| 341 | + icon.dataset.themeIconFile = fallbackThemeIconFileName(name); |
| 342 | + icon.setAttribute("aria-hidden", "true"); |
| 343 | + return icon; |
| 344 | + } |
| 345 | + |
| 346 | + function horizontalToggleIconName(button) { |
| 347 | + const expanded = button.getAttribute("aria-expanded") !== "false"; |
| 348 | + const isLeft = button.classList.contains("horizontal-accordion-toggle--left"); |
| 349 | + if (isLeft) { |
| 350 | + return expanded ? "chevron-left" : "chevron-right"; |
| 351 | + } |
| 352 | + return expanded ? "chevron-right" : "chevron-left"; |
| 353 | + } |
| 354 | + |
| 355 | + function updateHorizontalToggleIcon(button) { |
| 356 | + button.replaceChildren(createThemeIconNode(horizontalToggleIconName(button), "layout-icon horizontal-accordion-toggle__icon")); |
| 357 | + } |
| 358 | + |
| 359 | + function updateReturnToTopIcon(button) { |
| 360 | + button.replaceChildren(createThemeIconNode("chevron-up", "layout-icon return-to-top__icon")); |
| 361 | + } |
| 362 | + |
| 363 | + function refreshUtilityIcons(root) { |
| 364 | + (root || document).querySelectorAll(".horizontal-accordion-toggle").forEach(updateHorizontalToggleIcon); |
| 365 | + (root || document).querySelectorAll("[data-return-to-top]").forEach(updateReturnToTopIcon); |
| 366 | + } |
| 367 | + |
| 368 | + function loadThemeIcons() { |
| 369 | + import(assetUrl("js/theme-icons.js")).then(function (module) { |
| 370 | + themeIconRegistry = module; |
| 371 | + refreshUtilityIcons(document); |
| 372 | + }).catch(function () { |
| 373 | + themeIconRegistry = window.ThemeV2Icons || themeIconRegistry; |
| 374 | + }); |
| 375 | + } |
| 376 | + |
328 | 377 | function currentPagePath() { |
329 | 378 | const parts = window.location.pathname.split("/").filter(Boolean); |
330 | 379 | const rootIndex = parts.findIndex(function (part) { |
|
934 | 983 | button.dataset.accountSideNavCollapse = ""; |
935 | 984 | button.setAttribute("aria-label", "Collapse " + label); |
936 | 985 | button.setAttribute("aria-expanded", "true"); |
937 | | - button.textContent = "<"; |
| 986 | + updateHorizontalToggleIcon(button); |
938 | 987 | header.insertBefore(button, header.firstChild); |
939 | 988 |
|
940 | 989 | button.addEventListener("click", function () { |
|
943 | 992 | if (accountPanel) { |
944 | 993 | accountPanel.classList.toggle("is-left-collapsed", collapsed); |
945 | 994 | } |
946 | | - button.textContent = collapsed ? ">" : "<"; |
947 | 995 | button.setAttribute("aria-expanded", collapsed ? "false" : "true"); |
948 | 996 | button.setAttribute("aria-label", (collapsed ? "Expand " : "Collapse ") + label); |
| 997 | + updateHorizontalToggleIcon(button); |
949 | 998 | }); |
950 | 999 | } |
951 | 1000 |
|
952 | 1001 | function wireReturnToTop(root) { |
953 | 1002 | const button = root.querySelector("[data-return-to-top]"); |
954 | 1003 | if (!button) return; |
| 1004 | + updateReturnToTopIcon(button); |
955 | 1005 |
|
956 | 1006 | function updateVisibility() { |
957 | 1007 | button.classList.toggle("is-visible", window.scrollY > 280); |
|
1075 | 1125 | } |
1076 | 1126 |
|
1077 | 1127 | enforcePageProtection(); |
| 1128 | + loadThemeIcons(); |
1078 | 1129 | document.addEventListener("DOMContentLoaded", function () { |
1079 | 1130 | enforcePageProtection(); |
1080 | 1131 | const slots = Array.from(document.querySelectorAll("[data-partial]")); |
|
0 commit comments