Frontend Mentor - E-commerce product page solution

This is my solution to the E-commerce product page challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the site depending on their device's screen size ✅
  • See hover states for all interactive elements on the page ✅
  • Open a lightbox gallery by clicking on the large product image ✅
  • Switch the large product image by clicking on the small thumbnail images ✅
  • Add items to the cart ✅
  • View the cart and remove items from it ✅

Screenshot

Links

My process

Built with

What I learned

It was my first time building a lightbox gallery. I had to think deep to come up with the logic.

function swipeRight() {
  // function to view next image
  setImageIndex((prev) => {
    if (prev >= 0 && prev < 3) {
      return prev + 1;
    } else {
      return 0;
    }
  });
}

function swipeLeft() {
  // function to view previous image
  setImageIndex((prev) => {
    if (prev <= 3 && prev > 0) {
      return prev - 1;
    } else {
      return 3;
    }
  });
}

Continued development

I will use this project as a stepping stone to build a full e-commerce site.

Useful resources

  • scrimba - This is in my opinion the best place to learn web development.
  • stack overflow - Whenever I got stuck, I always found some insight here.

Author