Skip to content

Commit

Permalink
configure sticky header
Browse files Browse the repository at this point in the history
  • Loading branch information
ElviaBth committed May 30, 2024
1 parent c61a529 commit 4e3ce3f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions decidim-core/app/packs/src/decidim/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import "src/decidim/gallery"
import "src/decidim/direct_uploads/upload_field"
import "src/decidim/data_consent"
import "src/decidim/sw"
import "src/decidim/sticky_header"

// local deps that require initialization
import formDatePicker from "src/decidim/datepicker/form_datepicker"
Expand Down
17 changes: 17 additions & 0 deletions decidim-core/app/packs/src/decidim/sticky_header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let prevScrollpos = window.scrollY;

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

Scrollpos is not a recognized word. (unrecognized-spelling)
const mainBar = document.getElementById("main-bar");

window.onscroll = function() {
// if a subelement is not visible it has no offsetParent
const header = document.getElementById("main-dropdown-summary-mobile").offsetParent;
if (header) {
let currentScrollPos = window.scrollY;

if (prevScrollpos > currentScrollPos) {

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

Scrollpos is not a recognized word. (unrecognized-spelling)
mainBar.style.top = 0;
} else {
mainBar.style.top = `-${header.offsetHeight}px`;
}
prevScrollpos = currentScrollPos;

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

Scrollpos is not a recognized word. (unrecognized-spelling)
}
};
2 changes: 0 additions & 2 deletions decidim-core/app/packs/stylesheets/decidim/_footer.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
footer {
@apply mb-16 lg:mb-0;

.main-footer {
@apply bg-gray-4;

Expand Down
10 changes: 10 additions & 0 deletions decidim-core/app/packs/stylesheets/decidim/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ header {
}
}

#main-bar {
@apply fixed top-0 shadow-lg z-40 bg-white md:relative;

transition: top 0.3s;
}

#menu-bar {
@apply mt-24 md:mt-0;
}

.main-bar {
@apply container grid grid-cols-4 md:grid-cols-8 lg:grid-cols-12 gap-4 items-center py-5 h-24;

Expand Down

0 comments on commit 4e3ce3f

Please sign in to comment.