Skip to content

Commit

Permalink
fix subtitle inside accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
kesiah committed Sep 22, 2023
1 parent 027d902 commit ec00514
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions blocks/v2-specifications/v2-specifications.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
line-height: var(--headline-5-line-height);
}

.v2-specifications__list--subtitle {
margin-bottom: 24px;
margin-top: 24px;
}

/* With Text */
/* stylelint-disable-next-line no-descending-specificity */
.v2-specifications__list--with-text {
Expand Down
16 changes: 11 additions & 5 deletions blocks/v2-specifications/v2-specifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default async function decorate(block) {
const headingString = headings.join(',');
const headingsList = [...block.querySelectorAll(headingString)];
headingsList.forEach((heading) => heading.classList.add(`${blockName}__subtitle`, 'h5'));
const subtitleCounter = item.querySelectorAll(`.${blockName}__subtitle`).length;

if (typeTitle) {
if (accordion) {
Expand Down Expand Up @@ -77,13 +78,16 @@ export default async function decorate(block) {
item.remove();
}

const classes = [];
if (subtitleCounter) classes.push(`${blockName}__list--subtitle`);

// apply classes to the content based on items inside
if (typePicture) {
item.classList.add(`${blockName}__list--with-pictures`);
classes.push(`${blockName}__list--with-pictures`);
}

if (typeDownloads) {
item.classList.add(`${blockName}__list--with-downloads`);
classes.push(`${blockName}__list--with-downloads`);

const buttons = item.querySelectorAll('.button');
buttons.forEach((bt) => {
Expand All @@ -93,12 +97,12 @@ export default async function decorate(block) {
}

if (!typePicture && !typeDownloads && !typeTitle) {
item.classList.add(`${blockName}__list--with-text`);
classes.push(`${blockName}__list--with-text`);
}

accordionContent.appendChild(item);
item.classList.add(...classes);

removeEmptyTags(item);
accordionContent.appendChild(item);
});

// close last accordion content
Expand All @@ -108,5 +112,7 @@ export default async function decorate(block) {
block.appendChild(accordionWrapper);
}

removeEmptyTags(block);

await loadBlock(accordionBlock);
}

0 comments on commit ec00514

Please sign in to comment.