A real-life shopping cart application built with React/Typescript/Vitest.
I have written a tutorial about how I did this. You can find it here or here.
- React / Typescript / Vite
- SASS / CSS Modules
- react-testing-library / Vitest
The Shopping Cart consists of two pages: the product list page and the cart page
- The header component contains the application's logo on the left side, which is clickable and points to the product list page
- The header component contains the application's cart widget, which represents a cart icon with a number, signifying the count of the products added in the cart
- The header component is auto-shrinkable, which means whenever the user scrolls down, the header and its elements size is reduced
- The header component supports certain degree of opacity, which adds up to the look and feel of the app and also allows better visibility for the users
- The product list page lists all available products, displaying each product's thumbnail image, title, price (formatted as GBP) and a button for adding it to the cart
- The product list page is usable on both desktop and mobile devices, whereas on desktop it leverages three items per row grid, on mobile view is two or one, depending on the viewport width
- The cart page lists all products that are added to the cart, displaying each product's thumbnail image, title and an option for updating the desired quantity
- The logic of the quantifier component allows to add as many items as the user wants, but if the user decreases the count to zero, the product will be removed from the cart
- The cart page displays the total price of all items added, formatted as GBP, i.e. £100.23, on the bottom of the page, right after the list with all items
- The footer component displays social media links and copyright info, as well as the current version of the application
- Add item price in the cart page for better visibility
- Add small animations to improve the UX, for example shaking the cart icon when a product is being added (or vibrating when used on mobile device)
- Add options for registering and login, and saving choices for later
- Add rating system where user can rate each product
- Add option for leaving comments/reviews
To run the app, follow these steps.
- Ensure that NodeJS is installed.
- Install yarn.
- From the project folder, execute the following commands:
To install dependencies:
yarn
To run the app:
yarn dev
To run the tests:
yarn test