Download index.html from Nada1223/teste-com: direct link, hf CLI and curl.
- Browser
- Download file 36.5 kB
-
https://huggingface.co/spaces/Nada1223/teste-com/resolve/main/index.html
- Command line
-
hf download hf://spaces/Nada1223/teste-com/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Nada1223/teste-com/resolve/main/index.html
36.5 kB
| <html lang="pt-BR"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>ShopPrime - Sua Loja Online Premium</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> | |
| /* Efeitos personalizados */ | |
| .product-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); | |
| } | |
| .cart-item-enter { | |
| animation: slideIn 0.3s forwards; | |
| } | |
| .cart-item-exit { | |
| animation: slideOut 0.3s forwards; | |
| } | |
| @keyframes slideIn { | |
| from { transform: translateX(100%); opacity: 0; } | |
| to { transform: translateX(0); opacity: 1; } | |
| } | |
| @keyframes slideOut { | |
| from { transform: translateX(0); opacity: 1; } | |
| to { transform: translateX(100%); opacity: 0; } | |
| } | |
| /* Barra de rolagem personalizada */ | |
| ::-webkit-scrollbar { | |
| width: 8px; | |
| } | |
| ::-webkit-scrollbar-track { | |
| background: #f1f1f1; | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background: #888; | |
| border-radius: 4px; | |
| } | |
| ::-webkit-scrollbar-thumb:hover { | |
| background: #555; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 font-sans"> | |
| <!-- Barra de navegação --> | |
| <nav class="bg-indigo-600 text-white shadow-lg 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"></i> | |
| <span class="text-xl font-bold">ShopPrime</span> | |
| </div> | |
| <div class="hidden md:flex space-x-6"> | |
| <a href="#" class="hover:text-indigo-200 transition">Início</a> | |
| <a href="#" class="hover:text-indigo-200 transition">Produtos</a> | |
| <a href="#" class="hover:text-indigo-200 transition">Ofertas</a> | |
| <a href="#" class="hover:text-indigo-200 transition">Contato</a> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <button id="search-btn" class="hover:text-indigo-200 transition"> | |
| <i class="fas fa-search"></i> | |
| </button> | |
| <button id="cart-btn" class="relative hover:text-indigo-200 transition"> | |
| <i class="fas fa-shopping-cart"></i> | |
| <span id="cart-count" class="absolute -top-2 -right-2 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">0</span> | |
| </button> | |
| <button class="md:hidden" id="menu-btn"> | |
| <i class="fas fa-bars text-xl"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Menu móvel --> | |
| <div id="mobile-menu" class="hidden md:hidden bg-indigo-700 px-4 py-2"> | |
| <a href="#" class="block py-2 hover:bg-indigo-600 px-2 rounded transition">Início</a> | |
| <a href="#" class="block py-2 hover:bg-indigo-600 px-2 rounded transition">Produtos</a> | |
| <a href="#" class="block py-2 hover:bg-indigo-600 px-2 rounded transition">Ofertas</a> | |
| <a href="#" class="block py-2 hover:bg-indigo-600 px-2 rounded transition">Contato</a> | |
| </div> | |
| <!-- Barra de pesquisa --> | |
| <div id="search-bar" class="hidden bg-indigo-700 px-4 py-3"> | |
| <div class="container mx-auto flex"> | |
| <input type="text" placeholder="Pesquisar produtos..." class="flex-grow px-4 py-2 rounded-l focus:outline-none text-gray-800"> | |
| <button class="bg-indigo-800 px-4 py-2 rounded-r hover:bg-indigo-900 transition"> | |
| <i class="fas fa-search"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </nav> | |
| <!-- Carrinho de compras --> | |
| <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"> | |
| <div class="p-4 border-b flex justify-between items-center"> | |
| <h3 class="text-xl font-bold">Seu Carrinho</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="overflow-y-auto h-3/4 p-4 space-y-4"> | |
| <!-- Itens do carrinho serão adicionados aqui via JavaScript --> | |
| <div class="text-center text-gray-500 py-10"> | |
| <i class="fas fa-shopping-cart text-4xl mb-2"></i> | |
| <p>Seu carrinho está vazio</p> | |
| </div> | |
| </div> | |
| <div class="absolute bottom-0 left-0 right-0 p-4 border-t bg-white"> | |
| <div class="flex justify-between mb-4"> | |
| <span class="font-bold">Total:</span> | |
| <span id="cart-total" class="font-bold">R$ 0,00</span> | |
| </div> | |
| <button class="w-full bg-indigo-600 text-white py-3 rounded hover:bg-indigo-700 transition font-medium"> | |
| Finalizar Compra | |
| </button> | |
| </div> | |
| </div> | |
| <!-- Overlay para o carrinho --> | |
| <div id="cart-overlay" class="fixed inset-0 bg-black bg-opacity-50 z-40 hidden"></div> | |
| <!-- Banner hero --> | |
| <div 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"> | |
| <h1 class="text-4xl md:text-5xl font-bold mb-4">As Melhores Ofertas do Ano</h1> | |
| <p class="text-xl mb-6">Descubra produtos incríveis com descontos exclusivos</p> | |
| <button class="bg-white text-indigo-600 px-6 py-3 rounded-full font-medium hover:bg-gray-100 transition shadow-lg"> | |
| Compre Agora | |
| </button> | |
| </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="Produtos em destaque" class="rounded-lg shadow-2xl max-w-full h-auto"> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Seção de categorias --> | |
| <div class="container mx-auto px-4 py-12"> | |
| <h2 class="text-3xl font-bold text-center mb-8">Nossas Categorias</h2> | |
| <div class="grid grid-cols-2 md:grid-cols-4 gap-4"> | |
| <div class="bg-white p-6 rounded-lg shadow-md text-center hover:shadow-lg transition cursor-pointer"> | |
| <div class="bg-indigo-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-3"> | |
| <i class="fas fa-laptop text-indigo-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-semibold">Eletrônicos</h3> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-md text-center hover:shadow-lg transition cursor-pointer"> | |
| <div class="bg-purple-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-3"> | |
| <i class="fas fa-tshirt text-purple-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-semibold">Moda</h3> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-md text-center hover:shadow-lg transition cursor-pointer"> | |
| <div class="bg-green-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-3"> | |
| <i class="fas fa-home text-green-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-semibold">Casa</h3> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-md text-center hover:shadow-lg transition cursor-pointer"> | |
| <div class="bg-yellow-100 w-16 h-16 mx-auto rounded-full flex items-center justify-center mb-3"> | |
| <i class="fas fa-gamepad text-yellow-600 text-2xl"></i> | |
| </div> | |
| <h3 class="font-semibold">Games</h3> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Produtos em destaque --> | |
| <div class="bg-gray-100 py-12"> | |
| <div class="container mx-auto px-4"> | |
| <div class="flex justify-between items-center mb-8"> | |
| <h2 class="text-3xl font-bold">Produtos em Destaque</h2> | |
| <a href="#" class="text-indigo-600 hover:text-indigo-800 font-medium">Ver todos →</a> | |
| </div> | |
| <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6" id="products-grid"> | |
| <!-- Produtos serão adicionados aqui via JavaScript --> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Ofertas especiais --> | |
| <div class="container mx-auto px-4 py-12"> | |
| <h2 class="text-3xl font-bold text-center mb-8">Ofertas Especiais</h2> | |
| <div class="bg-gradient-to-r from-red-500 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 font-bold mb-2">Black Friday Antecipada</h3> | |
| <p class="text-lg mb-4">Até 50% de desconto em produtos selecionados</p> | |
| <div class="flex space-x-2 mb-4"> | |
| <div class="bg-black bg-opacity-30 px-3 py-1 rounded"> | |
| <span class="font-bold text-xl" id="countdown-days">00</span> | |
| <span class="text-sm block">Dias</span> | |
| </div> | |
| <div class="bg-black bg-opacity-30 px-3 py-1 rounded"> | |
| <span class="font-bold text-xl" id="countdown-hours">00</span> | |
| <span class="text-sm block">Horas</span> | |
| </div> | |
| <div class="bg-black bg-opacity-30 px-3 py-1 rounded"> | |
| <span class="font-bold text-xl" id="countdown-minutes">00</span> | |
| <span class="text-sm block">Min</span> | |
| </div> | |
| <div class="bg-black bg-opacity-30 px-3 py-1 rounded"> | |
| <span class="font-bold text-xl" id="countdown-seconds">00</span> | |
| <span class="text-sm block">Seg</span> | |
| </div> | |
| </div> | |
| <button class="bg-white text-red-600 px-6 py-2 rounded-full font-medium hover:bg-gray-100 transition"> | |
| Aproveite as Ofertas | |
| </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="Ofertas" class="rounded-lg shadow-lg max-w-full h-auto"> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Depoimentos --> | |
| <div class="bg-gray-100 py-12"> | |
| <div class="container mx-auto px-4"> | |
| <h2 class="text-3xl font-bold text-center mb-8">O Que Nossos Clientes Dizem</h2> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6"> | |
| <div class="bg-white p-6 rounded-lg shadow-md"> | |
| <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">"Comprei um notebook e chegou antes do prazo. A qualidade é excelente e o preço estava ótimo!"</p> | |
| <div class="flex items-center"> | |
| <img src="https://randomuser.me/api/portraits/women/43.jpg" alt="Cliente" class="w-10 h-10 rounded-full mr-3"> | |
| <div> | |
| <h4 class="font-semibold">Ana Silva</h4> | |
| <p class="text-sm text-gray-500">São Paulo</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-md"> | |
| <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">"Ótimo atendimento e produtos de qualidade. Já comprei várias vezes e sempre fico satisfeito."</p> | |
| <div class="flex items-center"> | |
| <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="Cliente" class="w-10 h-10 rounded-full mr-3"> | |
| <div> | |
| <h4 class="font-semibold">Carlos Oliveira</h4> | |
| <p class="text-sm text-gray-500">Rio de Janeiro</p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-white p-6 rounded-lg shadow-md"> | |
| <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">"Adorei a variedade de produtos e as promoções. O frete foi grátis e chegou muito rápido!"</p> | |
| <div class="flex items-center"> | |
| <img src="https://randomuser.me/api/portraits/women/65.jpg" alt="Cliente" class="w-10 h-10 rounded-full mr-3"> | |
| <div> | |
| <h4 class="font-semibold">Mariana Costa</h4> | |
| <p class="text-sm text-gray-500">Belo Horizonte</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Newsletter --> | |
| <div class="bg-indigo-600 text-white py-12"> | |
| <div class="container mx-auto px-4 text-center"> | |
| <h2 class="text-3xl font-bold mb-4">Receba Nossas Ofertas</h2> | |
| <p class="text-xl mb-6 max-w-2xl mx-auto">Inscreva-se para receber promoções exclusivas e novidades diretamente no seu e-mail.</p> | |
| <div class="flex flex-col sm:flex-row max-w-md mx-auto sm:max-w-xl"> | |
| <input type="email" placeholder="Seu melhor e-mail" class="px-4 py-3 rounded-l sm:rounded-r-none sm:rounded-l mb-2 sm:mb-0 flex-grow text-gray-800 focus:outline-none"> | |
| <button class="bg-indigo-800 px-6 py-3 rounded-r sm:rounded-l-none sm:rounded-r hover:bg-indigo-900 transition font-medium"> | |
| Inscrever-se | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Rodapé --> | |
| <footer class="bg-gray-800 text-white py-8"> | |
| <div class="container mx-auto px-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-4 gap-8"> | |
| <div> | |
| <h3 class="text-xl font-bold mb-4 flex items-center"> | |
| <i class="fas fa-shopping-bag mr-2"></i> ShopPrime | |
| </h3> | |
| <p class="text-gray-400">A melhor experiência de compra online com produtos de qualidade e preços competitivos.</p> | |
| </div> | |
| <div> | |
| <h4 class="font-bold mb-4">Links Úteis</h4> | |
| <ul class="space-y-2"> | |
| <li><a href="#" class="text-gray-400 hover:text-white transition">Sobre Nós</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white transition">Política de Privacidade</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white transition">Termos de Serviço</a></li> | |
| <li><a href="#" class="text-gray-400 hover:text-white transition">Trocas e Devoluções</a></li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="font-bold mb-4">Atendimento</h4> | |
| <ul class="space-y-2"> | |
| <li class="text-gray-400"><i class="fas fa-phone-alt mr-2"></i> (11) 1234-5678</li> | |
| <li class="text-gray-400"><i class="fas fa-envelope mr-2"></i> contato@shopprime.com</li> | |
| <li class="text-gray-400"><i class="fas fa-clock mr-2"></i> Seg-Sex: 9h-18h</li> | |
| </ul> | |
| </div> | |
| <div> | |
| <h4 class="font-bold mb-4">Redes Sociais</h4> | |
| <div class="flex space-x-4"> | |
| <a href="#" class="bg-gray-700 w-10 h-10 rounded-full flex items-center justify-center hover:bg-indigo-600 transition"> | |
| <i class="fab fa-facebook-f"></i> | |
| </a> | |
| <a href="#" class="bg-gray-700 w-10 h-10 rounded-full flex items-center justify-center hover:bg-blue-400 transition"> | |
| <i class="fab fa-twitter"></i> | |
| </a> | |
| <a href="#" class="bg-gray-700 w-10 h-10 rounded-full flex items-center justify-center hover:bg-pink-600 transition"> | |
| <i class="fab fa-instagram"></i> | |
| </a> | |
| <a href="#" class="bg-gray-700 w-10 h-10 rounded-full flex items-center justify-center hover:bg-red-600 transition"> | |
| <i class="fab fa-youtube"></i> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400"> | |
| <p>© 2023 ShopPrime. Todos os direitos reservados.</p> | |
| </div> | |
| </div> | |
| </footer> | |
| <!-- Botão flutuante do WhatsApp --> | |
| <a href="#" class="fixed bottom-6 right-6 bg-green-500 text-white w-14 h-14 rounded-full flex items-center justify-center shadow-lg hover:bg-green-600 transition z-40"> | |
| <i class="fab fa-whatsapp text-2xl"></i> | |
| </a> | |
| <script> | |
| // Dados dos produtos | |
| const products = [ | |
| { | |
| id: 1, | |
| name: "Roblox Vermelho", | |
| price: 99.99, | |
| image: "https://tr.rbxcdn.com/9e2e7b6b1c5d1d2d0c0a0b0c0d0e0f0/420/420/Avatar/Png", | |
| description: "Personagem Roblox vermelho exclusivo para seu avatar.", | |
| rating: 5, | |
| discount: 10 | |
| }, | |
| { | |
| id: 2, | |
| name: "Smartphone Premium", | |
| price: 2499.99, | |
| image: "https://images.unsplash.com/photo-1592899677977-9c10ca588bbd?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "O mais recente smartphone com câmera de 108MP e bateria de longa duração.", | |
| rating: 5, | |
| discount: 15 | |
| }, | |
| { | |
| id: 3, | |
| name: "Notebook Ultrafino", | |
| price: 4299.99, | |
| image: "https://images.unsplash.com/photo-1611186871348-b1ce696e52c9?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Notebook leve e potente com processador de última geração.", | |
| rating: 4, | |
| discount: 10 | |
| }, | |
| { | |
| id: 4, | |
| name: "Fones de Ouvido Sem Fio", | |
| price: 399.99, | |
| image: "https://images.unsplash.com/photo-1590658268037-6bf12165a8df?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Áudio premium com cancelamento de ruído ativo.", | |
| rating: 5, | |
| discount: 20 | |
| }, | |
| { | |
| id: 5, | |
| name: "Smartwatch Inteligente", | |
| price: 799.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: "Monitor de saúde e notificações em tempo real.", | |
| rating: 4, | |
| discount: 25 | |
| }, | |
| { | |
| id: 6, | |
| name: "Câmera Profissional", | |
| price: 3599.99, | |
| image: "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Captura momentos com qualidade profissional.", | |
| rating: 5, | |
| discount: 0 | |
| }, | |
| { | |
| id: 7, | |
| name: "Console de Games", | |
| price: 2799.99, | |
| image: "https://images.unsplash.com/photo-1607853202273-797f1c22a38e?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "A nova geração de entretenimento digital.", | |
| rating: 5, | |
| discount: 5 | |
| }, | |
| { | |
| id: 8, | |
| name: "Caixa de Som Bluetooth", | |
| price: 299.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: "Som potente e portátil para qualquer lugar.", | |
| rating: 4, | |
| discount: 30 | |
| }, | |
| { | |
| id: 9, | |
| name: "Tablet Multifuncional", | |
| price: 1299.99, | |
| image: "https://images.unsplash.com/photo-1544242097-8a8b8c0a5fa7?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=80", | |
| description: "Produtividade e entretenimento em um só dispositivo.", | |
| rating: 4, | |
| discount: 15 | |
| } | |
| ]; | |
| // Carrinho de compras | |
| let cart = []; | |
| // Elementos DOM | |
| const productsGrid = document.getElementById('products-grid'); | |
| const cartItems = document.getElementById('cart-items'); | |
| const cartTotal = document.getElementById('cart-total'); | |
| const cartCount = document.getElementById('cart-count'); | |
| const cartBtn = document.getElementById('cart-btn'); | |
| const closeCartBtn = document.getElementById('close-cart'); | |
| const cartSidebar = document.getElementById('cart-sidebar'); | |
| const cartOverlay = document.getElementById('cart-overlay'); | |
| const menuBtn = document.getElementById('menu-btn'); | |
| const mobileMenu = document.getElementById('mobile-menu'); | |
| const searchBtn = document.getElementById('search-btn'); | |
| const searchBar = document.getElementById('search-bar'); | |
| // Função para formatar preço | |
| function formatPrice(price) { | |
| return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(price); | |
| } | |
| // Função para renderizar produtos | |
| function renderProducts() { | |
| productsGrid.innerHTML = ''; | |
| products.forEach(product => { | |
| const discountedPrice = product.price * (1 - (product.discount / 100)); | |
| const productCard = document.createElement('div'); | |
| productCard.className = 'bg-white rounded-lg shadow-md 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"> | |
| ${product.discount > 0 ? | |
| `<span class="absolute top-2 right-2 bg-red-500 text-white text-xs font-bold px-2 py-1 rounded-full"> | |
| -${product.discount}% | |
| </span>` : '' | |
| } | |
| </div> | |
| <div class="p-4"> | |
| <h3 class="font-semibold text-lg mb-1">${product.name}</h3> | |
| <div class="flex items-center mb-2"> | |
| ${Array.from({ length: 5 }, (_, i) => | |
| `<i class="fas fa-star ${i < product.rating ? 'text-yellow-400' : 'text-gray-300'}"></i>` | |
| ).join('')} | |
| </div> | |
| <p class="text-gray-600 text-sm mb-3">${product.description}</p> | |
| <div class="flex justify-between items-center"> | |
| <div> | |
| ${product.discount > 0 ? | |
| `<span class="text-gray-400 line-through text-sm">${formatPrice(product.price)}</span>` : '' | |
| } | |
| <p class="text-indigo-600 font-bold">${formatPrice(discountedPrice)}</p> | |
| </div> | |
| <button class="add-to-cart bg-indigo-600 text-white p-2 rounded-full hover:bg-indigo-700 transition" data-id="${product.id}"> | |
| <i class="fas fa-shopping-cart"></i> | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| productsGrid.appendChild(productCard); | |
| }); | |
| // Adiciona eventos aos botões de adicionar ao carrinho | |
| document.querySelectorAll('.add-to-cart').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(e.currentTarget.getAttribute('data-id')); | |
| addToCart(productId); | |
| }); | |
| }); | |
| } | |
| // Função para adicionar produto ao carrinho | |
| function addToCart(productId) { | |
| const product = products.find(p => p.id === productId); | |
| const discountedPrice = product.price * (1 - (product.discount / 100)); | |
| const existingItem = cart.find(item => item.id === productId); | |
| if (existingItem) { | |
| existingItem.quantity += 1; | |
| } else { | |
| cart.push({ | |
| ...product, | |
| quantity: 1, | |
| finalPrice: discountedPrice | |
| }); | |
| } | |
| updateCart(); | |
| // Animação de confirmação | |
| const cartIcon = cartBtn.querySelector('i'); | |
| cartIcon.classList.add('animate-bounce'); | |
| setTimeout(() => { | |
| cartIcon.classList.remove('animate-bounce'); | |
| }, 500); | |
| } | |
| // Função para remover item do carrinho | |
| function removeFromCart(productId) { | |
| cart = cart.filter(item => item.id !== productId); | |
| updateCart(); | |
| } | |
| // Função para atualizar quantidade no carrinho | |
| function updateQuantity(productId, newQuantity) { | |
| const item = cart.find(item => item.id === productId); | |
| if (item) { | |
| item.quantity = Math.max(1, newQuantity); | |
| updateCart(); | |
| } | |
| } | |
| // Função para atualizar o carrinho | |
| function updateCart() { | |
| // Atualiza contador | |
| const totalItems = cart.reduce((sum, item) => sum + item.quantity, 0); | |
| cartCount.textContent = totalItems; | |
| // Atualiza lista de itens | |
| if (cart.length === 0) { | |
| cartItems.innerHTML = ` | |
| <div class="text-center text-gray-500 py-10"> | |
| <i class="fas fa-shopping-cart text-4xl mb-2"></i> | |
| <p>Seu carrinho está vazio</p> | |
| </div> | |
| `; | |
| } else { | |
| cartItems.innerHTML = ''; | |
| cart.forEach(item => { | |
| const cartItem = document.createElement('div'); | |
| cartItem.className = 'cart-item-enter bg-gray-50 rounded-lg p-3 flex items-center'; | |
| cartItem.innerHTML = ` | |
| <img src="${item.image}" alt="${item.name}" class="w-16 h-16 object-cover rounded"> | |
| <div class="ml-3 flex-grow"> | |
| <h4 class="font-medium">${item.name}</h4> | |
| <p class="text-indigo-600 font-bold">${formatPrice(item.finalPrice)}</p> | |
| <div class="flex items-center mt-1"> | |
| <button class="decrease-quantity text-gray-500 hover:text-indigo-600" data-id="${item.id}"> | |
| <i class="fas fa-minus"></i> | |
| </button> | |
| <input type="number" value="${item.quantity}" min="1" class="quantity-input w-12 text-center mx-2 border rounded"> | |
| <button class="increase-quantity text-gray-500 hover:text-indigo-600" data-id="${item.id}"> | |
| <i class="fas fa-plus"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <button class="remove-item ml-2 text-gray-500 hover:text-red-500" data-id="${item.id}"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| `; | |
| cartItems.appendChild(cartItem); | |
| }); | |
| // Adiciona eventos aos controles de quantidade | |
| document.querySelectorAll('.decrease-quantity').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(e.currentTarget.getAttribute('data-id')); | |
| const item = cart.find(item => item.id === productId); | |
| if (item) { | |
| updateQuantity(productId, item.quantity - 1); | |
| } | |
| }); | |
| }); | |
| document.querySelectorAll('.increase-quantity').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(e.currentTarget.getAttribute('data-id')); | |
| const item = cart.find(item => item.id === productId); | |
| if (item) { | |
| updateQuantity(productId, item.quantity + 1); | |
| } | |
| }); | |
| }); | |
| document.querySelectorAll('.quantity-input').forEach(input => { | |
| input.addEventListener('change', (e) => { | |
| const productId = parseInt(e.currentTarget.closest('.flex').querySelector('button').getAttribute('data-id')); | |
| const newQuantity = parseInt(e.currentTarget.value); | |
| updateQuantity(productId, newQuantity); | |
| }); | |
| }); | |
| document.querySelectorAll('.remove-item').forEach(button => { | |
| button.addEventListener('click', (e) => { | |
| const productId = parseInt(e.currentTarget.getAttribute('data-id')); | |
| removeFromCart(productId); | |
| }); | |
| }); | |
| } | |
| // Atualiza total | |
| const total = cart.reduce((sum, item) => sum + (item.finalPrice * item.quantity), 0); | |
| cartTotal.textContent = formatPrice(total); | |
| } | |
| // Contador regressivo para ofertas | |
| function updateCountdown() { | |
| const now = new Date(); | |
| const targetDate = new Date(); | |
| targetDate.setDate(now.getDate() + 5); // 5 dias a partir de agora | |
| targetDate.setHours(23, 59, 59, 0); | |
| const diff = targetDate - now; | |
| const days = Math.floor(diff / (1000 * 60 * 60 * 24)); | |
| const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | |
| const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); | |
| const seconds = Math.floor((diff % (1000 * 60)) / 1000); | |
| document.getElementById('countdown-days').textContent = days.toString().padStart(2, '0'); | |
| document.getElementById('countdown-hours').textContent = hours.toString().padStart(2, '0'); | |
| document.getElementById('countdown-minutes').textContent = minutes.toString().padStart(2, '0'); | |
| document.getElementById('countdown-seconds').textContent = seconds.toString().padStart(2, '0'); | |
| } | |
| // Event listeners | |
| cartBtn.addEventListener('click', () => { | |
| cartSidebar.classList.remove('translate-x-full'); | |
| cartOverlay.classList.remove('hidden'); | |
| document.body.style.overflow = 'hidden'; | |
| }); | |
| closeCartBtn.addEventListener('click', () => { | |
| cartSidebar.classList.add('translate-x-full'); | |
| cartOverlay.classList.add('hidden'); | |
| document.body.style.overflow = ''; | |
| }); | |
| cartOverlay.addEventListener('click', () => { | |
| cartSidebar.classList.add('translate-x-full'); | |
| cartOverlay.classList.add('hidden'); | |
| document.body.style.overflow = ''; | |
| }); | |
| menuBtn.addEventListener('click', () => { | |
| mobileMenu.classList.toggle('hidden'); | |
| }); | |
| searchBtn.addEventListener('click', () => { | |
| searchBar.classList.toggle('hidden'); | |
| }); | |
| // Inicialização | |
| document.addEventListener('DOMContentLoaded', () => { | |
| renderProducts(); | |
| updateCountdown(); | |
| setInterval(updateCountdown, 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=Nada1223/teste-com" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |