A lightweight shopping cart application built with Svelte, TypeScript, and TailwindCSS.
The project demonstrates how to manage state, reactivity, and UI interactions in Svelte without relying on heavy frameworks.
π Features
- Product Listing β Products are loaded from an API (
loadData
) and displayed in a responsive grid.
- Add to Cart β Users can add products with a single click.
- Cart Drawer β A side cart panel shows selected items, quantities, and total price.
- Increase / Decrease Quantity β Update product quantity directly from the cart.
- Remove Items β Remove items individually from the cart.
- Free Shipping Notification β Alerts the user when their total cart value exceeds
$50
.
- Cart State Management β Implemented using Svelteβs
$state
, $derived
, and $effect
reactivity.
- Type Safety β Written in TypeScript with strong typing for products and cart items.
- Responsive Design β Styled with TailwindCSS for a modern, responsive layout.
π Project Structure
src/
βββ Api.ts # API loader for fetching products
βββ App.svelte # Main shopping cart UI
βββ cart-item.svelte # Component for individual cart items
βββ Types.ts # TypeScript interfaces (Product, CartProduct)
βοΈ Tech Stack
πΈ Screenshots
π§ Installation & Usage
- Clone the repo
```bash
git clone https://github.com/awadreda/shopping-cart-svelte.git
cd shopping-cart-svelte
npm install
npm run dev