Interactive Rating Component with SCSS, Fluid Typography, and JS
Design comparison
Solution retrospective
How do you guys think about my javascript? is there a better way to write it? I doubt my javascript is written in the best practice. Any feedbacks are welcome! 🙌
Community feedback
- @Bayoumi-devPosted over 2 years ago
Hey Fathul,
- I suggest you add
cursor: pointer;
to thebutton
, The cursor indicates to users there is an action that will be executed when clicking on it.
Hope this is useful to you... Keep coding👍
Marked as helpful1@thefathdevPosted over 2 years ago@Bayoumi-dev Thank you so much! I really forgot it :D
0 - I suggest you add
- @HashimAlSadahPosted over 2 years ago
Hi @whatTheFath, congrats on completing this challenge, your solution looks fine, but as you mentioned this is not the best JS practice.
What you did in your code is that you gave each button an event listener, but the common method is to listen to any click event on the parent container, which is <div id="rate-btn" class="card-rate"> in your code. Then you can check if clicked element is a button. In you case each button has class of <button class="card-rate__list">1</button>.
Overall, you have done a great job in this challenge and Keep Coding.
Marked as helpful1@thefathdevPosted over 2 years agoWow, thank you so much for your better JS solution and recommendation Hashim! @HashimAlSadah. It's really helpful✨
0 - @Sdann26Posted over 2 years ago
Your design and layout are perfect, there's nothing to add there, plus I don't see any accessibility issues.
Your JS is fine actually it's understandable but regarding functionality you should be able to prevent it from being sent by pressing the SUBMIT button. For that you could create a conditional that when receiving the value of when you don't press any button it won't allow you to hit SUBMIT until you click the other buttons. With that implemented I think it would improve the performance of the challenge :D!
Marked as helpful1@thefathdevPosted over 2 years agoWhoah, I didn't noticed it, I'm really appreciate it, Danilo! @Sdann26
1
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