Skip to content

This is a challenge on the Mentor frontend website, where I was able to put into practice my knowledge with DOM manipulation, mobile menu, bubble, and dropdown menu.

License

Notifications You must be signed in to change notification settings

viniciusshenri96/intro-section-with-dropdown-nav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro section with dropdown navigation

 

🚧 Intro section with dropdown navigation 🟢 Completed 🚀 🚧

 

Project description 📚

This is a solution to the challenge Intro section with dropdown navigation.

This is a challenge on the Mentor frontend website, where I was able to put into practice my knowledge with DOM manipulation, mobile menu, bubble, and dropdown menu.

Challenge Difficulty - JUNIOR

 

What I learned

In this project I focused a lot on creating the Mobile and Dropdown menu, and reviewed my knowledge with bubble which is a type of event control

MENU MOBILE:

I also created this function called clickOutside it will make the bubble effect and when the user clicks outside the dropdown menu, it will be closed, we can see in this gif:

Function:

function clickOutside(element, callback) {
  const html = document.querySelector("html");
  const outside = "data-outside";

  if (!element.hasAttribute(outside)) {
    setTimeout(() => {
      html.addEventListener("click", handleOutsideClick);
    });
    element.setAttribute(outside, "");
  }
  function handleOutsideClick(event) {
    if (!element.contains(event.target)) {
      element.removeAttribute(outside);
      setTimeout(() => {
        html.removeEventListener("click", handleOutsideClick);
      });
      callback();
    }
  }
}

DROPDOWN MENU:

hiding the submenu when some other one is active:

document.querySelectorAll("[data-dropdown].active").forEach((dropdown) => {
  if (dropdown === currentDropdown) return;
  dropdown.classList.remove(classActive);
});

Exemple:

if the click happens inside the submenu it will not be hidden, if you click outside the submenu it will be hidden, this happens if the condition below is true.

if (!dropdownButton && e.target.closest("[data-dropdown]")) return;

Exemple:

Links

 

My process

Built with

 

👨‍💻 Author

About

This is a challenge on the Mentor frontend website, where I was able to put into practice my knowledge with DOM manipulation, mobile menu, bubble, and dropdown menu.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published