Design comparison
Solution retrospective
👋🏾 The dropdown section of the nav still not working ... any help on this / comments on how better I would have handled the challenge will be much appreciated.
Community feedback
- @AlexMartosPPosted about 2 years ago
Great work!
First of all, you should have href="#", so that the website don't refresh.
There are som ways you can fix the navbar, you could add a state called "isActive" and when you click a link the state changes with the clicked link for example "Company".
Then you can do this:
<ul classNamse={`nav-list_secondary ${isActive === "Features" ? "open" : ""}`}
Another way you can do this, is by creating two different states, one for each nav link that have a drop down and then check like above but only checking if "isActive" is true or false.
If you want to use vanilla JS like as you do, you can do that to. I changed your code so that it should work (not tested):
const showDropDown = (e) => { e.target.nextElementSibling.classList.toggle("open"); };
Here is my solution if you want to take a look: https://www.frontendmentor.io/solutions/intro-section-with-dropdown-navigation-made-with-reactjs-AUet3fha6z
Marked as helpful0@LeskimPosted about 2 years ago@AlexMartosP Thanks Martos ...will try the implementation using state 🤝🏾
0@LeskimPosted about 2 years ago@AlexMartosP Working fantastic now(used state) ...just the icons on mobile that I haven't added .... Thanks 🤜🏽
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord