Spaces:
Running
Running
Download index.html from dharnny/test-e-commerce: direct link, hf CLI and curl.
- Browser
- Download file 42.5 kB
-
https://huggingface.co/spaces/dharnny/test-e-commerce/resolve/main/index.html
- Command line
-
hf download hf://spaces/dharnny/test-e-commerce/index.html
-
curl -L -o index.html https://huggingface.co/spaces/dharnny/test-e-commerce/resolve/main/index.html
42.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ShopEase - Your Online Shopping Destination</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| /* Custom CSS for animations and effects */ | |
| .product-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); | |
| } | |
| .cart-item-enter { | |
| opacity: 0; | |
| transform: translateX(-20px); | |
| } | |
| .cart-item-enter-active { | |
| opacity: 1; | |
| transform: translateX(0); | |
| transition: all 300ms ease-in; | |
| } | |
| .cart-item-exit { | |
| opacity: 1; | |
| } | |
| .cart-item-exit-active { | |
| opacity: 0; | |
| transform: translateX(20px); | |
| transition: all 300ms ease-in; | |
| } | |
| @keyframes pulse { | |
| 0%, 100% { | |
| transform: scale(1); | |
| } | |
| 50% { | |
| transform: scale(1.05); | |
| } | |
| } | |
| .pulse-animation { | |
| animation: pulse 1.5s infinite; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <!-- Header/Navigation --> | |
| <header class="bg-white shadow-sm sticky top-0 z-50"> | |
| <div class="container mx-auto px-4 py-3 flex justify-between items-center"> | |
| <div class="flex items-center space-x-2"> | |
| <i class="fas fa-shopping-bag text-2xl text-indigo-600"></i> | |
| <h1 class="text-xl font-bold text-gray-800">Shop<span class="text-indigo-600">Ease</span></h1> | |
| </div> | |
| <div class="hidden md:flex items-center space-x-6"> | |
| <a href="#" class="text-gray-700 hover:text-indigo-600 transition">Home</a> | |
| <a href="#products" class="text-gray-700 hover:text-indigo-600 transition">Products</a> | |
| <a href="#deals" class="text-gray-700 hover:text-indigo-600 transition">Deals</a> | |
| <a href="#about" class="text-gray-700 hover:text-indigo-600 transition">About</a> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <button id="search-btn" class="text-gray-600 hover:text-indigo-600"> | |
| <i class="fas fa-search"></i> | |
| </button> | |
| <button id="cart-btn" class="relative text-gray-600 hover:text-indigo-600"> | |
| <i class="fas fa-shopping-cart"></i> | |
| <span id="cart-count" class="absolute -top-2 -right-2 bg-indigo-600 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">0</span> | |
| </button> | |
| <button id="mobile-menu-btn" class="md:hidden text-gray-600 hover:text-indigo-600"> | |
| <i class="fas fa-bars"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Mobile Menu --> | |
| <div id="mobile-menu" class="hidden md:hidden bg-white py-2 px-4 shadow-md"> | |
| <a href="#" class="block py-2 text-gray-700 hover:text-indigo-600">Home</a> | |
| <a href="#products" class="block py-2 text-gray-700 hover:text-indigo-600">Products</a> | |
| <a href="#deals" class="block py-2 text-gray-700 hover:text-indigo-600">Deals</a> | |
| <a href="#about" class="block py-2 text-gray-700 hover:text-indigo-600">About</a> | |
| </div> | |
| <!-- Search Bar --> | |
| <div id="search-bar" class="hidden bg-white py-3 px-4 shadow-sm"> | |
| <div class="container mx-auto flex"> | |
| <input type="text" placeholder="Search for products..." class="flex-grow px-4 py-2 border border-gray-300 rounded-l-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"> | |
| <button class="bg-indigo-600 text-white px-4 py-2 rounded-r-lg hover:bg-indigo-700 transition"> | |
| <i class="fas fa-search"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Hero Section --> | |
| <section class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white py-16"> | |
| <div class="container mx-auto px-4 flex flex-col md:flex-row items-center"> | |
| <div class="md:w-1/2 mb-8 md:mb-0"> | |
| <h2 class="text-4xl md:text-5xl font-bold mb-4">Summer Sale Up To 50% Off</h2> | |
| <p class="text-xl mb-6">Discover amazing deals on your favorite products. Limited time offer!</p> | |
| <div class="flex space-x-4"> | |
| <button class="bg-white text-indigo-600 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition">Shop Now</button> | |
| <button class="border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:text-indigo-600 transition">Learn More</button> | |
| </div> | |
| </div> | |
| <div class="md:w-1/2 flex justify-center"> | |
| <img src="https://images.unsplash.com/photo-1523275335684-37898b6baf30?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80" alt="Featured Product" class="rounded-lg shadow-xl max-w-md w-full h-auto pulse-animation"> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Categories --> | |
| <section class="py-12 bg-white"> | |
| <div class="container mx-auto px-4"> | |
| <h2 class="text-3xl font-bold text-center mb-10 text-gray-800">Shop by Category</h2> | |
| <div class="grid grid-cols-2 md:grid-cols-4 gap-6"> | |
| <div class="bg-gray-100 rounded-lg p-6 text-center hover:bg-indigo-50 transition cursor-pointer"> | |
| <div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4"> | |
| <i class="fas fa-tshirt text-indigo-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-medium text-gray-800">Fashion</h3> | |
| </div> | |
| <div class="bg-gray-100 rounded-lg p-6 text-center hover:bg-indigo-50 transition cursor-pointer"> | |
| <div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4"> | |
| <i class="fas fa-laptop text-indigo-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-medium text-gray-800">Electronics</h3> | |
| </div> | |
| <div class="bg-gray-100 rounded-lg p-6 text-center hover:bg-indigo-50 transition cursor-pointer"> | |
| <div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4"> | |
| <i class="fas fa-home text-indigo-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-medium text-gray-800">Home</h3> | |
| </div> | |
| <div class="bg-gray-100 rounded-lg p-6 text-center hover:bg-indigo-50 transition cursor-pointer"> | |
| <div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-4"> | |
| <i class="fas fa-gamepad text-indigo-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-medium text-gray-800">Gaming</h3> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Featured Products --> | |
| <section id="products" class="py-12 bg-gray-50"> | |
| <div class="container mx-auto px-4"> | |
| <div class="flex justify-between items-center mb-8"> | |
| <h2 class="text-3xl font-bold text-gray-800">Featured Products</h2> | |
| <a href="#" class="text-indigo-600 hover:text-indigo-800 font-medium">View All</a> | |
| </div> | |
| <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6" id="products-container"> | |
| <!-- Products will be dynamically added here --> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Special Offers --> | |
| <section id="deals" class="py-12 bg-white"> | |
| <div class="container mx-auto px-4"> | |
| <h2 class="text-3xl font-bold text-center mb-10 text-gray-800">Special Offers</h2> | |
| <div class="bg-gradient-to-r from-yellow-400 to-orange-500 rounded-xl p-8 text-white"> | |
| <div class="flex flex-col md:flex-row items-center"> | |
| <div class="md:w-1/2 mb-6 md:mb-0"> | |
| <h3 class="text-2xl md:text-3xl font-bold mb-4">Flash Sale!</h3> | |
| <p class="text-lg mb-4">Limited time offer on selected items. Don't miss out!</p> | |
| <div class="flex items-center mb-4"> | |
| <div class="bg-white text-orange-500 px-3 py-1 rounded mr-2"> | |
| <span id="hours">12</span>h | |
| </div> | |
| <div class="bg-white text-orange-500 px-3 py-1 rounded mr-2"> | |
| <span id="minutes">45</span>m | |
| </div> | |
| <div class="bg-white text-orange-500 px-3 py-1 rounded"> | |
| <span id="seconds">30</span>s | |
| </div> | |
| </div> | |
| <button class="bg-white text-orange-500 px-6 py-2 rounded-lg font-medium hover:bg-gray-100 transition">Shop Now</button> | |
| </div> | |
| <div class="md:w-1/2 flex justify-center"> | |
| <img src="https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80" alt="Special Offer" class="rounded-lg shadow-lg max-w-xs w-full h-auto"> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Testimonials --> | |
| <section class="py-12 bg-gray-50"> | |
| <div class="container mx-auto px-4"> | |
| <h2 class="text-3xl font-bold text-center mb-10 text-gray-800">What Our Customers Say</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6"> | |
| <div class="bg-white p-6 rounded-lg shadow-sm"> | |
| <div class="flex items-center mb-4"> | |
| <div class="text-yellow-400 mr-2"> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| </div> | |
| </div> | |
| <p class="text-gray-600 mb-4">"The quality of products is amazing and the delivery was super fast. Will definitely shop here again!"</p> | |
| <div class="flex items-center"> | |
| <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="Customer" class="w-10 h-10 rounded-full mr-3"> | |
| <div> | |
| <h4 class="font-medium">Sarah Johnson</h4> | |
| <p class="text-sm text-gray-500">Verified Buyer</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-sm"> | |
| <div class="flex items-center mb-4"> | |
| <div class="text-yellow-400 mr-2"> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star-half-alt"></i> | |
| </div> | |
| </div> | |
| <p class="text-gray-600 mb-4">"Great customer service! They helped me choose the perfect gift for my wife's birthday. Highly recommended!"</p> | |
| <div class="flex items-center"> | |
| <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="Customer" class="w-10 h-10 rounded-full mr-3"> | |
| <div> | |
| <h4 class="font-medium">Michael Chen</h4> | |
| <p class="text-sm text-gray-500">Verified Buyer</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-sm"> | |
| <div class="flex items-center mb-4"> | |
| <div class="text-yellow-400 mr-2"> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| </div> | |
| </div> | |
| <p class="text-gray-600 mb-4">"The checkout process was so smooth and my order arrived earlier than expected. Very impressed!"</p> | |
| <div class="flex items-center"> | |
| <img src="https://randomuser.me/api/portraits/women/68.jpg" alt="Customer" class="w-10 h-10 rounded-full mr-3"> | |
| <div> | |
| <h4 class="font-medium">Emily Rodriguez</h4> | |
| <p class="text-sm text-gray-500">Verified Buyer</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Newsletter --> | |
| <section class="py-12 bg-indigo-600 text-white"> | |
| <div class="container mx-auto px-4 text-center"> | |
| <h2 class="text-3xl font-bold mb-4">Subscribe to Our Newsletter</h2> | |
| <p class="text-xl mb-6 max-w-2xl mx-auto">Get the latest updates on new products, special offers, and exclusive discounts.</p> | |
| <div class="flex flex-col sm:flex-row max-w-md mx-auto sm:max-w-xl"> | |
| <input type="email" placeholder="Your email address" class="flex-grow px-4 py-3 rounded-l-lg sm:rounded-r-none rounded-r-lg text-gray-800 focus:outline-none"> | |
| <button class="bg-indigo-800 px-6 py-3 rounded-r-lg sm:rounded-l-none rounded-l-lg mt-2 sm:mt-0 hover:bg-indigo-900 transition">Subscribe</button> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- About Section --> | |
| <section id="about" class="py-12 bg-white"> | |
| <div class="container mx-auto px-4"> | |
| <div class="flex flex-col md:flex-row items-center"> | |
| <div class="md:w-1/2 mb-8 md:mb-0"> | |
| <h2 class="text-3xl font-bold mb-6 text-gray-800">About ShopEase</h2> | |
| <p class="text-gray-600 mb-4">Founded in 2020, ShopEase has quickly become a trusted name in online shopping, offering a wide range of high-quality products at competitive prices.</p> | |
| <p class="text-gray-600 mb-6">Our mission is to make online shopping easy, enjoyable, and accessible to everyone, with fast shipping, excellent customer service, and a seamless shopping experience.</p> | |
| <button class="bg-indigo-600 text-white px-6 py-3 rounded-lg font-medium hover:bg-indigo-700 transition">Learn More</button> | |
| </div> | |
| <div class="md:w-1/2 flex justify-center"> | |
| <img src="https://images.unsplash.com/photo-1556740738-b6a63e27c4df?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80" alt="Our Team" class="rounded-lg shadow-lg max-w-md w-full h-auto"> | |
| </div> | |
| </div> | |
| </div> | |
| </section> | |
| <!-- Footer --> | |
| <footer class="bg-gray-800 text-white py-12"> | |
| <div class="container mx-auto px-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-8"> | |
| <div> | |
| <div class="flex items-center space-x-2 mb-4"> | |
| <i class="fas fa-shopping-bag text-2xl text-indigo-400"></i> | |
| <h3 class="text-xl font-bold">Shop<span class="text-indigo-400">Ease</span></h3> | |
| </div> | |
| <p class="text-gray-400 mb-4">Your one-stop shop for all your needs. Quality products, fast delivery, and excellent service.</p> | |
| <div class="flex space-x-4"> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-facebook-f"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-twitter"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-instagram"></i></a> | |
| <a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-linkedin-in"></i></a> | |
| </div> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4">Quick Links</h4> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Home</a></li> | |
| <li><a href="#products" class="text-gray-400 hover:text-white">Products</a></li> | |
| <li><a href="#deals" class="text-gray-400 hover:text-white">Special Offers</a></li> | |
| <li><a href="#about" class="text-gray-400 hover:text-white">About Us</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Contact</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4">Customer Service</h4> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-gray-400 hover:text-white">My Account</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Order Tracking</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Wishlist</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Shipping Info</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white">Returns & Exchanges</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="text-lg font-semibold mb-4">Contact Us</h4> | |
| <ul class="space-y-2 text-gray-400"> | |
| <li class="flex items-start"> | |
| <i class="fas fa-map-marker-alt mt-1 mr-2 text-indigo-400"></i> | |
| <span>123 Shopping Street, Retail City, 10001</span> | |
| </li> | |
| <li class="flex items-start"> | |
| <i class="fas fa-phone-alt mt-1 mr-2 text-indigo-400"></i> | |
| <span>+1 (555) 123-4567</span> | |
| </li> | |
| <li class="flex items-start"> | |
| <i class="fas fa-envelope mt-1 mr-2 text-indigo-400"></i> | |
| <span>info@shopease.com</span> | |
| </li> | |
| </ul> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400"> | |
| <p>© 2023 ShopEase. All rights reserved.</p> | |
| </div> | |
| </div> | |
| </footer> | |
| <!-- Shopping Cart Sidebar --> | |
| <div id="cart-sidebar" class="fixed top-0 right-0 h-full w-full md:w-96 bg-white shadow-lg transform translate-x-full transition-transform duration-300 ease-in-out z-50 overflow-y-auto"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h3 class="text-xl font-bold">Your Cart</h3> | |
| <button id="close-cart" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div id="cart-items" class="mb-6"> | |
| <!-- Cart items will be dynamically added here --> | |
| <div class="text-center py-8 text-gray-500" id="empty-cart-message"> | |
| <i class="fas fa-shopping-cart text-4xl mb-3"></i> | |
| <p>Your cart is empty</p> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-200 pt-4 mb-4"> | |
| <div class="flex justify-between mb-2"> | |
| <span class="font-medium">Subtotal:</span> | |
| <span id="cart-subtotal">$0.00</span> | |
| </div> | |
| <div class="flex justify-between mb-2"> | |
| <span class="font-medium">Shipping:</span> | |
| <span>Free</span> | |
| </div> | |
| <div class="flex justify-between text-lg font-bold"> | |
| <span>Total:</span> | |
| <span id="cart-total">$0.00</span> | |
| </div> | |
| </div> | |
| <button id="checkout-btn" class="w-full bg-indigo-600 text-white py-3 rounded-lg font-medium hover:bg-indigo-700 transition mb-3">Proceed to Checkout</button> | |
| <button class="w-full border border-indigo-600 text-indigo-600 py-3 rounded-lg font-medium hover:bg-indigo-50 transition">Continue Shopping</button> | |
| </div> | |
| </div> | |
| <!-- Overlay for cart sidebar --> | |
| <div id="overlay" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden"></div> | |
| <!-- Product Quick View Modal --> | |
| <div id="quick-view-modal" class="fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center hidden"> | |
| <div class="bg-white rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-start mb-4"> | |
| <h3 id="quick-view-title" class="text-2xl font-bold">Product Quick View</h3> | |
| <button id="close-quick-view" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="flex flex-col md:flex-row gap-6"> | |
| <div class="md:w-1/2"> | |
| <img id="quick-view-image" src="" alt="Product" class="w-full rounded-lg"> | |
| </div> | |
| <div class="md:w-1/2"> | |
| <div class="flex items-center mb-2"> | |
| <div class="text-yellow-400 mr-2"> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star-half-alt"></i> | |
| </div> | |
| <span class="text-gray-500 text-sm">(24 reviews)</span> | |
| </div> | |
| <p id="quick-view-price" class="text-2xl font-bold text-gray-800 mb-4">$99.99</p> | |
| <p id="quick-view-description" class="text-gray-600 mb-6">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> | |
| <div class="flex items-center mb-6"> | |
| <span class="mr-4 font-medium">Quantity:</span> | |
| <div class="flex items-center border border-gray-300 rounded"> | |
| <button class="px-3 py-1 text-gray-600 hover:bg-gray-100">-</button> | |
| <span class="px-3 py-1 border-x border-gray-300">1</span> | |
| <button class="px-3 py-1 text-gray-600 hover:bg-gray-100">+</button> | |
| </div> | |
| </div> | |
| <div class="flex space-x-4"> | |
| <button class="flex-1 bg-indigo-600 text-white py-3 rounded-lg font-medium hover:bg-indigo-700 transition"> | |
| <i class="fas fa-shopping-cart mr-2"></i> Add to Cart | |
| </button> | |
| <button class="flex-1 border border-indigo-600 text-indigo-600 py-3 rounded-lg font-medium hover:bg-indigo-50 transition"> | |
| <i class="far fa-heart mr-2"></i> Wishlist | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Sample product data | |
| const products = [ | |
| { | |
| id: 1, | |
| name: "Wireless Headphones", | |
| price: 89.99, | |
| image: "https://images.unsplash.com/photo-1505740420928-5e560c06d30e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Premium wireless headphones with noise cancellation and 30-hour battery life." | |
| }, | |
| { | |
| id: 2, | |
| name: "Smart Watch", | |
| price: 199.99, | |
| image: "https://images.unsplash.com/photo-1523275335684-37898b6baf30?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Track your fitness, receive notifications, and more with this stylish smartwatch." | |
| }, | |
| { | |
| id: 3, | |
| name: "Bluetooth Speaker", | |
| price: 59.99, | |
| image: "https://images.unsplash.com/photo-1572569511254-d8f925fe2cbb?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Portable Bluetooth speaker with 20W output and 15-hour playtime." | |
| }, | |
| { | |
| id: 4, | |
| name: "Laptop Backpack", | |
| price: 49.99, | |
| image: "https://images.unsplash.com/photo-1553062407-98eeb64c6a62?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Durable and stylish backpack with padded laptop compartment." | |
| }, | |
| { | |
| id: 5, | |
| name: "Wireless Keyboard", | |
| price: 69.99, | |
| image: "https://images.unsplash.com/photo-1587829741301-dc798b83cc3a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Slim wireless keyboard with quiet keys and long battery life." | |
| }, | |
| { | |
| id: 6, | |
| name: "Fitness Tracker", | |
| price: 79.99, | |
| image: "https://images.unsplash.com/photo-1576243345690-4e4b79b63288?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Track your steps, heart rate, and sleep with this comfortable fitness band." | |
| }, | |
| { | |
| id: 7, | |
| name: "Portable Charger", | |
| price: 39.99, | |
| image: "https://images.unsplash.com/photo-1598128558393-70ff21433be0?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "10000mAh portable charger with fast charging capability." | |
| }, | |
| { | |
| id: 8, | |
| name: "Gaming Mouse", | |
| price: 45.99, | |
| image: "https://images.unsplash.com/photo-1527814050087-3793815479db?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "High-precision gaming mouse with customizable RGB lighting." | |
| } | |
| ]; | |
| // Shopping cart data | |
| let cart = []; | |
| // DOM elements | |
| const productsContainer = document.getElementById('products-container'); | |
| const cartBtn = document.getElementById('cart-btn'); | |
| const cartSidebar = document.getElementById('cart-sidebar'); | |
| const closeCartBtn = document.getElementById('close-cart'); | |
| const cartItemsContainer = document.getElementById('cart-items'); | |
| const cartCount = document.getElementById('cart-count'); | |
| const cartSubtotal = document.getElementById('cart-subtotal'); | |
| const cartTotal = document.getElementById('cart-total'); | |
| const emptyCartMessage = document.getElementById('empty-cart-message'); | |
| const overlay = document.getElementById('overlay'); | |
| const mobileMenuBtn = document.getElementById('mobile-menu-btn'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| const searchBtn = document.getElementById('search-btn'); | |
| const searchBar = document.getElementById('search-bar'); | |
| const quickViewModal = document.getElementById('quick-view-modal'); | |
| const closeQuickViewBtn = document.getElementById('close-quick-view'); | |
| // Initialize the page | |
| document.addEventListener('DOMContentLoaded', () => { | |
| renderProducts(); | |
| updateCartCount(); | |
| startCountdown(); | |
| // Event listeners | |
| cartBtn.addEventListener('click', toggleCart); | |
| closeCartBtn.addEventListener('click', toggleCart); | |
| overlay.addEventListener('click', toggleCart); | |
| mobileMenuBtn.addEventListener('click', toggleMobileMenu); | |
| searchBtn.addEventListener('click', toggleSearchBar); | |
| closeQuickViewBtn.addEventListener('click', closeQuickView); | |
| }); | |
| // Render products to the page | |
| function renderProducts() { | |
| productsContainer.innerHTML = ''; | |
| products.forEach(product => { | |
| const productCard = document.createElement('div'); | |
| productCard.className = 'bg-white rounded-lg shadow-sm overflow-hidden product-card transition duration-300'; | |
| productCard.innerHTML = ` | |
| <div class="relative"> | |
| <img src="${product.image}" alt="${product.name}" class="w-full h-48 object-cover"> | |
| <button class="absolute top-2 right-2 bg-white rounded-full w-8 h-8 flex items-center justify-center shadow-md hover:bg-gray-100"> | |
| <i class="far fa-heart text-gray-600"></i> | |
| </button> | |
| </div> | |
| <div class="p-4"> | |
| <h3 class="font-semibold text-lg mb-1">${product.name}</h3> | |
| <div class="flex items-center mb-2"> | |
| <div class="text-yellow-400 text-sm"> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star"></i> | |
| <i class="fas fa-star-half-alt"></i> | |
| </div> | |
| <span class="text-gray-500 text-sm ml-1">(24)</span> | |
| </div> | |
| <div class="flex justify-between items-center"> | |
| <span class="font-bold text-lg">$${product.price.toFixed(2)}</span> | |
| <button class="bg-indigo-600 text-white px-3 py-1 rounded hover:bg-indigo-700 transition add-to-cart" data-id="${product.id}"> | |
| <i class="fas fa-shopping-cart mr-1"></i> Add | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| // Add event listener for quick view | |
| productCard.addEventListener('click', (e) => { | |
| if (!e.target.closest('.add-to-cart') && !e.target.closest('.fa-heart')) { | |
| openQuickView(product); | |
| } | |
| }); | |
| productsContainer.appendChild(productCard); | |
| }); | |
| // Add event listeners to all "Add to Cart" buttons | |
| document.querySelectorAll('.add-to-cart').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| const productId = parseInt(button.getAttribute('data-id')); | |
| addToCart(productId); | |
| }); | |
| }); | |
| } | |
| // Add product to cart | |
| function addToCart(productId) { | |
| const product = products.find(p => p.id === productId); | |
| // Check if product already exists in cart | |
| const existingItem = cart.find(item => item.id === productId); | |
| if (existingItem) { | |
| existingItem.quantity += 1; | |
| } else { | |
| cart.push({ | |
| ...product, | |
| quantity: 1 | |
| }); | |
| } | |
| updateCartCount(); | |
| renderCartItems(); | |
| // Show cart sidebar if it's hidden | |
| if (cartSidebar.classList.contains('translate-x-full')) { | |
| toggleCart(); | |
| } | |
| // Show success message | |
| const notification = document.createElement('div'); | |
| notification.className = 'fixed top-4 right-4 bg-green-500 text-white px-4 py-2 rounded-lg shadow-lg flex items-center'; | |
| notification.innerHTML = ` | |
| <i class="fas fa-check-circle mr-2"></i> | |
| <span>Added to cart!</span> | |
| `; | |
| document.body.appendChild(notification); | |
| setTimeout(() => { | |
| notification.classList.add('opacity-0', 'transition-opacity', 'duration-300'); | |
| setTimeout(() => notification.remove(), 300); | |
| }, 2000); | |
| } | |
| // Remove product from cart | |
| function removeFromCart(productId) { | |
| cart = cart.filter(item => item.id !== productId); | |
| updateCartCount(); | |
| renderCartItems(); | |
| } | |
| // Update product quantity in cart | |
| function updateQuantity(productId, newQuantity) { | |
| const item = cart.find(item => item.id === productId); | |
| if (item) { | |
| item.quantity = newQuantity; | |
| if (item.quantity <= 0) { | |
| removeFromCart(productId); | |
| } else { | |
| updateCartCount(); | |
| renderCartItems(); | |
| } | |
| } | |
| } | |
| // Render cart items in sidebar | |
| function renderCartItems() { | |
| cartItemsContainer.innerHTML = ''; | |
| if (cart.length === 0) { | |
| emptyCartMessage.classList.remove('hidden'); | |
| cartSubtotal.textContent = '$0.00'; | |
| cartTotal.textContent = '$0.00'; | |
| return; | |
| } | |
| emptyCartMessage.classList.add('hidden'); | |
| let subtotal = 0; | |
| cart.forEach(item => { | |
| const cartItem = document.createElement('div'); | |
| cartItem.className = 'flex items-center py-4 border-b border-gray-200 cart-item'; | |
| cartItem.innerHTML = ` | |
| <img src="${item.image}" alt="${item.name}" class="w-16 h-16 object-cover rounded"> | |
| <div class="ml-4 flex-grow"> | |
| <h4 class="font-medium">${item.name}</h4> | |
| <p class="text-gray-600">$${item.price.toFixed(2)}</p> | |
| </div> | |
| <div class="flex items-center"> | |
| <button class="text-gray-500 hover:text-indigo-600 quantity-decrease" data-id="${item.id}"> | |
| <i class="fas fa-minus"></i> | |
| </button> | |
| <span class="mx-2 w-8 text-center">${item.quantity}</span> | |
| <button class="text-gray-500 hover:text-indigo-600 quantity-increase" data-id="${item.id}"> | |
| <i class="fas fa-plus"></i> | |
| </button> | |
| </div> | |
| <button class="ml-4 text-gray-500 hover:text-red-500 remove-item" data-id="${item.id}"> | |
| <i class="fas fa-trash"></i> | |
| </button> | |
| `; | |
| cartItemsContainer.appendChild(cartItem); | |
| subtotal += item.price * item.quantity; | |
| }); | |
| // Update totals | |
| cartSubtotal.textContent = `$${subtotal.toFixed(2)}`; | |
| cartTotal.textContent = `$${subtotal.toFixed(2)}`; | |
| // Add event listeners to quantity buttons | |
| document.querySelectorAll('.quantity-decrease').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(button.getAttribute('data-id')); | |
| const item = cart.find(item => item.id === productId); | |
| if (item) { | |
| updateQuantity(productId, item.quantity - 1); | |
| } | |
| }); | |
| }); | |
| document.querySelectorAll('.quantity-increase').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(button.getAttribute('data-id')); | |
| const item = cart.find(item => item.id === productId); | |
| if (item) { | |
| updateQuantity(productId, item.quantity + 1); | |
| } | |
| }); | |
| }); | |
| document.querySelectorAll('.remove-item').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(button.getAttribute('data-id')); | |
| removeFromCart(productId); | |
| }); | |
| }); | |
| } | |
| // Update cart count in header | |
| function updateCartCount() { | |
| const count = cart.reduce((total, item) => total + item.quantity, 0); | |
| cartCount.textContent = count; | |
| } | |
| // Toggle cart sidebar | |
| function toggleCart() { | |
| if (cartSidebar.classList.contains('translate-x-full')) { | |
| cartSidebar.classList.remove('translate-x-full'); | |
| overlay.classList.remove('hidden'); | |
| document.body.style.overflow = 'hidden'; | |
| } else { | |
| cartSidebar.classList.add('translate-x-full'); | |
| overlay.classList.add('hidden'); | |
| document.body.style.overflow = 'auto'; | |
| } | |
| } | |
| // Toggle mobile menu | |
| function toggleMobileMenu() { | |
| mobileMenu.classList.toggle('hidden'); | |
| } | |
| // Toggle search bar | |
| function toggleSearchBar() { | |
| searchBar.classList.toggle('hidden'); | |
| } | |
| // Open quick view modal | |
| function openQuickView(product) { | |
| document.getElementById('quick-view-title').textContent = product.name; | |
| document.getElementById('quick-view-image').src = product.image; | |
| document.getElementById('quick-view-price').textContent = `$${product.price.toFixed(2)}`; | |
| document.getElementById('quick-view-description').textContent = product.description; | |
| quickViewModal.classList.remove('hidden'); | |
| document.body.style.overflow = 'hidden'; | |
| } | |
| // Close quick view modal | |
| function closeQuickView() { | |
| quickViewModal.classList.add('hidden'); | |
| document.body.style.overflow = 'auto'; | |
| } | |
| // Countdown timer for flash sale | |
| function startCountdown() { | |
| let hours = 12; | |
| let minutes = 45; | |
| let seconds = 30; | |
| const hoursElement = document.getElementById('hours'); | |
| const minutesElement = document.getElementById('minutes'); | |
| const secondsElement = document.getElementById('seconds'); | |
| const timer = setInterval(() => { | |
| seconds--; | |
| if (seconds < 0) { | |
| seconds = 59; | |
| minutes--; | |
| } | |
| if (minutes < 0) { | |
| minutes = 59; | |
| hours--; | |
| } | |
| if (hours < 0) { | |
| clearInterval(timer); | |
| return; | |
| } | |
| hoursElement.textContent = hours.toString().padStart(2, '0'); | |
| minutesElement.textContent = minutes.toString().padStart(2, '0'); | |
| secondsElement.textContent = seconds.toString().padStart(2, '0'); | |
| }, 1000); | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=dharnny/test-e-commerce" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |