Skip to content

Commit

Permalink
Merge pull request #2 from demilade211/master
Browse files Browse the repository at this point in the history
Added javascript functionality to navbar
  • Loading branch information
Iroh-Omolola authored May 6, 2021
2 parents 08fc575 + bdc635e commit c957c11
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 2 deletions.
40 changes: 40 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const burger = document.querySelector(".burger");
const nav = document.querySelector(".mobile-nav");
const navLink = document.querySelectorAll(".mobile-nav li");
const mobile = document.querySelectorAll(".m-link");
// fuction to toggle nav
let state = 0;
const openDrop=()=> {
nav.style.display = "flex";
}
const closeDrop=()=>{
nav.style.display = "none";
state = 0;
}

function toggleNav(n){
state += n;
if(state==1){
openDrop();
}
else{
closeDrop();
}

// to animate nav
navLink.forEach((link,index) => {
if(link.style.animation){ // without the if statement the list fade in will only implent on refresh of the page
link.style.animation = "";
}
else{
link.style.animation = `navLinkFade 0.5s ease forwards ${index/7 + 0.5}s`;
}
});
// to animate the burger icon
burger.classList.toggle("toggle");
}
// to close mobile nav bar on click
const closeDropdownMenuSelectingItem = (() => mobile.forEach((item) => item.addEventListener("click", ()=>{
closeDrop();
toggleNav();
})))()
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@
<div><img src="img/ikeja branch NBA logo2 1.png" class="logo1" width="50px" height="40px"></div>
<div><img src="img/ikeja branch NBA logo 1.png" class="logo2" width="140px" height="40px"></div>
</div>
<div class="burger">
<div class="burger" onclick="toggleNav(1)">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
<nav class="mobile-nav">
<ul>
<li><a href="#" class="m-link">HOMES</a></li>
<li><a href="#" class="m-link">NEWS & EVENTS</a></li>
<li><a href="#" class="m-link">ABOUT US</a></li>
<li><a href="#" class="m-link">MEMBERS PORTAL</a></li>
</ul>
</nav>
<div class="nav-list">
<ul class="topnav">
<li class="active"> <a href="#">HOMES</a></li>
Expand Down Expand Up @@ -227,6 +235,7 @@ <h6>Contact</h6>
<!-- Optional JavaScript; choose one of the two! -->

<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="app.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta1/js/bootstrap.bundle.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/ionicons.js"></script>
</body>
Expand Down
55 changes: 54 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
}

nav {
background-color: white;
position: fixed;
z-index: 10;
width: 100%;
height: auto;
display: flex;
Expand Down Expand Up @@ -134,6 +137,7 @@
/* Declare heights because of positioning of img element */

.carousel-item {
margin-top: 40px;
height: 32rem;
}

Expand Down Expand Up @@ -397,6 +401,9 @@
color: #000000;
margin-top: 10px;
}
.mobile-nav{
display: none;
}

@media screen and (min-width: 768px) {
.bd-placeholder-img-lg {
Expand Down Expand Up @@ -454,6 +461,32 @@
margin-top: -290px;
margin-right: 100px;
}
.mobile-nav {
background-color:white;
display: none;
flex-direction: column;
position: absolute;
right: 0;
top: 75.5px;
width: 55%;
height: 100vh;
align-content: space-between;
transition: transform 0.5s ease-in;
z-index: 2;
}
.mobile-nav li{
padding: 20px 0;
width: 100%;
margin: 0;
opacity: 0;
padding-bottom: 5px;
list-style-type: none;
}
.mobile-nav li a{
text-decoration: none;
color: #2D6936;
font-family: 'Ubuntu', 'Montserrat', sans-serif;
}
}

@media screen and (max-width: 990px) {
Expand Down Expand Up @@ -878,4 +911,24 @@
.PageFour-Content p {
width: 100%;
}
}
}
}
@keyframes navLinkFade{
from{
opacity: 0;
transform: translateX(50px);
}
to{
opacity: 1;
transform: translateX(0px);
}
}
.toggle .line1{
transform: rotate(-45deg) translate(-5px,6px);
}
.toggle .line2{
opacity: 0;
}
.toggle .line3{
transform: rotate(45deg) translate(-5px,-6px);
}

2 comments on commit c957c11

@vercel
Copy link

@vercel vercel bot commented on c957c11 May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nba2 – ./

nba2.vercel.app
nba2-git-master-omolola7991.vercel.app
nba2-omolola7991.vercel.app

@vercel
Copy link

@vercel vercel bot commented on c957c11 May 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nba – ./

nba-cyan.vercel.app
nba-omolola7991.vercel.app
nba-git-master-omolola7991.vercel.app

Please sign in to comment.