
Design comparison
Solution retrospective
Able to complete this challenge
What challenges did you encounter, and how did you overcome them?I had challenges with the javascript DOM, but I was able achieve what I wanted to do and it worked. I have to practice more to be conversant with it.
What specific areas of your project would you like help with?Understanding more about Javascript DOM
Please log in to post a comment
Log in with GitHubCommunity feedback
- @shadowbanks
Hii,
Great job on completing the challenge Larry 🥳
I have a few suggestions for you :))
-
Currently, you're using an
h3
tag for the date<h3 class="date">28 Jun 2020</h3>
. A better option could be thetime
tag<time datetime="2020-06-28">28 Jun 2020</time>
. for improved semantic HTML and SEO. -
Right now, you have the active part as the default view, removing
is-open
from the class will do the trick.
<section class="share-content is-open">
- In your javaScript I noticed that
body.classList.toggle('is-open');
doesn't actually have any visible effect, as you're not styling it in the CSS
Additionally, I have a suggestion for your code, you can create a function to handle the classes toggle, which would make the code cleaner and more reusable. Here's how you could do it:
const toggleIsOpen = () => { shareContent.classList.toggle('is-open'); authorDetails.classList.toggle('hidden'); } shareButton.addEventListener('click', () => { toggleIsOpen(); }); // Add a separate event listener for the dark share button shareButtonDark.addEventListener('click', () => { toggleIsOpen(); });
This way you won't need the extra
.remove
calls. It simplifies things a bit and keeps your code DRY (Don’t Repeat Yourself).I hope this is helpful, happy coding!😊
Marked as helpful -
- @larryQuao
Noted, I will get back on it an do the suggested correction you have stated. Thank you
Join 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