Enhance projects

This commit is contained in:
John Gatward
2026-03-19 16:08:39 +00:00
parent 3cb8d5a14e
commit 2646321ad9
3 changed files with 274 additions and 122 deletions

View File

@@ -22,3 +22,30 @@ window.addEventListener('scroll', () => {
a.style.color = a.getAttribute('href') === `#${current}` ? 'var(--mauve)' : '';
});
});
// ─── Project filters ──────────────────────────────────────────────
const filterChips = document.querySelectorAll('.filter-chip');
const projectCards = document.querySelectorAll('#project-grid .project-card');
if (filterChips.length > 0 && projectCards.length > 0) {
const applyFilter = (filter) => {
projectCards.forEach(card => {
const tech = (card.dataset.tech || '').split(/\s+/).filter(Boolean);
const shouldShow = filter === 'all' || tech.includes(filter);
card.classList.toggle('is-hidden', !shouldShow);
});
};
filterChips.forEach(chip => {
chip.addEventListener('click', () => {
const selected = chip.dataset.filter || 'all';
filterChips.forEach(other => {
other.classList.toggle('active', other === chip);
});
applyFilter(selected);
});
});
}