@christopher-adolphe
Posted
Hi @Reallyvane ๐
You did a great job in completing this challenge. ๐ The component is faithful to the design. ๐ Below are a few things that I have noticed and you might want to check in order to improve your solution.
- When I look at this component, I would expect to see a
<form>
element with<input type="radio"/>
elements for the different ratings and a submit<button>
in the HTML markup. However, it is not the case in your solution. While the component seem to be working fine for the general users, those with assistive technology might struggle to interact with it. This is why I would suggest you to use HTML elements that are built to take user inputs when it is the case. For example<input type="radio"/>
or<input type="checkbox"/>
to choose from a list of options instead of<div>
elements. This will also simplify things on the JavaScript side. ๐ - I also noticed that you have set a default rating value of 3 but at the moment, there is no visual cue that communicates that to the user. You should add the
active
class by default on the corresponding<div class="rating-btn">
element. Again, if it was a<input type="radio"/>
, you would have used thechecked
attribute to achieve that. On the other hand, if you don't wish to set a default rating value, you would then have to add a check in theonSubmit()
function like this:
let stars_score;
function onSubmit() {
// Returning early if stars_score is not set
if (!stars_score) {
return;
}
card_content_1.classList.add("hide");
score.textContent = stars_score;
card_content_2.classList.remove("hide");
}
I hope this helps.
Keep it up.
Marked as helpful
@Reallyvane
Posted
Hi!
Thank you so much. This helps a lot and I appreciate the thorough explanation and example.
@christopher-adolphe
Posted
I'm happy to help and glad to see this was helpful to you. ๐
See you on the next one.
Best regards.