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.
- Overview
- The challenge
- Screenshot
- Links
- My process
- Built with
- What I learned
- Continued development
- Useful resources
- Author
- Acknowledgments
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: Add solution URL here
- Live Site URL
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
- BEM
- Sass
- Prettier formatter
- Vanilla JS
CSS
- I was super excited to add rotation on the little star icon as well as to make the results image float up and down.
.starImg {
animation: spin 3s infinite linear;
}
.results__img {
animation: float 3s ease-in-out infinite;
}
@keyframes spin {
from {
transform: rotate(deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes float {
0% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
100% {
transform: translateY(0);
}
}
Javascript
- Iwas having a hard time making the hover states behave like I wanted to but here is my solution below
cardItem.addEventListener("mouseenter", () => {
if (!cardItem.classList.contains("clicked")) {
cardItem.style.backgroundColor = "hsl(25, 97%, 53%)";
}
});
cardItem.addEventListener("mouseleave", () => {
if (!cardItem.classList.contains("clicked")) {
cardItem.style.backgroundColor = "#363c44";
}
});
});
This was my first Javascript project, and I learned a lot! I can't wait to build my next project and hone my js skills.
- Frontend Mentor - @garcialexco