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

Commit 1299ab9

Browse files
committed
Show occurrences
1 parent 0e16915 commit 1299ab9

2 files changed

Lines changed: 66 additions & 4 deletions

File tree

extension/sidebar-pane.html

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
line-height: 1.8;
1515
}
1616

17+
a {
18+
text-decoration: none;
19+
}
20+
1721
header {
1822
color: #0c0c0d;
1923
background-color: #f9f9fa;
@@ -26,10 +30,6 @@
2630
border-top: 1px solid #e0e0e2;
2731
}
2832

29-
a {
30-
text-decoration: none;
31-
}
32-
3333
li {
3434
margin-block-end: 4px;
3535
list-style: none;
@@ -127,6 +127,32 @@
127127
font-weight: 600;
128128
}
129129

130+
/* occurrences part */
131+
.occurrences details summary {
132+
cursor: pointer;
133+
color: #b6babf;
134+
}
135+
136+
.occurrences ul {
137+
line-height: 1.2;
138+
padding-inline-start: 16px;
139+
padding-block-start: 2px;
140+
}
141+
142+
.occurrences li {
143+
font-family: monospace;
144+
font-size: 12px;
145+
}
146+
147+
.occurrences .node-name {
148+
color: #0074e8;
149+
}
150+
151+
.occurrences .node-id,
152+
.occurrences .node-class {
153+
color: #dd00a9;
154+
}
155+
130156
#subtree aside {
131157
display: none;
132158
padding-block: 12px;

extension/sidebar-pane.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,45 @@ function _renderIssue(issue) {
163163

164164
issueEl.classList.add((issue.deprecated ? "warning" : "information"));
165165

166+
if (issue.nodes) {
167+
issueEl.append(_renderOccurrences(issue));
168+
}
169+
166170
return issueEl;
167171
}
168172

173+
function _renderOccurrences({ nodes }) {
174+
const occurrencesEl = document.createElement("section");
175+
occurrencesEl.classList.add("occurrences");
176+
177+
const nodelistEl = document.createElement("ul");
178+
for (const { id, className, nodeName } of nodes) {
179+
const nodeEl = document.createElement("li");
180+
nodeEl.append(_renderTerm(nodeName.toLowerCase(), ["node-name"]));
181+
182+
if (id) {
183+
nodeEl.append(_renderTerm(`#${ id }`, ["node-id"]));
184+
} else if (className.length) {
185+
nodeEl.append(_renderTerm(`.${ className.replace(/\s+/g, ".") }`, ["node-class"]));
186+
}
187+
nodelistEl.append(nodeEl);
188+
}
189+
190+
if (nodes.length !== 1) {
191+
const summaryEl = document.createElement("summary");
192+
summaryEl.textContent = `${nodes.length} occurrences`;
193+
194+
const detailsEl = document.createElement("details");
195+
detailsEl.append(summaryEl, nodelistEl);
196+
197+
occurrencesEl.append(detailsEl);
198+
} else {
199+
occurrencesEl.append(nodelistEl);
200+
}
201+
202+
return occurrencesEl;
203+
}
204+
169205
function _renderSubject(issue) {
170206
const { type, url } = issue;
171207
const subjectEl = document.createElement("span");

0 commit comments

Comments
 (0)