Skip to content

Commit 511a3e7

Browse files
committed
feat: Replace material icons with SVGs for toolbar buttons and enhance styling for better visual consistency
1 parent 93d78d8 commit 511a3e7

File tree

3 files changed

+85
-13
lines changed

3 files changed

+85
-13
lines changed

index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@
5757
<h3>EXPLORER</h3>
5858
<div class="sidebar-actions">
5959
<button class="btn-icon-small" id="expandAll" title="Expand All">
60-
<span class="material-symbols-outlined">unfold_more</span>
60+
<img src="https://raw.githack.com/PKief/vscode-material-icon-theme/main/icons/chevron-down.svg" alt="Expand All" class="toolbar-icon" />
6161
</button>
6262
<button class="btn-icon-small" id="collapseAll" title="Collapse All">
63-
<span class="material-symbols-outlined">unfold_less</span>
63+
<img src="https://raw.githack.com/PKief/vscode-material-icon-theme/main/icons/chevron-up.svg" alt="Collapse All" class="toolbar-icon" />
6464
</button>
6565
<button class="btn-icon-small" id="selectAll" title="Select All">
66-
<span class="material-symbols-outlined">check_box</span>
66+
<img src="https://raw.githack.com/PKief/vscode-material-icon-theme/main/icons/check-all.svg" alt="Select All" class="toolbar-icon" />
6767
</button>
6868
<button class="btn-icon-small" id="deselectAll" title="Deselect All">
69-
<span class="material-symbols-outlined">check_box_outline_blank</span>
69+
<img src="https://raw.githack.com/PKief/vscode-material-icon-theme/main/icons/checkbox-blank-outline.svg" alt="Deselect All" class="toolbar-icon" />
7070
</button>
7171
<button class="btn-icon-small" id="clearAll" title="Clear All">
72-
<span class="material-symbols-outlined">delete_sweep</span>
72+
<img src="https://raw.githack.com/PKief/vscode-material-icon-theme/main/icons/trash.svg" alt="Clear All" class="toolbar-icon" />
7373
</button>
7474
</div>
7575
</div>

index.js

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,10 +1395,72 @@
13951395
}
13961396
};
13971397
D.search.oninput = e => {
1398-
const q = e.target.value.toLowerCase();
1399-
document.querySelectorAll('.tree-item').forEach(item => {
1400-
const n = item.querySelector('.file-name').textContent.toLowerCase();
1401-
item.style.display = n.includes(q) ? '' : 'none';
1398+
const q = e.target.value.trim().toLowerCase();
1399+
const allItems = Array.from(document.querySelectorAll('.tree-item'));
1400+
// Helper: get full path for a tree-item
1401+
const getPath = item => {
1402+
let path = '';
1403+
let cur = item;
1404+
while (cur && cur.classList.contains('tree-item')) {
1405+
const name = cur.querySelector('.file-name')?.textContent || '';
1406+
path = name + (path ? '/' + path : '');
1407+
cur = cur.parentElement?.closest('.tree-item');
1408+
}
1409+
return path.toLowerCase();
1410+
};
1411+
// First, hide all
1412+
allItems.forEach(item => { item.style.display = 'none'; });
1413+
// If search is empty, show all
1414+
if (!q) {
1415+
allItems.forEach(item => { item.style.display = ''; });
1416+
// Collapse all folders
1417+
document.querySelectorAll('.tree-children').forEach(tc => tc.classList.remove('open'));
1418+
document.querySelectorAll('.expand-btn').forEach(btn => btn.classList.remove('expanded'));
1419+
document.querySelectorAll('.expand-btn .material-symbols-outlined').forEach(span => span.textContent = 'chevron_right');
1420+
return;
1421+
}
1422+
// Find all items that match (by name or path)
1423+
const matches = allItems.filter(item => {
1424+
const name = item.querySelector('.file-name')?.textContent.toLowerCase() || '';
1425+
const path = getPath(item);
1426+
return name.includes(q) || path.includes(q);
1427+
});
1428+
// Show all matches and their ancestors
1429+
const showSet = new Set();
1430+
matches.forEach(item => {
1431+
let cur = item;
1432+
while (cur && cur.classList.contains('tree-item')) {
1433+
showSet.add(cur);
1434+
cur = cur.parentElement?.closest('.tree-item');
1435+
}
1436+
});
1437+
allItems.forEach(item => {
1438+
if (showSet.has(item)) {
1439+
item.style.display = '';
1440+
} else {
1441+
item.style.display = 'none';
1442+
}
1443+
});
1444+
// Expand all folders that are ancestors of matches
1445+
document.querySelectorAll('.tree-children').forEach(tc => {
1446+
const parent = tc.parentElement;
1447+
if (parent && showSet.has(parent)) {
1448+
tc.classList.add('open');
1449+
const btn = parent.querySelector('.expand-btn');
1450+
if (btn) {
1451+
btn.classList.add('expanded');
1452+
const span = btn.querySelector('.material-symbols-outlined');
1453+
if (span) span.textContent = 'expand_more';
1454+
}
1455+
} else {
1456+
tc.classList.remove('open');
1457+
const btn = parent?.querySelector('.expand-btn');
1458+
if (btn) {
1459+
btn.classList.remove('expanded');
1460+
const span = btn.querySelector('.material-symbols-outlined');
1461+
if (span) span.textContent = 'chevron_right';
1462+
}
1463+
}
14021464
});
14031465
};
14041466
const togFold = o => {

style.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,20 @@
2222
--transition: all 0.15s ease;
2323
}
2424

25-
/* Material Icons Custom Colors */
26-
.material-symbols-outlined {
27-
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
28-
user-select: none;
25+
26+
/* Toolbar Icon (VSCode style) */
27+
.toolbar-icon {
28+
width: 20px;
29+
height: 20px;
30+
display: block;
31+
margin: 0 auto;
32+
filter: none;
33+
opacity: 0.92;
34+
transition: opacity 0.15s, transform 0.15s;
35+
}
36+
.btn-icon-small:hover .toolbar-icon {
37+
opacity: 1;
38+
transform: scale(1.12);
2939
}
3040

3141
html, body {

0 commit comments

Comments
 (0)