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

#bem#sass/scss
P

@kaamiik

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


What specific areas of your project would you like help with?

Is the structure of my HTML page correct in this challenge? Is the use of radio buttons correct? How can I make my page more accessible?

Is it correct to use one CSS file for both pages? There were commonalities between the two pages and that’s why I used one CSS file.

I used local storage in my JS. Are my JS codes correct? How can I improve my codes?

When my index.html page gets smaller, instead of the page getting narrower, it overflows at some point. How can I solve this problem?

Community feedback

P
markus 1,430

@markuslewin

Posted

Regarding the HTML, the "How did we do?" text should be a h1, like what you did on the "Thank you!" page. Labels are mostly used to label form controls. div.feedback-form__ratings could be coded as a fieldset with a legend inside to group the radio buttons.

The radio buttons are very close to being accessible! The only problem is that they're hidden with display: none. That declaration hides them from keyboards and screenreaders as well. You only want to visually hide them. You can copy the sr-only class from Tailwind to achieve this. You'll know you got it right when you can select a rating with the keyboard.

The page overflows because there's not enough room for the radio buttons and the gap between them. You could try reducing the gap on the .feedback-form__ratings, and space the radio buttons with justify-content: space-between instead. flex-wrap: wrap would make the buttons wrap to another line when necessary. It depends on how you want them to behave.

The CSS and JS look good to me! In case you ever need to get the values of a form in the future, you can use FormData:

formEl.addEventListener("submit", function (e) {
  e.preventDefault();
  const formData = new FormData(e.currentTarget);
  const value = formData.get("rating");
  console.log({ value });
});

Great job!

Marked as helpful

0

P

@kaamiik

Posted

Thanks Marcus for your great feedback. It was very helpful. I changed my JS files. I deleted the index.js from html and only add this code to thanks.js

const searchParams = new URLSearchParams(window.location.search);
const rating = searchParams.get('rating');

and then add this on html

<form class="feedback-form" action="thanks.html" method="GET">
  <!-- form elements here -->
  <button type="submit" class="feedback-form__submit">Submit</button>
</form>

I changed my code you can check it again. @markuslewin

1
P
markus 1,430

@markuslewin

Posted

@kaamiik Perfect! 🥳

1

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