Skip to content

Commit

Permalink
fusion menu mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
juandc committed May 24, 2022
1 parent 1052fcd commit 9e37fee
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 4 deletions.
44 changes: 44 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,50 @@
</li>
</ul>
</div>

<div class="mobile-menu inactive">
<ul>
<li>
<a href="/">CATEGORIES</a>
</li>
<li>
<a href="/">All</a>
</li>
<li>
<a href="/">Clothes</a>
</li>
<li>
<a href="/">Electronics</a>
</li>
<li>
<a href="/">Furnitures</a>
</li>
<li>
<a href="/">Toys</a>
</li>
<li>
<a href="/">Other</a>
</li>
</ul>

<ul>
<li>
<a href="/">My orders</a>
</li>
<li>
<a href="/">My account</a>
</li>
</ul>

<ul>
<li>
<a href="/" class="email">platzi@example.com</a>
</li>
<li>
<a href="/" class="sign-out">Sign out</a>
</li>
</ul>
</div>
</nav>

<script src="./main.js"></script>
Expand Down
8 changes: 6 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const menuEmail = document.querySelector('.navbar-email');
const desktopMenu = document.querySelector('.desktop-menu');
const menuHamIcon = document.querySelector('.menu');
const mobileMenu = document.querySelector('.mobile-menu');

menuEmail.addEventListener('click', toggleDesktopMenu);
menuHamIcon.addEventListener('click', toggleMobileMenu);

function toggleDesktopMenu() {
console.log('Click');
desktopMenu.classList.toggle('inactive');
}

console.log('JS funcionando');
function toggleMobileMenu() {
mobileMenu.classList.toggle('inactive');
}
46 changes: 44 additions & 2 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* General */
:root {
--white: #FFFFFF;
--black: #000000;
Expand All @@ -12,12 +13,12 @@ body {
margin: 0;
font-family: 'Quicksand', sans-serif;
}

.inactive {
display: none;
}


/* Navbar (general) */
nav {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -82,7 +83,7 @@ nav {
align-items: center;
}


/* Menu en desktop */
.desktop-menu {
position: absolute;
top: 60px;
Expand Down Expand Up @@ -121,6 +122,38 @@ nav {
display: inline-block;
}

/* Menu en mobile */
.mobile-menu {
position: absolute;
top: 60px;
padding: 24px;
}
.mobile-menu a {
text-decoration: none;
color: var(--black);
font-weight: bold;
/* margin-bottom: 24px; */
}
.mobile-menu ul {
padding: 0;
margin: 24px 0 0;
list-style: none;
}
.mobile-menu ul:nth-child(1) {
border-bottom: 1px solid var(--very-light-pink);
}
.mobile-menu ul li {
margin-bottom: 24px;
}
.email {
font-size: var(--sm);
font-weight: 300 !important;
}
.sign-out {
font-size: var(--sm);
color: var(--hospital-green) !important;
}


@media (max-width: 640px) {
.menu {
Expand All @@ -132,4 +165,13 @@ nav {
.navbar-email {
display: none;
}
.desktop-menu {
display: none;
}
}

@media (min-width: 641px) {
.mobile-menu {
display: none;
}
}

0 comments on commit 9e37fee

Please sign in to comment.