This is a solution to the Interactive rating component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Select and submit a number rating
- See the "Thank you" card state after submitting a rating
Mobile
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- Mobile-first workflow
- React - JS library
- Styled Components - For styles
Learn alot about styling components with Styled Components, the way it generates custom classes along the ones added by the developer. Workarounds for creating specific functions and passing props along with the styling. Creating reusable components to avoid repeating code.
//fake radio button effect
for (let i = 0; i < btns.length; i++) {
if (btns[i] !== e.target) {
//get the current classes
currClasses = btns[i].className.split(' ');
//remove current class
const cIndex = currClasses.indexOf('current');
//remove current if exists
if (cIndex !== -1) {
currClasses.pop();
}
//set classes
btns[i].className = currClasses.join(' ');
} else {
btns[i].className += ' current';
}
}- Frontend Mentor - @serfoll
- Twitter - @sergio_fol

