Skip to content

Commit

Permalink
refactor adjustCtasButtons function
Browse files Browse the repository at this point in the history
  • Loading branch information
ElviaBth committed Jun 10, 2024
1 parent 13a8919 commit 9ada1c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions decidim-core/app/packs/src/decidim/sticky_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ const adjustCtasButtons = () => {
return;
}

ctasButtons.forEach((ctasButton) => {
if (!ctasButton.offsetParent) {
return;
}
if (isElementInViewport(ctasButton)) {
footer.style.marginBottom = `${ctasButton.offsetHeight}px`;
} else {
footer.style.marginBottom = 0;
}
});
let visibleButtons = Array.from(ctasButtons).filter(isElementInViewport);

if (visibleButtons.length > 0) {
const marginBottom = Math.max(...visibleButtons.map((ctasButton) => ctasButton.offsetHeight));
footer.style.marginBottom = `${marginBottom}px`;
} else {
footer.style.marginBottom = 0;
}
};

if (stickyHeader) {
Expand Down
2 changes: 1 addition & 1 deletion decidim-core/app/packs/stylesheets/decidim/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@
}

.survey-section-buttons {
@apply flex-row last:[&>button]:font-semibold last:[&>button]:text-lg last:[&>button]:py-3;
@apply h-20 flex-row last:[&>button]:font-semibold last:[&>button]:text-lg last:[&>button]:py-3;
}
}

0 comments on commit 9ada1c1

Please sign in to comment.