Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pritamtirpude/e-commerce-product-page

E-commerce product landing page.
https://github.com/pritamtirpude/e-commerce-product-page

context-api custom-hooks framer-motion javascript reactjs semantic-html tailwindcss vitejs

Last synced: 16 days ago
JSON representation

E-commerce product landing page.

Awesome Lists containing this project

README

        

# Frontend Mentor - E-commerce product page solution

This is a solution to the [E-commerce product page challenge on Frontend Mentor](https://www.frontendmentor.io/challenges/ecommerce-product-page-UPsZ9MJp6). Frontend Mentor challenges help you improve your coding skills by building realistic projects.

## Table of contents

- [Frontend Mentor - E-commerce product page solution](#frontend-mentor---e-commerce-product-page-solution)
- [Table of contents](#table-of-contents)
- [Overview](#overview)
- [The challenge](#the-challenge)
- [Screenshot](#screenshot)
- [Links](#links)
- [My process](#my-process)
- [Built with](#built-with)
- [What I learned](#what-i-learned)
- [Author](#author)


## 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

![](./src/assets/screenshot_one.png)
![](./src/assets/screenshot_two.png)

### Links

- Solution URL: [Frontend Mentor Solution URL](https://www.frontendmentor.io/solutions/product-landing-page-using-react-js-context-api-tailwind-css-4pssbWUEdj)
- Live Site URL: [Live URL](https://e-commerce-product-page-app.vercel.app/)

## My process

### Built with

- Semantic HTML5 markup
- Tailwind CSS
- Flexbox
- Mobile-first workflow
- [React](https://reactjs.org/) - JS library
- [Framer Motion](https://www.framer.com/) - Animation Library

### What I learned

Learned how to build a custom lightbox gallery using framer motion and Reusable components.

```LightBox Component JSX
const LightBox = ({ setIsClicked, isProduct }) => {
const [imgIndex, setImgIndex] = useState(isProduct);
const [direction, setDirection] = useState("");

const productImages = [
productOneImg,
productTwoImg,
productThreeImg,
productFourImg,
];

const thumbsArray = [
productOneThumb,
productTwoThumb,
productThreeThumb,
productFourThumb,
];

const handleNext = () => {
setImgIndex((prevState) =>
prevState + 1 === productImages.length ? 0 : prevState + 1
);
setDirection("right");
};

const handlePrevious = () => {
setImgIndex((prevState) =>
prevState - 1 < 0 ? productImages.length - 1 : prevState - 1
);
setDirection("left");
};

return (
setIsClicked((prevState) => !prevState)}
>

e.stopPropagation()}>










setIsClicked((prevState) => !prevState)}
>


e.stopPropagation()}
>
{thumbsArray.map((thumb, index) => (
setImgIndex(index)}
className={`${
imgIndex === index ? "ring-2 ring-primary-orange" : ""
} overflow-hidden shadow-lg rounded-xl relative z-50 cursor-pointer`}
>
thumbnail





))}


);
};
```

## Author

- Frontend Mentor - [@pritamtirpude](https://www.frontendmentor.io/profile/pritamtirpude)
- Twitter - [@ptirpude1991](https://twitter.com/ptirpude1991)