From c77671150ed4fff2b4e0e747b10a4ce0953b853c Mon Sep 17 00:00:00 2001 From: zellerbaptiste Date: Tue, 9 Jan 2024 11:51:12 +0100 Subject: [PATCH] feat(accordions-group): ajoute un modifieur pour dissocier le collapse du groupe --- src/component/accordion/example/index.ejs | 2 ++ .../accordion/example/sample/accordions-group.ejs | 6 ++++-- .../accordion/script/accordion/accordion-selector.js | 2 +- .../accordion/template/ejs/accordions-group.ejs | 10 ++++++++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/component/accordion/example/index.ejs b/src/component/accordion/example/index.ejs index eba73481c..d27392d15 100755 --- a/src/component/accordion/example/index.ejs +++ b/src/component/accordion/example/index.ejs @@ -3,3 +3,5 @@ <%- sample('Accordéon', './sample/accordion', {}, true); %> <%- sample('Groupe d‘accordéons', './sample/accordions-group', {}, true); %> + +<%- sample('Groupe d‘accordéons dissociés', './sample/accordions-group', {accordionsGroup: {dissociate: true}}, true); %> diff --git a/src/component/accordion/example/sample/accordions-group.ejs b/src/component/accordion/example/sample/accordions-group.ejs index dadaef82d..9a1e7fade 100755 --- a/src/component/accordion/example/sample/accordions-group.ejs +++ b/src/component/accordion/example/sample/accordions-group.ejs @@ -1,13 +1,15 @@ <% -const accordions = []; +let accordionsGroup = locals.accordionsGroup || {}; +const accordions = []; for (let i = 0; i < 6; i++) accordions.push({ label: 'Intitulé accordéon', content: randomContent(), id: uniqueId('accordion'), }); -const accordionsGroup = { +accordionsGroup = { + ...accordionsGroup, accordions: accordions } %> diff --git a/src/component/accordion/script/accordion/accordion-selector.js b/src/component/accordion/script/accordion/accordion-selector.js index 8adffc7ce..4144c0873 100644 --- a/src/component/accordion/script/accordion/accordion-selector.js +++ b/src/component/accordion/script/accordion/accordion-selector.js @@ -4,7 +4,7 @@ const ACCORDION = api.internals.ns.selector('accordion'); const COLLAPSE = api.internals.ns.selector('collapse'); export const AccordionSelector = { - GROUP: api.internals.ns.selector('accordions-group'), + GROUP: `${api.internals.ns.selector('accordions-group')}:not(${api.internals.ns.selector('accordions-group--dissociate')})`, ACCORDION: ACCORDION, COLLAPSE: `${ACCORDION} > ${COLLAPSE}, ${ACCORDION} > *:not(${ACCORDION}):not(${COLLAPSE}) > ${COLLAPSE}, ${ACCORDION} > *:not(${ACCORDION}):not(${COLLAPSE}) > *:not(${ACCORDION}):not(${COLLAPSE}) > ${COLLAPSE}`, COLLAPSE_LEGACY: `${ACCORDION} ${COLLAPSE}`, diff --git a/src/component/accordion/template/ejs/accordions-group.ejs b/src/component/accordion/template/ejs/accordions-group.ejs index 12e70f010..25457351a 100644 --- a/src/component/accordion/template/ejs/accordions-group.ejs +++ b/src/component/accordion/template/ejs/accordions-group.ejs @@ -6,8 +6,14 @@ %> <% eval(include('../../../../core/index.ejs')); %> -<% let accordionsGroup = locals.accordionsGroup || {accordions: []} %> -
+<% +let accordionsGroup = locals.accordionsGroup || {accordions: []} +let classes = accordionsGroup.classes || []; +classes.push(prefix + '-accordions-group'); +if (accordionsGroup.dissociate) classes.push(prefix + '-accordions-group--dissociate'); +%> + +
> <% for (let i = 0; i < accordionsGroup.accordions.length; i++) { %>