/*
OnlineShop.jsx
Single-file React component (default export) for an online-shopping demo.
Copy-paste into a React project that has Tailwind CSS configured.
Requirements (install in your project):
npm install framer-motion lucide-react @radix-ui/react-dialog @shadcn/ui
(shadcn/ui and Radix are optional — the code falls back to simple elements)
How to use:
1. Ensure Tailwind is configured in your project (recommended: Create React App + Tailwind, Vite + Tailwind, or Next.js with Tailwind).
2. Place this file under src/components/OnlineShop.jsx
3. Import and render: import OnlineShop from './components/OnlineShop';
Notes:
- This is a client-only demo (no backend). Products are stored in a local array.
- Replace placeholder images with your own or connect to an API when ready.
- All styles use Tailwind utility classes for an aesthetic, modern look.
*/
import React, {useState, useMemo} from 'react';
import {motion, AnimatePresence} from 'framer-motion';
import {ShoppingCart, X, Search, Heart} from 'lucide-react';
// shadcn components optional
import {Button} from '@shadcn/ui/button';
const sampleProducts = [
{
id: 'p1',
title: 'Aurora Wireless Headphones',
price: 3499,
rating: 4.6,
img: 'https://images.unsplash.com/photo-1518444020302-6a484d2f6f0d?q=80&w=800&auto=format&fit=crop&ixlib=rb-4.0.3&s=1',
category: 'Electronics',
badge: 'Bestseller',
},
{
id: 'p2',
title: 'Minimal Leather Wallet',
price: 799,
rating: 4.3,
img: 'https://images.unsplash.com/photo-1519744792095-2f2205e87b6f?q=80&w=800&auto=format&fit=crop&ixlib=rb-4.0.3&s=2',
category: 'Accessories',
},
{
id: 'p3',
title: 'Breeze Running Shoes',
price: 2599,
rating: 4.5,
img: 'https://images.unsplash.com/photo-1528701800489-4766b2f9f1b6?q=80&w=800&auto=format&fit=crop&ixlib=rb-4.0.3&s=3',
category: 'Footwear',
badge: 'Limited',
},
{
id: 'p4',
title: 'Ceramic Coffee Mug (Set of 2)',
price: 499,
rating: 4.1,
img: 'https://images.unsplash.com/photo-1523942839745-7848a47f0c3f?q=80&w=800&auto=format&fit=crop&ixlib=rb-4.0.3&s=4',
category: 'Home',
},
{
id