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

Interactive rating component in Vanilla JS and CSS

Gus•60
@angusgee
A solution to the Interactive rating component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


  1. Is this solution complete, or should I really create a separate class for the rating buttons' active states? At the moment there's no "state" as such, only the variable ratingScore.

  2. The "You selected 3 out of 5" text looks slightly too high in it's div to me, can you confirm? I can't see any reason why it would be out, it has 8px top and bottom padding and should inherit display:flex, align-items:center and justify-content:center from its parent.

  3. How important and relevant is it to use a CSS preprocessor like SASS? Would you recommend that I change? I'm aiming to become a full-stack dev one day.

  4. Do my commits look okay? Any feedback there about using Github in a professional setting.

  5. Any other suggestions about best practices? Again bearing in mind that I'm aiming to learn to produce production-quality code.

Cheers!

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Lucas 👾•104,160
    @correlucas
    Posted almost 3 years ago

    👾Hello MaltaWebDev, congratulations on completing this challenge!

    Nice code and nice solution! You did a good job here putting everything together. I’ve some suggestions for you:

    Your component is perfect, but is not responsive yet, this is due the fixed width you've applied to the container.Look both width and max-width the main difference between these properties is that the first(width) is fixed and the second(max-width) is flexible, for example, a component with width: 340px will not grow or shrink because the size will be ever the same, but a container with max-width: 340px or min-width: 340px can grow or contract depending of the property you've set for the container. So if you want a responsive block element, never use width choose or min-width or max-width.

    To improve the card overall responsibility, you can start to add flex-wrap inside the class that manages the section for the rating numbers button and makes the adjust to fit in different rows while the container scales down, not that without this property the container doesn't shrink. Here's the code applying these changes:

    .rating-buttons {
        display: flex;
        justify-content: space-between;
        margin-bottom: 35px;
        padding: 0 20px 0 20px;
        flex-wrap: wrap;
    }
    

    ✌️ I hope this helps you and happy coding!

    Marked as helpful
  • Mehdi•990
    @siavhnz
    Posted almost 3 years ago

    Hello MaltaWebDev

    In Slack, you asked about comparing work and design, I use perfect pixel extension for my solutions which is a great tool for comparing when working on a challenge.

    here is a link to the Pixel Prefect Chrome extension

    Happy coding

    Marked as helpful
  • Adriano•42,890
    @AdrianoEscarabote
    Posted over 2 years ago

    Hello MaltaWebDev!!

    I noticed that your link to the active page is not working to fix this added this link:

    https://maltawebdev.github.io/RatingCard/

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

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

Oops! 😬

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

Log in with GitHub