|
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 | 77 | const iconName = document.body.classList.contains("tool-focus-mode") || document.fullscreenElement |
84 | 78 | ? "exit-fullscreen" |
|
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 | 147 | summary.appendChild(badge); |
156 | 148 |
|
157 | | - const fullscreenName = document.createElement("span"); |
158 | | - fullscreenName.className = "tool-display-mode__fullscreen-name"; |
159 | | - 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"; |
| 149 | + const toolNameLabel = document.createElement("span"); |
| 150 | + toolNameLabel.className = "tool-display-mode__tool-name"; |
| 151 | + toolNameLabel.textContent = toolName; |
| 152 | + summary.appendChild(toolNameLabel); |
170 | 153 |
|
171 | 154 | const character = document.createElement("img"); |
172 | 155 | character.className = "tool-display-mode__character"; |
173 | 156 | character.src = publicImageSource(slot.dataset.toolCharacterSrc, "characters"); |
174 | 157 | 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); |
183 | | - slot.replaceWith(displayMode); |
| 158 | + summary.appendChild(character); |
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 | | - } |
| 160 | + summary.appendChild(createThemeIconNode("fullscreen", "layout-icon tool-display-mode__mode-icon")); |
| 161 | + displayMode.appendChild(summary); |
| 162 | + slot.replaceWith(displayMode); |
210 | 163 |
|
211 | 164 | function applyRegistryImages(registry) { |
212 | 165 | const registryTool = registry.getToolBySlug(toolSlug); |
|
238 | 191 | leftColumnTitle.textContent = registryName; |
239 | 192 | } |
240 | 193 | badge.alt = registryName + " badge"; |
241 | | - fullscreenName.textContent = registryName; |
| 194 | + toolNameLabel.textContent = registryName; |
242 | 195 | character.alt = registryName + " character"; |
243 | | - description.textContent = registryName; |
244 | 196 | badge.src = registry.getToolImageSource(registryTool, "badge"); |
245 | 197 | character.src = registry.getToolImageSource(registryTool, "tool"); |
246 | 198 | } |
247 | 199 |
|
248 | | - async function renderToolNavigation() { |
| 200 | + async function applyRegistryDisplayData() { |
249 | 201 | try { |
250 | 202 | const registry = await import("/toolbox/tool-registry-api-client.js"); |
251 | 203 | const registryDiagnostic = registry.getToolRegistryApiDiagnostic(); |
252 | 204 | if (registryDiagnostic) { |
253 | 205 | throw new Error(registryDiagnostic); |
254 | 206 | } |
255 | | - const navigation = registry.getToolNavigationTargets(toolSlug); |
256 | 207 | 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 | 208 | } catch (error) { |
267 | | - console.warn("Tool navigation could not be loaded.", error); |
| 209 | + console.warn("Tool display mode registry metadata could not be loaded.", error); |
268 | 210 | } |
269 | 211 | } |
270 | 212 |
|
271 | | - renderToolNavigation(); |
| 213 | + applyRegistryDisplayData(); |
272 | 214 |
|
273 | 215 | async function enterToolMode() { |
274 | 216 | document.body.classList.add("tool-focus-mode"); |
|
317 | 259 | }); |
318 | 260 |
|
319 | 261 | refreshVerticalAccordionChevrons(); |
320 | | - updateToolDisplayModeChevron(); |
321 | 262 |
|
322 | 263 | document.querySelectorAll(".tool-workspace").forEach(function (workspace) { |
323 | 264 | const columns = workspace.querySelectorAll(":scope > .tool-column"); |
|
0 commit comments