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

Rating component using Vanilla JavaScript

#bem#sass/scss

@danyczech

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


Hi all,

in CSS I tried many different things for svg/img and span content to center them in their backgrounds (with background-color I made the background circle and the svg star and number written inside <span>1</span> weren't easy for me to center to the middle of this circle). Finally, I used display:flex & align-items and justify-content: center and I am not sure if this is the best practice or if the flexbox is too much for just centering.

Thanks for the advice!

Community feedback

Nelson 2,380

@nelsonleone

Posted

Nice , congrats on completing the challenge , you can set a < width and aspect-ratio of 1/1 > on the spans so the can be round shaped when you add border radius,

For clicking the spans , (though using buttons would be also good) you can use JS , using the forEach method to remove all active buttons before making the clicked on active .

span.addEventlistener(....... document.querySelector(span).forEach(span => { span.remove.classList('active') })

e.target.classlist.add('active') )

0
Dytoma 570

@Dytoma

Posted

Hey👋 Congratulation on completing this challenge, I really like your solution.

Here are some improvements you can implement to your code for accessibility:

  • The proper way to build the "rating buttons" in this challenge is to create a form and inside of it, there should be five input 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.

You can read:

This is one of the recommendation I got on my solution that I think you can implement to your code too.

Good Job👏

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