Skip to content

Commit 14b7aeb

Browse files
Merge pull request #35 from miquigz/navbarresponsive#22
feat: responsive navbar #22
2 parents 1037cb3 + a9d8bd5 commit 14b7aeb

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed

themes/basic/assets/css/_header.scss

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,57 @@
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+
nav.show-on-mobile.nav-links > a {
37+
padding-left: 0;
38+
padding-right: 0;
39+
}
40+
.menu-button:hover {
41+
cursor: pointer;
42+
}
43+
44+
.page-header {
45+
justify-content: space-between;
46+
.header-center {
47+
order: -1;
48+
max-width: 24px;
49+
.mobile-menu {
50+
z-index: 50;
51+
}
52+
}
53+
.header-center > .nav-links {
54+
background-color: #fefefe;
55+
border-bottom: 1px solid #ccc;
56+
border-top: 1px solid #ccc;
57+
position: absolute;
58+
display: flex;
59+
width: 100%;
60+
flex-wrap: wrap;
61+
top: 76px;
62+
left: 0;
63+
a {
64+
text-align: center;
65+
min-width: 33%;
66+
}
67+
}
68+
}
69+
nav.hide-on-mobile {
70+
max-height: 0;
71+
opacity: 0;
72+
overflow: hidden;
73+
transition: opacity 0.5s;
74+
}
75+
nav.show-on-mobile {
76+
opacity: 1;
77+
max-height: 348px;
78+
transition: opacity 0.5s ease;
79+
}
80+
}
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+
let menuClass = menu.classList;
12+
if (menuClass.contains("show-on-mobile")) {
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)