Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 3 years ago

Interactive rating component using SASS and JS

bem, sass/scss, gulp
David•7,960
@DavidMorgade
A solution to the Interactive rating component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Just trying to figure out if there is any way to animate to display: none; using JS or CSS, searched a lot on google/mdn/stackoverflow but I still didnt manage to do it, any feedback about this will be appreciated!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • James•340
    @James-alderson
    Posted almost 3 years ago

    Hi David, the challenge you designed is very nice and well designed, there are just a few points that would help improve your design.

    1. Give the transition to the element itself, not to the floating element, because then when the mouse leaves the element, it will return to the original state in an animation. (rating__input button and .rating__btns).
    2. For ranks, it is better to use width and height, because in this case, there is no need to adjust the layer value to make it square, and if the numbers inside the ranks become two or three digits in the future, there is no need to change the padding value again.
    3. The centering of the element on the page is done correctly, but it is not correctly centered in high resolutions. For this reason, it is better to use the grid method to center the element. Use these styles in your body element: (display: grid, height: 100vh, place-items: center;) and remove these styles from your .rating element: (height: 100%; margin: 20vh auto;).

    /////////////////////////////////////

    To answer your question, currently I can't do this with css and javascript, instead you can use the max-height attribute to create the animation.

    Of course, there is a solution for your question, and that is using the jQuery library. Example of jQuery: jQuery Animated Accordion. When you click on the accordion title, you can see the conditions for changing the .content element using the web developer tool.

    Marked as helpful
  • Fluffy Kas•7,655
    @FluffyKas
    Posted about 3 years ago

    Heyo,

    What would you like to animate exactly? I only recently got into animations (css, js and some React animation libraries) so I'm not an expert but perhaps I could help.

    I'm not sure display: none can be animated tough. There are ways around it. Opacity, for one, could be animated easily with js or with css keyframes.

    Your solution looks really great btw, even as it is. :) There's a few small things you might wanna fix before looking into animations:

    1. For this challenge, radio inputs are more suitable than buttons. Bit harder to style, but it would be the logical choice.

    2. Your solution could be wrapped in <main> so it has a landmark at least. Guess it's not a huge deal, as it's just a component but it doesn't hurt to add it.

    3. You should leave the alt texts blank, announcing them by screen readers adds nothing to the content. ^^ Adding an aria-hidden="true" as well is a good idea too!

    4. For the submit button, don't use an <input>. There's a native button element in html that is a lot more suitable for this nowadays.

    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub