Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Interactive rating component

glgaviria64β€’ 50

@glgaviria64

Desktop design screenshot for the Interactive rating component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


I need to improve in Javascript, I enjoy during this challenge

Community feedback

Adrianoβ€’ 33,970

@AdrianoEscarabote

Posted

Hello glgaviria64, how are you? I truly loved your project's outcome, however I have some advice that I hope you'll find useful:

To avoid a big code, we can make some changes.

first we can use the same class on all the buttons:

<button class="btncard" id="1">1</button>

To get them all in js we will use this:

const buttonCard = document.querySelectorAll(".btncard")

and then to add the events, we can use the forEach method since we have an array of elements, and in each element we will add a click event with the necessary functionality:

buttonCard.forEach(element => {
  element.addEventListener("click", () => {
    calificacion = element.textContent;
  });
});

The remainder is excellent.

I hope it's useful. πŸ‘

0
Lagxyβ€’ 90

@Lagxy

Posted

theres an issue when the user didn't select any number and it display undefined out of 5, i suggest you put the default value to 0.

0

@VCarames

Posted

Hey there! πŸ‘‹ Here are some suggestions to help improve your code:

  • The figure element is not needed ❌ since there is no figcaption attached to it.
  • The β€œicons/illustrations” in this component are purely decorative. ⚠️ Their alt tag should be left blank and have an aria-hidden=β€œtrue” to hide them from assistive technology.

More Info: πŸ“š

https://www.w3.org/WAI/tutorials/images/

  • To ensure that the "rating buttons" are fully accessible πŸ’―, they need to be built using a form ⚠️ and inside of it, there should be fiveinput radios and each input should have a label attached to it to make the buttons accessible. Finally wrap all the inputs and labels inside a fieldset to prevent users from making more than one selection.

More Info: πŸ“š

MDN: <input type="radio">

MDN: Field Set Element

  • Currently, users can submit without selecting a rating ⚠️. To fix this, you can do one of the following:
  1. Make the β€œ5” rating the default rating.
  2. Create an error message, telling users they need make a selection.
  3. Disable the button until a selection is made.
  • Your CSS Reset is being underutilized. 😒 To fully maximize πŸ’― it, you will want to add more to it.

Here are some examples that you can freely use:

Josh Comeau Reset

Eric Meyer Reset

If you have any questions or need further clarification, feel free to reach out to me.

Happy Coding! πŸŽ†πŸŽŠπŸͺ…

0

Please log in to post a comment

Log in with GitHub
Discord logo

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