Giter VIP home page Giter VIP logo

zaidkhan144 / shopping-cart Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 2.0 49.33 MB

An E-commerce skateboard website with all the shopping cart functionalities. I have created this in react. For styling, I have used styled-components, and for animation, I have used the framer-motion library.

Home Page: https://zaidkhan144.github.io/shopping-cart/#/

HTML 7.40% JavaScript 91.43% CSS 1.17%
skateboard reactjs styled-components framer-motion react-router e-commerce

shopping-cart's Introduction

Uptown Skate Shop

An E-commerce skateboard website with all the shopping cart functionalities.

Homepage

image

Shop page

image

Shop Item page

image

Cart Items page

image

Installation and Setup Instructions

To make below steps work, You will need node and npm installed globally on your machine.

# Clone this repository
$ git clone https://github.com/ZaidKhan144/shopping-cart.git

# Enter the Git folder
$ cd shopping-cart

# Enter the project folder
$ cd skateboard

# Install dependencies
$ npm install

# Start the project
$ npm start

Tech used

  • React
  • Styled Components
  • Framer Motion
  • Styled Icons
  • ESLint - A linter tool to standardize code
  • Prettier - Code formatter
  • GitHub Pages

Reflection

This project's main goal was to design and develop a multiple-page application using react-router-dom. The app can add, update, and remove items from the cart.

I started this project by creating a create-react-app boilerplate and then added react-router-4.0.

One of the main challenges I ran into was adding an item to the cart. I knew I have to match the item ID with the index's ID. In my mind, there were two JS methods from where I could achieve this, one was using findIndex, and the other was to use indexOf with the map. After a bit of researching, I opt to choose findIndex to get better performance. The thing with findIndex is that it will stop as soon as it finds the item you're looking for, whereas the map doesn't care what item you're searching for. Even if the item is at first index, it will still loop through every item to create a new array of Indexes. This would be quite a lot of work to achieve the same result. I know it doesn't make any difference for data this short, but still, I wanted to try the best.

Another challenge I came across was designing the Cart Item page. Initially, I made the main grid for columns, cart, and order summary. And then another grid inside the cart to handle cart items detail. Now at this point, It was working great for one item, but as soon as I added one more item, it appeared at the order summary place instead of dropping in the cart column, and the order summary was moved to the second row. After a bit of research, it turns out the CSS grid generates rows dynamically by default. I tried handling it with other grid properties but couldn't achieve the desired result. On thinking about this overnight, I realized why don't wrap the cart items detail into a parent grid and stretch cart items equal to the number of columns. This way, each item will render on its own row without overflowing the cart grid.

The last challenge I faced was to hide browser video controls. On inspecting on video, we get to see two options Loop and Show Controls. So to hide those options, I made a mask at the top and positioned it relative to the video. Now, if you inspect a video, you won't see those options.

At the end of the day, the technologies implemented in this project are React, React-Router, styled-components, and framer-motion library. I chose styled-components because of its ability to make reusable components to handle CSS and framer-motion because of its declarative syntax. I have also made this responsive to give an optimized browsing experience.

In the future, I might add more product options and create a filter to search for desired results.

You can visit the App here: https://zaidkhan144.github.io/shopping-cart/#/

Funny story, Remember when I mentioned wrapping cart items by a parent div? So I was struggling to come up with its name to use it as a component, and I had to make sure I don't forget it as well, so I named it DaddyCart ๐Ÿ˜‚

image

shopping-cart's People

Contributors

zaidkhan144 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

josealz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.