Enhance projects
This commit is contained in:
27
script.js
27
script.js
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user