-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Header: aligned items Nav items: visual click effect HTML: switched button to anchor tag HTML & JS: display current year HTML: added google map link to location CSS: added selection bg-color HTML, CSS & JS: added your-profile & show/hide profile functionality CSS: sped up animation speed when hovering side-nav items
- Loading branch information
1 parent
da56379
commit fdcd34f
Showing
5 changed files
with
246 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
"use strict"; | ||
|
||
//? HTML elements | ||
const userBookmark = document.querySelector("#user-bookmark"); | ||
const userChat = document.querySelector("#user-chat"); | ||
const userProfile = document.querySelector("#user-profile"); | ||
const yearNow = document.querySelectorAll(".current-year"); | ||
for (const item of yearNow) item.innerHTML = new Date().getFullYear().toString(); | ||
|
||
//? Event listeners | ||
userBookmark.addEventListener("click", () => {}); | ||
userChat.addEventListener("click", () => {}); | ||
document.querySelector("#user-bookmark").addEventListener("click", () => {}); | ||
document.querySelector("#user-chat").addEventListener("click", () => {}); | ||
|
||
userProfile.addEventListener("click", () => { | ||
//? Show profile page | ||
//? add click for every item in the side nav | ||
const sideNavItems = document.querySelectorAll(".side-nav__item"); | ||
|
||
for (const navItem of sideNavItems) { | ||
navItem.addEventListener("click", () => { | ||
// remove active class from all item except the clicked one | ||
for (const item of sideNavItems) { | ||
if (navItem !== item && item.classList.contains("side-nav__item--active")) | ||
item.classList.remove("side-nav__item--active"); | ||
} | ||
|
||
// Toggle active class for the clicked item | ||
navItem.classList.add("side-nav__item--active"); | ||
}); | ||
} | ||
|
||
//? Show profile when clicked | ||
const user = document.querySelector("#user-profile"); | ||
const yourProfile = document.querySelector(".your-profile"); | ||
|
||
user.addEventListener("click", () => { | ||
yourProfile.classList.toggle("show-profile"); | ||
}); | ||
|
||
//? Hide profile when clicking outside the element | ||
document.addEventListener("click", (event) => { | ||
if (!user.contains(event.target) && !yourProfile.contains(event.target)) | ||
yourProfile.classList.remove("show-profile"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.