|
73 | 73 | document.querySelectorAll("details.vertical-accordion").forEach(wireVerticalAccordionChevron); |
74 | 74 | } |
75 | 75 |
|
76 | | - function updateToolDisplayModeChevron() { |
77 | | - const iconName = displayMode.open ? "chevron-up" : "chevron-down"; |
78 | | - const shell = createChevronShell(iconName, "tool-display-mode__chevron", "tool-display-mode__chevron-icon"); |
79 | | - replaceIconNode(summary, ":scope > .tool-display-mode__chevron", shell); |
80 | | - } |
81 | | - |
82 | 76 | function updateToolDisplayModeModeIcon() { |
83 | | - const iconName = document.body.classList.contains("tool-focus-mode") || document.fullscreenElement |
| 77 | + const iconName = document.body.classList.contains("tool-focus-mode") |
84 | 78 | ? "exit-fullscreen" |
85 | 79 | : "fullscreen"; |
86 | 80 | const icon = createThemeIconNode(iconName, "layout-icon tool-display-mode__mode-icon"); |
|
107 | 101 | function refreshThemeIcons() { |
108 | 102 | refreshVerticalAccordionChevrons(); |
109 | 103 | updateToolDisplayModeModeIcon(); |
110 | | - updateToolDisplayModeChevron(); |
111 | 104 | refreshHorizontalToggleIcons(); |
112 | 105 | } |
113 | 106 |
|
|
146 | 139 | const summary = document.createElement("summary"); |
147 | 140 | summary.setAttribute("aria-label", "Tool Display Mode"); |
148 | 141 | summary.title = "Tool Display Mode"; |
149 | | - summary.appendChild(createThemeIconNode("fullscreen", "layout-icon tool-display-mode__mode-icon")); |
150 | 142 |
|
151 | 143 | const badge = document.createElement("img"); |
152 | 144 | badge.className = "tool-display-mode__badge"; |
153 | 145 | badge.src = publicImageSource(slot.dataset.toolIconSrc, "badges"); |
154 | 146 | badge.alt = toolName + " badge"; |
155 | | - summary.appendChild(badge); |
156 | 147 |
|
157 | 148 | const fullscreenName = document.createElement("span"); |
158 | 149 | fullscreenName.className = "tool-display-mode__fullscreen-name"; |
159 | 150 | fullscreenName.textContent = toolName; |
160 | | - summary.appendChild(fullscreenName); |
161 | | - displayMode.appendChild(summary); |
162 | | - displayMode.addEventListener("toggle", updateToolDisplayModeChevron); |
163 | | - |
164 | | - const body = document.createElement("div"); |
165 | | - body.className = "tool-display-mode__body"; |
166 | | - |
167 | | - const identityRow = document.createElement("div"); |
168 | | - identityRow.className = "tool-display-mode__identity-row content-cluster"; |
169 | | - identityRow.dataset.toolDisplayModeRow = "identity"; |
170 | 151 |
|
171 | 152 | const character = document.createElement("img"); |
172 | 153 | character.className = "tool-display-mode__character"; |
173 | 154 | character.src = publicImageSource(slot.dataset.toolCharacterSrc, "characters"); |
174 | 155 | character.alt = toolName + " character"; |
175 | | - identityRow.appendChild(character); |
176 | | - |
177 | | - const description = document.createElement("span"); |
178 | | - description.className = "tool-display-mode__description"; |
179 | | - description.textContent = toolName; |
180 | | - identityRow.appendChild(description); |
181 | | - body.appendChild(identityRow); |
182 | | - displayMode.appendChild(body); |
| 156 | + summary.append(badge, fullscreenName, character, createThemeIconNode("fullscreen", "layout-icon tool-display-mode__mode-icon")); |
| 157 | + displayMode.append(summary); |
183 | 158 | slot.replaceWith(displayMode); |
184 | 159 |
|
185 | | - function createNavigationControl(direction, target) { |
186 | | - const controlLabel = direction === "previous" ? "Previous" : "Next"; |
187 | | - const dataAttribute = direction === "previous" ? "toolNavPrevious" : "toolNavNext"; |
188 | | - const iconName = direction === "previous" ? "chevron-left" : "chevron-right"; |
189 | | - const icon = createThemeIconNode(iconName, "layout-icon tool-display-mode__navigation-icon"); |
190 | | - const label = document.createTextNode(controlLabel + ": " + (target?.label || "Unavailable")); |
191 | | - |
192 | | - if (!target || target.disabled) { |
193 | | - const disabledText = document.createElement("span"); |
194 | | - disabledText.className = "pill tool-display-mode__navigation-link tool-display-mode__navigation-link--disabled"; |
195 | | - disabledText.dataset[dataAttribute] = "disabled"; |
196 | | - disabledText.append(icon, label); |
197 | | - return disabledText; |
198 | | - } |
199 | | - |
200 | | - const link = document.createElement("a"); |
201 | | - link.className = "tool-display-mode__navigation-link"; |
202 | | - link.href = target.href; |
203 | | - link.dataset[dataAttribute] = target.kind; |
204 | | - if (target.group) { |
205 | | - link.dataset.toolNavGroup = target.group; |
206 | | - } |
207 | | - link.append(icon, label); |
208 | | - return link; |
209 | | - } |
210 | | - |
211 | 160 | function applyRegistryImages(registry) { |
212 | 161 | const registryTool = registry.getToolBySlug(toolSlug); |
213 | 162 | if (!registryTool) { |
|
240 | 189 | badge.alt = registryName + " badge"; |
241 | 190 | fullscreenName.textContent = registryName; |
242 | 191 | character.alt = registryName + " character"; |
243 | | - description.textContent = registryName; |
244 | 192 | badge.src = registry.getToolImageSource(registryTool, "badge"); |
245 | 193 | character.src = registry.getToolImageSource(registryTool, "tool"); |
246 | 194 | } |
247 | 195 |
|
248 | | - async function renderToolNavigation() { |
| 196 | + async function renderToolDisplayMetadata() { |
249 | 197 | try { |
250 | 198 | const registry = await import("/toolbox/tool-registry-api-client.js"); |
251 | 199 | const registryDiagnostic = registry.getToolRegistryApiDiagnostic(); |
252 | 200 | if (registryDiagnostic) { |
253 | 201 | throw new Error(registryDiagnostic); |
254 | 202 | } |
255 | | - const navigation = registry.getToolNavigationTargets(toolSlug); |
256 | 203 | applyRegistryImages(registry); |
257 | | - const navigationRow = document.createElement("nav"); |
258 | | - navigationRow.className = "tool-display-mode__navigation-row content-cluster"; |
259 | | - navigationRow.dataset.toolDisplayModeRow = "navigation"; |
260 | | - navigationRow.setAttribute("aria-label", "Tool build-order navigation"); |
261 | | - navigationRow.append( |
262 | | - createNavigationControl("previous", navigation.previous), |
263 | | - createNavigationControl("next", navigation.next) |
264 | | - ); |
265 | | - body.appendChild(navigationRow); |
266 | 204 | } catch (error) { |
267 | | - console.warn("Tool navigation could not be loaded.", error); |
| 205 | + console.warn("Tool display metadata could not be loaded.", error); |
268 | 206 | } |
269 | 207 | } |
270 | 208 |
|
271 | | - renderToolNavigation(); |
| 209 | + renderToolDisplayMetadata(); |
272 | 210 |
|
273 | 211 | async function enterToolMode() { |
274 | 212 | document.body.classList.add("tool-focus-mode"); |
|
296 | 234 | } catch (error) { |
297 | 235 | console.warn("Exit fullscreen failed.", error); |
298 | 236 | } |
| 237 | + updateToolDisplayModeModeIcon(); |
299 | 238 | } |
300 | 239 |
|
301 | 240 | summary.addEventListener("click", function (event) { |
|
309 | 248 | }); |
310 | 249 |
|
311 | 250 | document.addEventListener("fullscreenchange", function () { |
312 | | - if (!document.fullscreenElement && document.body.classList.contains("tool-focus-mode")) { |
| 251 | + if (!document.fullscreenElement) { |
313 | 252 | document.body.classList.remove("tool-focus-mode"); |
314 | 253 | displayMode.open = true; |
315 | | - refreshThemeIcons(); |
316 | 254 | } |
| 255 | + refreshThemeIcons(); |
317 | 256 | }); |
318 | 257 |
|
319 | 258 | refreshVerticalAccordionChevrons(); |
320 | | - updateToolDisplayModeChevron(); |
321 | 259 |
|
322 | 260 | document.querySelectorAll(".tool-workspace").forEach(function (workspace) { |
323 | 261 | const columns = workspace.querySelectorAll(":scope > .tool-column"); |
|
0 commit comments