Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 6 months ago

product-list-with-cart

calvinvin•1,060
@calvinvin
A solution to the Product list with cart challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I used React and Vite.

This is my first time building React with Vite, and I learned NextJS at first. I should use Vite instead of NextJS first as a newbie just starting to learn web design by building small single page application like these challenges..., wasted some time figuring out everything from nothing and didn't know from which part the problems came.

This is also my first challenge solution with such a javascript-heavy job. It's fun, but after designing the javascript functions, I'm too tired to design the CSS very seriously 😉.

Code
Couldn’t fetch repository

Please log in to post a comment

Log in with GitHub

Community feedback

  • Jay Khatri•4,230
    @khatri2002
    Posted 6 months ago

    Hi @calvinvin!

    The developed solution looks great! Below are a few suggestions for improvement:


    1) "Add to Cart" Should Change View Only After Click

    Currently, when you hover over "Add to Cart", the layout changes immediately to show increment/decrement buttons. This is not the expected behavior.

    The user should be able to click on "Add to Cart" first. Only after clicking, the UI should update to show increment/decrement buttons. This is the standard approach followed by all e-commerce websites.

    2) Use button Instead of label, and span Instead of input

    1. The "Add to Cart" is wrapped inside a <label> tag.
      • Use a <button> instead.
    2. The quantity value is displayed inside an <input> field.
      Since users can't edit it, the blinking cursor might confuse them.
      Use a <span>, or if <input> is used, make it disabled.

    3) "Confirm Order" Button is Not Visible

    The "Confirm Order" button blends into the background, making it invisible. This happens because its background color matches the cart’s background.

    Use a distinct color for better visibility:

    .cart__confirm-button {
        background-color: var(--Red); /* Ensure contrast */
    }
    

    4) Improve Cart's HTML Structure

    The cart list (ul) should only contain added products (li). Currently, non-list items like order total, delivery message, and confirm button are also inside ul.
    Only products should be inside ul, and other details should be separate.


    The rest of the things look great! This is a solid solution! Keep up the fantastic work! 🚀

    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

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