Skip to content

Commit

Permalink
Add navbar web component (#152)
Browse files Browse the repository at this point in the history
Embed header web component
Format code
Hide custom scrollbar
Add prettier to recommended extensions
  • Loading branch information
dqunbp authored Jan 17, 2024
1 parent 86ad68e commit 46662d5
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 369 deletions.
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"recommendations": ["celianriboulet.webvalidator"]
"recommendations": ["celianriboulet.webvalidator", "esbenp.prettier-vscode"]
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.fontSize": 18,
"editor.fontSize": 16,
"editor.rulers": [88, 120],
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
Expand Down Expand Up @@ -44,5 +44,8 @@
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
4 changes: 2 additions & 2 deletions themes/hugo-bulma-blocks-theme/assets/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
padding-bottom: 30px;
}

::-webkit-scrollbar {
/* ::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-thumb {
background: rgb(225, 225, 225);
}
} */

.sidebar ul {
list-style: none;
Expand Down
79 changes: 39 additions & 40 deletions themes/hugo-bulma-blocks-theme/assets/js/navbar.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
// first handler for hide / show of search box when magnifying glass is clicked
document.addEventListener('DOMContentLoaded', () => {
const $toggles = Array.prototype.slice.call(
document.querySelectorAll('.search-icon'), 0);
document.addEventListener("DOMContentLoaded", () => {
const $toggles = Array.prototype.slice.call(
document.querySelectorAll(".search-icon"),
0,
);

$toggles.forEach( el => {
el.addEventListener('click', () => {
$toggles.forEach((el) => {
el.addEventListener("click", () => {
console.log("Search icon clicked");
// Get the target from the "data-target" attribute
const $target = document.getElementById("search-control");
// Toggle the search control
el.classList.toggle('is-hidden');
$target.classList.toggle('is-hidden');
})
})
// Get the target from the "data-target" attribute
const $target = document.getElementById("search-control");
// Toggle the search control
el.classList.toggle("is-hidden");
$target.classList.toggle("is-hidden");
});
});
});


document.addEventListener('DOMContentLoaded', () => {

document.addEventListener("DOMContentLoaded", () => {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(
document.querySelectorAll('.navbar-burger'), 0);

document.querySelectorAll(".navbar-burger"),
0,
);

// Add a click event on each of them
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {

// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);

// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle('is-active');
$target.classList.toggle('is-active');

});
$navbarBurgers.forEach((el) => {
el.addEventListener("click", () => {
// Get the target from the "data-target" attribute
const target = el.dataset.target;
const $target = document.getElementById(target);

// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
el.classList.toggle("is-active");
$target.classList.toggle("is-active");
});
});

});
});

var prevScrollpos = window.scrollY;
window.onscroll = function() {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {
document.getElementById("context").style.top = "66px";
} else {
document.getElementById("context").style.top = "0px";
}
prevScrollpos = currentScrollPos;
}
window.onscroll = function () {
var currentScrollPos = window.scrollY;
if (prevScrollpos > currentScrollPos) {
document.getElementById("context").style.top = "4rem";
} else {
document.getElementById("context").style.top = "0px";
}
prevScrollpos = currentScrollPos;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$navbar-background-color: $scheme-main !default
$navbar-box-shadow-size: 5px 5px 5px 0 !default
$navbar-box-shadow-color: #00000020 !default
$navbar-height: 4.75rem !default
$navbar-height: 4rem !default
$navbar-padding-vertical: 1rem !default
$navbar-padding-horizontal: 2rem !default
$navbar-z: 30 !default
Expand Down
2 changes: 1 addition & 1 deletion themes/hugo-bulma-blocks-theme/assets/sass/style.sass
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mark
@extend .gradient-row
position: fixed
width: 100%
top: 66px
top: 4rem
z-index: 100
transition: top 0.3s;

Expand Down
2 changes: 1 addition & 1 deletion themes/hugo-bulma-blocks-theme/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
{{ partial "banner.html" . }}
{{ .Content }}
{{ partial "funders-simple.html" . }}
{{ partial "footer.html" . }}
{{ partial "footer.html" . }}
Loading

0 comments on commit 46662d5

Please sign in to comment.