Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit a5e3d1d

Browse files
author
daisuke
committed
fixed #16 - Indicator with spinner for loading subtree
1 parent 495fb6f commit a5e3d1d

2 files changed

Lines changed: 62 additions & 2 deletions

File tree

extension/sidebar-pane.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,49 @@
122122
.deprecated, .experimental {
123123
font-weight: 600;
124124
}
125+
126+
#subtree aside {
127+
display: none;
128+
padding-block: 12px;
129+
padding-inline: 40px;
130+
}
131+
132+
#subtree.processing aside {
133+
display: block;
134+
}
135+
136+
#subtree.processing ul {
137+
display: none;
138+
}
139+
140+
#subtree aside label {
141+
display: flex;
142+
align-items: center;
143+
}
144+
145+
/* import from devtools/client/themes/common.css */
146+
/* Throbbers */
147+
.devtools-throbber::before {
148+
content: "";
149+
display: inline-block;
150+
vertical-align: bottom;
151+
margin-inline-end: 0.5em;
152+
width: 1em;
153+
height: 1em;
154+
border: 2px solid currentColor;
155+
border-right-color: transparent;
156+
border-radius: 50%;
157+
animation: 1.1s linear throbber-spin infinite;
158+
}
159+
160+
@keyframes throbber-spin {
161+
from {
162+
transform: none;
163+
}
164+
to {
165+
transform: rotate(360deg);
166+
}
167+
}
125168
</style>
126169
<script src="experiments/inspectedNode/api-client.js"></script>
127170
<script type="module" src="sidebar-pane.js"></script>
@@ -134,6 +177,9 @@
134177
<section id="subtree">
135178
<header>Issues for the selected element's subtree</header>
136179
<ul></ul>
180+
<aside>
181+
<label class="devtools-throbber"></label>
182+
</aside>
137183
</section>
138184
</body>
139185
</html>

extension/sidebar-pane.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ async function _updateSelectedNode(selectedNode) {
3838
}
3939

4040
async function _updateSubtree(selectedNode) {
41-
const ulEl = document.querySelector("#subtree ul");
41+
const subtreeEl = document.getElementById("subtree");
42+
const ulEl = subtreeEl.querySelector("ul");
4243

4344
if (!_isValidElement(selectedNode)) {
4445
_render([], ulEl);
@@ -47,7 +48,14 @@ async function _updateSubtree(selectedNode) {
4748

4849
const issues = [];
4950

50-
for (const node of await browser.experiments.inspectedNode.getNodesInSubtree()) {
51+
subtreeEl.classList.add("processing");
52+
const progressEl = subtreeEl.querySelector("aside label");
53+
54+
progressEl.textContent = "Getting all descendants of the selected node";
55+
const nodesInSubtree = await browser.experiments.inspectedNode.getNodesInSubtree();
56+
57+
progressEl.textContent = "Getting web compatibility issues for HTML element";
58+
for (const node of nodesInSubtree) {
5159
if (!_isValidElement(node)) {
5260
continue
5361
}
@@ -57,13 +65,19 @@ async function _updateSubtree(selectedNode) {
5765
..._webcompat.getHTMLElementIssues(nodeName, attributes, _targetBrowsers));
5866
}
5967

68+
progressEl.textContent = "Getting all descendants of the selected node";
6069
const declarationBlocks = await browser.experiments.inspectedNode.getStylesInSubtree();
70+
71+
progressEl.textContent = "Getting web compatibility issues for CSS styles";
6172
for (const { declarations } of declarationBlocks) {
6273
issues.push(
6374
..._webcompat.getCSSDeclarationBlockIssues(declarations, _targetBrowsers));
6475
}
6576

77+
progressEl.textContent = "Rendering all issues";
6678
_render(issues, ulEl);
79+
80+
subtreeEl.classList.remove("processing");
6781
}
6882

6983
function _isValidElement({ nodeType, isCustomElement }) {

0 commit comments

Comments
 (0)