diff --git a/sass/general.scss b/sass/general.scss index de5b158..e74a1ce 100644 --- a/sass/general.scss +++ b/sass/general.scss @@ -12,3 +12,7 @@ flex-direction: row; } +.disable-scroll { + overflow: hidden !important; + position: fixed; +} diff --git a/sass/style.scss b/sass/style.scss index a477254..2ade7d1 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -82,3 +82,37 @@ footer { margin-bottom: 2rem; } +.hamburger { + display: none; +} + +@media only screen and (min-width: 0px) and (max-width: 1090px) { + header { + .hamburger { + display: block; + font-size: 3rem; + text-decoration: none; + cursor: pointer; + user-select: none; + z-index: 2000; + } + .logo { + z-index: 2000; + } + .hamburger:hover { + color: white; + } + .links { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1000; + background: var(--c-gray); + flex-direction: column; + font-size: 2rem; + } + } +} diff --git a/static/js/mobile-navbar.js b/static/js/mobile-navbar.js new file mode 100644 index 0000000..c23faf3 --- /dev/null +++ b/static/js/mobile-navbar.js @@ -0,0 +1,22 @@ +const burger = document.querySelector(".hamburger") +const links = document.querySelector(".links") +const body = document.querySelector("body") + +let shown = false + +burger.addEventListener("click", (e) => { + e.preventDefault() + if (!shown) { + links.style.display = "flex" + body.classList.add("disable-scroll") + burger.textContent = "x" + } else { + links.style.display = "none" + body.classList.remove("disable-scroll") + burger.textContent = "☰" + } + + shown = !shown +}) + + diff --git a/templates/base.html b/templates/base.html index 52499d5..256e0c3 100644 --- a/templates/base.html +++ b/templates/base.html @@ -25,6 +25,7 @@ + {% block styles %} {% endblock styles %} @@ -43,6 +44,7 @@ >{{ item.name }} {% endfor %} +