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, responsive and using JS

@Rafael-Urei

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


The most difficult part was the JS, I wanna know if there's a easiest way to make this transition of style between buttons after you click them, making them selected.

Community feedback

yishak abrham 2,150

@yishak621

Posted

I see in ur code that u replace the whole document by js but instead u design two cards in same containor and use js to toggle from rating card to result card ...

//Submit btn click event 
 submitBtn.addEventListener('click', () => { 
   callBack(); 
   const newArray = [...eachBtns]; //spread operator to convert them to array 
   newArray.forEach((btn) => { 
     //checking if the user click on rating btn-at least one of it makes it true 
     if (btn.classList.contains('btn-active')) { 
       ratingCard.classList.add('hidden'); 
       selectedCard.classList.remove('hidden'); 
       home.classList.remove('hidden'); 
       errorMessage.classList.remove('error-active'); 
     } else if (!selectedCard.classList.contains('hidden')) { 
       errorMessage.classList.remove('error-active'); 
     } else { 
       errorMessage.classList.add('error-active'); 
       function hideError() { 
         errorMessage.classList.remove('error-active'); 
       } 
       setTimeout(hideError, 2000); 
     } 
   }); 
 });

Marked as helpful

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