Skip to content

Commit 7df725f

Browse files
committed
1 parent 96950dd commit 7df725f

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

src/packages/CSS/Controls/Catalog/DSFRcatalogStyle.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,21 @@ button[id^="GPshowCatalogPicto-"][aria-pressed="true"] + dialog {
143143
max-width: 450px;
144144
}
145145

146+
.catalog-section-full {
147+
/* position: fixed; */
148+
top: 0;
149+
left: 0;
150+
width: 100%;
151+
height: 100%;
152+
background: white;
153+
z-index: 10000;
154+
}
155+
section.catalog-section-full > h3 > button.fr-accordion__btn[aria-expanded=true]::after {
156+
transform: rotate(90deg);
157+
left: 0;
158+
right: unset;
159+
}
160+
146161
/* Mode mobile doit prendre le dessus */
147162
@media (max-width: 576px) {
148163
.gpf-mobile-fullscreen .GPtabContent {

src/packages/Controls/Catalog/CatalogDOM.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,11 @@ var CatalogDOM = {
799799
var idCollapseSection = `accordion-${categoryId}-${id}`;
800800
return `
801801
<!-- section -->
802-
<section id="section-${categoryId}-${id}" class="fr-accordion" style="contain: content;">
802+
<section
803+
id="section-${categoryId}-${id}"
804+
data-category="${categoryId}"
805+
data-id="${id}"
806+
class="fr-accordion" style="contain: content;">
803807
<h3 class="fr-accordion__title">
804808
<button class="GPcatalogButtonSection fr-accordion__btn gpf-accordion__btn" role="section-collapse-${categoryId}" aria-expanded="false" aria-controls="${idCollapseSection}">
805809
<span class="GPshowCatalogAdvancedTools gpf-hidden"></span>
@@ -912,7 +916,7 @@ var CatalogDOM = {
912916
if (found) {
913917
icon = found.icon;
914918
} else {
915-
icon = "fr-icon-arrow-right-s-line"; // icone par defaut !
919+
icon = "fr-icon-subtract-line"; // icone par defaut !
916920
}
917921
}
918922
strElements = tmplSection(id, category.id, title, icon, count, data);
@@ -1001,13 +1005,21 @@ var CatalogDOM = {
10011005
buttons.forEach((button) => {
10021006
button.addEventListener("click", (e) => {
10031007
e.target.ariaExpanded = !(e.target.ariaExpanded === "true");
1004-
var collapse = document.getElementById(e.target.getAttribute("aria-controls"));
1008+
var collapseId = e.target.getAttribute("aria-controls");
1009+
var collapse = document.getElementById(collapseId);
10051010
if (!collapse) {
10061011
return;
10071012
}
1013+
var sectionId = collapseId.replace("accordion", "section");
1014+
var section = document.getElementById(sectionId);
1015+
var categoryId = (section) ? section.dataset.category : null;
10081016
if (e.target.ariaExpanded === "true") {
10091017
collapse.classList.add("fr-collapse--expanded");
10101018
collapse.classList.remove("GPelementHidden");
1019+
if (section) {
1020+
section.classList.add("catalog-section-full");
1021+
this.updateVisibilitySectionsByCategory(sectionId, categoryId, false);
1022+
}
10111023
// scroll auto sur le bouton cliqué (dsfr oblige de passer par scrollTop sur le container au lieu de scrollIntoView)
10121024
const container = button.closest("div[id^=\"tabpanel-\"]");
10131025
const buttonRect = button.getBoundingClientRect();
@@ -1021,6 +1033,10 @@ var CatalogDOM = {
10211033
} else {
10221034
collapse.classList.remove("fr-collapse--expanded");
10231035
collapse.classList.add("GPelementHidden");
1036+
if (section) {
1037+
section.classList.remove("catalog-section-full");
1038+
this.updateVisibilitySectionsByCategory(sectionId, categoryId, true);
1039+
}
10241040
}
10251041
}, false);
10261042
});
@@ -1100,6 +1116,25 @@ var CatalogDOM = {
11001116
});
11011117
});
11021118
}
1119+
},
1120+
1121+
updateVisibilitySectionsByCategory (sectionId, categoryId, visible) {
1122+
// rendre les sections visibles ou non de la sous-categorie
1123+
var selector = `[id^="section-${categoryId}-"]`;
1124+
var sections = document.querySelectorAll(selector);
1125+
for (let i = 0; i < sections.length; i++) {
1126+
const section = sections[i];
1127+
if (section.id === sectionId) {
1128+
continue;
1129+
}
1130+
if (visible) {
1131+
section.classList.remove("gpf-hidden");
1132+
section.classList.remove("GPelementHidden");
1133+
} else {
1134+
section.classList.add("gpf-hidden");
1135+
section.classList.add("GPelementHidden");
1136+
}
1137+
}
11031138
}
11041139

11051140
};

0 commit comments

Comments
 (0)