Skip to content

Commit 3d53ba2

Browse files
committed
feat: responsive navbar
1 parent 1037cb3 commit 3d53ba2

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

themes/basic/assets/css/_header.scss

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,44 @@
2424
box-shadow: 1px 1px 3px #ccc;
2525
}
2626
}
27+
28+
.menu-button {
29+
display: none;
30+
}
31+
32+
@media (max-width: 768px) {
33+
.menu-button {
34+
display: block;
35+
}
36+
.page-header {
37+
justify-content: space-between;
38+
.header-center {
39+
order: -1;
40+
max-width: 24px;
41+
.mobile-menu {
42+
z-index: 50;
43+
}
44+
}
45+
.header-center > .nav-links {
46+
background-color: #fefefe;
47+
border-bottom: 1px solid #ccc;
48+
border-top: 1px solid #ccc;
49+
position: absolute;
50+
display: flex;
51+
flex-wrap: wrap;
52+
top: 76px;
53+
left: 0;
54+
a {
55+
text-align: center;
56+
min-width: 28%;
57+
}
58+
}
59+
}
60+
nav.hide-on-mobile {
61+
display: none !important;
62+
height: 0;
63+
}
64+
nav.show-on-mobile {
65+
display: flex !important;
66+
}
67+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
var menuButton = document.querySelector(".menu-button");
3+
var menu = document.querySelector(".nav-links");
4+
5+
function hideMenu() {
6+
menu.classList.add("hide-on-mobile");
7+
menu.classList.remove("show-on-mobile");
8+
}
9+
10+
menuButton.addEventListener("click", function () {
11+
var displayStyle = getComputedStyle(menu).display;
12+
if (displayStyle !== "none") {
13+
hideMenu();
14+
} else {
15+
menu.classList.add("show-on-mobile");
16+
menu.classList.remove("hide-on-mobile");
17+
}
18+
});
19+
20+
menu.addEventListener("click", hideMenu);
21+
});
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
<nav>
1+
<div class="menu-button">
2+
<span >
3+
<img alt="mobile menu" src="{{"img/menu.svg"|relURL}}" alt=""/>
4+
</span>
5+
</div>
6+
7+
<nav class="nav-links hide-on-mobile">
28
<a href="/">Inicio</a>
39
<a href="/biografia">Biografía</a>
410
<a href="/proyectos">Proyectos</a>
511
<a href="/posts">Posts</a>
612
<a href="/colaboradores">Colaboradores</a>
713
<a href="/contacto">Contacto</a>
814
</nav>
15+
16+
17+
{{ $mobileHeader := resources.Get "js/header-mobile.js" }}
18+
<script src="{{ $mobileHeader.Permalink }}" defer></script>

themes/basic/static/img/menu.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)