Interactive Rating Component using HTML, CSS, JavaScript

Solution retrospective
I am very pleased with how the project has come out and how close that I appear to have got to the provided design.
What challenges did you encounter, and how did you overcome them?The main challenge that I faced was the styling of the radio inputs. After a few attempts to figure this out without any assistance, I had to resort to searching for a solution online. I found a short youtube video which was really helpful (link in the project README) and I was able to adapt the methods in the video to work with this project and I am overall really happy with the results.
What specific areas of your project would you like help with?I am still not sure if the form I have created could be better structure or handled when the submission is made. I am also sure that my CSS could be optimised better and that is something I need to work on so that I am not unessessarily repeating style which could be grouped together.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @grace-snow
I'm afraid this has some serious accessibility problems. It's great you've used a form with radio inputs but there are specific requirements around that you need to follow.
- This group of radios should be in a fieldset (or role="group") with a legend (or aria-labelledby referencing some on screen text).
- there should be no click event listeners anywhere, just one submit event listener on the form.
- the inputs must not be display none! That removes them from the accessibility tree. You need to accessibly hide them instead.
- font size should be in rem, never px.
- it's really important to never limit the height of elements that contain text. That includes the wrapper, and component (the cards/panels). Min-height is fine to use (but unnecessary on the component). Let the browser do it's job and decide what height is needed based on the content inside the card.
- the component must not have a width either. Use max-width in rem instead. This allows the component to shrink narrower when needed like on smaller phones.
- don't style on IDs. That's not what they're for and is causing unnecessary duplication in CSS.
- don't forget to add :focus-visible styles. When the inputs are focused by keyboards it needs to be obvious on the label visually.
- there is no need for a media query in this. Once the above changes are made you can remove it. But for future reference, don't write media queries like this. Style mobile first and use min-width media queries, preferably defined in rem or em not px so that the layout scales nicely even when users have a larger text size setting.
- don't change inline styles in js. Let css handle all styling. Js should only toggle attributes or classes.
- once you've changed js to only use one submit listener you will be able to get the chosen value from the form data. E.g.
form.rating.value
.
Marked as helpful
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