Skip to content

Commit

Permalink
feat(accordions-group): ajoute un modifieur pour dissocier le collaps…
Browse files Browse the repository at this point in the history
…e du groupe
  • Loading branch information
zellerbaptiste committed Jan 9, 2024
1 parent 616fe65 commit c776711
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/component/accordion/example/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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); %>
6 changes: 4 additions & 2 deletions src/component/accordion/example/sample/accordions-group.ejs
Original file line number Diff line number Diff line change
@@ -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
}
%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
10 changes: 8 additions & 2 deletions src/component/accordion/template/ejs/accordions-group.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
%>
<% eval(include('../../../../core/index.ejs')); %>
<% let accordionsGroup = locals.accordionsGroup || {accordions: []} %>
<div class="<%= prefix %>-accordions-group" >
<%
let accordionsGroup = locals.accordionsGroup || {accordions: []}
let classes = accordionsGroup.classes || [];
classes.push(prefix + '-accordions-group');
if (accordionsGroup.dissociate) classes.push(prefix + '-accordions-group--dissociate');
%>
<div <%- includeClasses(classes); %>>
<%
for (let i = 0; i < accordionsGroup.accordions.length; i++) {
%>
Expand Down

0 comments on commit c776711

Please sign in to comment.