Skip to content

Commit

Permalink
Add hamburger.js
Browse files Browse the repository at this point in the history
  • Loading branch information
theacodes committed Aug 19, 2024
1 parent 2c4b11b commit a801f76
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/_includes/components/scripts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="/static/scripts/hamburger.js"></script>
18 changes: 10 additions & 8 deletions src/_includes/layouts/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
</head>

<body>
<div class="container is-max-desktop">
<section class="section">
<div class="container is-max-desktop">

{% include "components/navbar.html" %}
{% include "components/navbar.html" %}

<main class="main">
{{ content }}
</main>
<main class="main">
{{ content }}
</main>

{% include "components/footer.html" %}

</div>
{% include "components/footer.html" %}
{% include "components/scripts.html" %}
</div>
</section>
</body>

</html>
26 changes: 26 additions & 0 deletions src/static/scripts/hamburger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Hamburger menu functionality.
*
* See https://bulma.io/documentation/components/navbar/#navbar-menu
*/

document.addEventListener("DOMContentLoaded", () => {
/** @type {NodeListOf<HTMLElement>} */
const burgers = document.querySelectorAll(".navbar-burger");

for(const burger of burgers) {
const targetId = burger.dataset["target"];
const target = document.getElementById(targetId ?? "");

if(!target) {
console.error(`Hamburger target ${targetId} for ${burger} not found.`);
return;
}

burger.addEventListener("click", () => {
burger.classList.toggle("is-active");
target.classList.toggle("is-active");
});
}

});
8 changes: 8 additions & 0 deletions src/static/styles/oshwa.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ h6 {
.footer {
--bulma-footer-background-color: transparent;
}

/* OHM-specific bits */

@media screen and (max-width: 1024px) {
.navbar-brand .navbar-item img {
--bulma-navbar-item-img-max-height: 6lh;
}
}

0 comments on commit a801f76

Please sign in to comment.