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
- Solution URL: Interactive Rating
- React
- CSS custom properties
- Flexbox
- React - JS library
I learned how to use css modules in React. CSS Modules let you use the same CSS class name in different files without worrying about naming clashes. I used enviroment variable for min and max rating number, I create and file .env with two variables
REACT_APP_NOT_MIN_RATING = 1
REACT_APP_NOT_MAX_RATING = 5
and in components I used this command:
const min = process.env.REACT_APP_NOT_MIN_RATING;
const max = process.env.REACT_APP_NOT_MAX_RATING;
In future projects I want to use more React (props, context, hooks)
- Adding a CSS Modules Stylesheet - This helped me to understand how to use css modules
- Frontend Mentor - @dunaidan