Skip to content

Commit 3643ac0

Browse files
committed
add a filter search
1 parent a34f8a9 commit 3643ac0

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

public/styles.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ h4 { font-size: 1.05rem; }
173173
font-size: 0.85rem; margin-top: 0.4rem;
174174
}
175175

176+
/* ---------- Search bar ---------- */
177+
.search-bar {
178+
display: flex; align-items: center; gap: 0.6rem;
179+
padding: 0.6rem 1rem; border-radius: 8px;
180+
border: 1px solid var(--rule); background: var(--bg-elev);
181+
margin-bottom: 1rem;
182+
}
183+
.search-bar svg { color: var(--meta); flex-shrink: 0; }
184+
.search-bar input {
185+
flex: 1; border: none; background: transparent; outline: none;
186+
font-size: 0.95rem; color: var(--fg); font-family: inherit;
187+
}
188+
.search-bar input::placeholder { color: var(--meta); }
189+
176190
/* ---------- Category heads & skill rows ---------- */
177191
.category { margin: 3rem 0; }
178192
.cat-head {

src/pages/index.astro

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ const collectionLd = {
6565
<cite>— ICP Skills protocol, <a href="/llms.txt"><code>/llms.txt</code></a></cite>
6666
</blockquote>
6767

68+
<div class="search-bar">
69+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
70+
<input id="skill-search" type="text" placeholder="Filter skills…" autocomplete="off" />
71+
</div>
72+
6873
{grouped.map(({ category, skills }) => (
6974
<section class="category" id={`category-${encodeURIComponent(category)}`} aria-labelledby={`cat-h-${category}`}>
7075
<div class="cat-head">
@@ -105,3 +110,27 @@ const collectionLd = {
105110
});
106111
})();
107112
</script>
113+
114+
<script is:inline>
115+
(function () {
116+
var input = document.getElementById('skill-search');
117+
if (!input) return;
118+
input.addEventListener('input', function () {
119+
var q = input.value.toLowerCase().trim();
120+
var sections = document.querySelectorAll('section.category');
121+
sections.forEach(function (section) {
122+
var rows = section.querySelectorAll('.skill-row');
123+
var visible = 0;
124+
rows.forEach(function (row) {
125+
var title = row.querySelector('.skill-title');
126+
var desc = row.querySelector('.skill-desc');
127+
var text = ((title ? title.textContent : '') + ' ' + (desc ? desc.textContent : '')).toLowerCase();
128+
var match = !q || text.indexOf(q) !== -1;
129+
row.style.display = match ? '' : 'none';
130+
if (match) visible++;
131+
});
132+
section.style.display = visible ? '' : 'none';
133+
});
134+
});
135+
})();
136+
</script>

0 commit comments

Comments
 (0)