Intro Section with Dropdown Navigation (Scss + Js)
Design comparison
Solution retrospective
This one was slightly more difficult. I would like to know some feedback, especially how I could have structured the JavaScript part better and create the Mobile Overlay using the same HTML used for the Navigation Menu! Thanks!
Community feedback
- @elaineleungPosted over 2 years ago
Hi George, it also took me some time to figure out how to work the overlay, and as a practice afterwards I wrote a simplified version of this site using a CodePen. It's a bit different to how I wrote my challenge, but in any case, it shows how you can use little code to make everything work. You can check out the overlay there: https://codepen.io/elaineleung/pen/poLpzge
As for the JS, it's quite a lot! I wrote mine in React so I can't exactly compare the two, but even with my CodePen, you can see that you don't need a lot of code (I just had 12 lines). For instance, instead of using
add
andremove
onclassList
, you can trytoggle
instead. I think you'll find that when you don't need to add and remove the class, your code will shrink down by at least half. Also, I see that you usedlet
instead ofconst
variables for your DOM elements; since these aren't bound to change, you can useconst
instead, as that is the common practice.Anyway, hope this helps you out!
Marked as helpful1
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