Index > filter menu fonctionnel + router URL + opti images
All checks were successful
Deploy / Deploy to Production (push) Successful in 2s
All checks were successful
Deploy / Deploy to Production (push) Successful in 2s
- Filtre actif reflété dans ?filter= (pushState), restauré au chargement et sur popstate
- Projet ouvert reflété dans ?project= (pushState), restauré au chargement et sur popstate
- router.js : helpers setParam/getParam + dispatch routechange sur popstate
- Opti images projet : snippet picture, srcset 500-1800w JPEG+WebP, sizes 50vw/>1000px / 100vw mobile
- SCSS : picture { display: contents } dans .project-slideshow, .filtered-out, button.active
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
444b07ccad
commit
40366f617b
11 changed files with 139 additions and 23 deletions
28
assets/js/filter-menu.js
Normal file
28
assets/js/filter-menu.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
const filterButtons = document.querySelectorAll(".filter-menu button");
|
||||
const projectItems = document.querySelectorAll(".projects-index li");
|
||||
|
||||
function applyFilter(filter) {
|
||||
filterButtons.forEach((b) => b.classList.remove("active"));
|
||||
if (!filter) {
|
||||
projectItems.forEach((item) => item.classList.remove("filtered-out"));
|
||||
return;
|
||||
}
|
||||
const btn = [...filterButtons].find((b) => b.dataset.filter === filter);
|
||||
if (btn) btn.classList.add("active");
|
||||
projectItems.forEach((item) => {
|
||||
item.classList.toggle("filtered-out", item.dataset.category !== filter);
|
||||
});
|
||||
}
|
||||
|
||||
filterButtons.forEach((btn) => {
|
||||
btn.addEventListener("click", () => {
|
||||
const isActive = btn.classList.contains("active");
|
||||
const newFilter = isActive ? null : btn.dataset.filter;
|
||||
applyFilter(newFilter);
|
||||
Router.setParam("filter", newFilter);
|
||||
});
|
||||
});
|
||||
|
||||
window.addEventListener("routechange", () => applyFilter(Router.getParam("filter")));
|
||||
|
||||
applyFilter(Router.getParam("filter"));
|
||||
Loading…
Add table
Add a link
Reference in a new issue