
Simple interactive rating component using native javascript
Design comparison
Solution retrospective
I am most proud of completing the challenge by using native javascript and not some SPA Framework like Angular.
What challenges did you encounter, and how did you overcome them?None that I can think of
What specific areas of your project would you like help with?Code feedback is always appreciated. But as a note, this challenge was completed using the bare minimum required :)
Community feedback
- @skyv26Posted 3 months ago
Hi @progfish, 😊
First off, I want to say that I really appreciate your design work! The app looks great and feels polished despite the minimal resources you had to work with. Awesome job! 👍 However, there are a few areas where improvements can be made to optimize both your code structure and maintainability. Here are my suggestions:
-
Separate Design from HTML: It's always a good practice to separate CSS into its own file rather than embedding it directly within the HTML. This makes your code more readable, easier to maintain, and better structured for future updates. 📂
-
Use
<ul>
and<li>
for List Items: For the ratings section, it's better to use<ul>
(unordered list) and<li>
(list item) tags instead of<div>
for each item. It makes the HTML more semantically correct and improves accessibility. It will also help screen readers interpret the content better. 📝 Example:<ul class="ratings"> <li class="circle" onclick="setFeedback(event, 1)">1</li> <li class="circle" onclick="setFeedback(event, 2)">2</li> <li class="circle" onclick="setFeedback(event, 3)">3</li> <li class="circle" onclick="setFeedback(event, 4)">4</li> <li class="circle" onclick="setFeedback(event, 5)">5</li> </ul>
-
Use
<div>
Instead of<section>
: The<section>
tag is typically used to represent distinct sections of a website with their own headings. For a small card like this, you can simply use a<div>
tag, as it is more appropriate for this use case. 🚫🗂️ -
Use Meaningful or Empty
alt
Attributes for Decorative Images: If the image is purely decorative, you can leave thealt
attribute blank (alt=""
). However, if it adds context, make sure the text is meaningful. This is important for accessibility and how screen readers will interpret the image. 🖼️ -
Externalize JavaScript: For better code organization and reusability, consider placing your JavaScript code in a separate file and linking it to the HTML. This will help keep things clean and modular. 📜
Great work overall, and keep it up! 🚀
Marked as helpful1@progfishPosted 3 months ago@skyv26 Thanks for your kind words and feedback! I think you make a lot of great points. And I do agree with externalizing CSS and Javascript, but I opted not to do that because of the simplicity and size of the challenge :)
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