@MasonBoom
Posted
Hello,
Although this project is very well done, I believe that there is always room for improvement.
I noticed that I was able to select more than one rating button at a time. A way to solve this issue is to loop through each of the buttons and have all of them change back to their original state before changing the desired button to orange. Here is the function that I used (I used React.js in my project)
const toggleButton = index => { const buttons = document.getElementsByClassName('button'); for (let i = 0; i < buttons.length; i++) { buttons[i].classList.remove('active'); } buttons[index].classList.add('active'); setRating(index + 1); }
and then from here you could do something like this:
rating_number[i].addEventListener("click",(i)=>{ toggleButton(i) })
@Mayur-1182
Posted
@MasonBoom Thanks it's really a very helpful for me
@MasonBoom
Posted
@Mayur-1182 no problem
@Mayur-1182
Posted
@MasonBoom Can you give me some tips how i can improve my css ??
@Mayur-1182
Posted
@MasonBoom Can you give me some tips how i can improve my css ??
@MasonBoom
Posted
@Mayur-1182 your css file looks just fine to me, I would just increase the size of the rating buttons slightly.