File size: 33,074 Bytes
e995f10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>T-Shirt Store | Votre boutique de t-shirts 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>
/* Animation pour le bouton panier */
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.animate-pulse {
animation: pulse 1s infinite;
}
/* Transition pour les cartes produits */
.product-card {
transition: all 0.3s ease;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
/* Style personnalisé pour le menu déroulant */
.dropdown:hover .dropdown-menu {
display: block;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<!-- Barre de navigation -->
<nav class="bg-white shadow-lg sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between items-center h-16">
<!-- Logo -->
<div class="flex-shrink-0 flex items-center">
<span class="text-xl font-bold text-indigo-600">T-SHIRT STORE</span>
</div>
<!-- Menu principal -->
<div class="hidden md:block">
<div class="ml-10 flex items-center space-x-4">
<a href="#" class="text-gray-900 px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100">Accueil</a>
<div class="dropdown relative">
<button class="text-gray-900 px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100 flex items-center">
Collections <i class="fas fa-chevron-down ml-1 text-xs"></i>
</button>
<div class="dropdown-menu absolute hidden bg-white mt-2 py-2 w-48 rounded-md shadow-lg z-50">
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Nouveautés</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Best-sellers</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Édition limitée</a>
</div>
</div>
<a href="#" class="text-gray-900 px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100">Homme</a>
<a href="#" class="text-gray-900 px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100">Femme</a>
<a href="#" class="text-gray-900 px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100">Enfant</a>
<a href="#" class="text-gray-900 px-3 py-2 rounded-md text-sm font-medium hover:bg-gray-100">Contact</a>
</div>
</div>
<!-- Icônes utilisateur/panier -->
<div class="flex items-center space-x-4">
<button class="p-2 rounded-full text-gray-600 hover:text-gray-900 hover:bg-gray-100">
<i class="fas fa-search"></i>
</button>
<button class="p-2 rounded-full text-gray-600 hover:text-gray-900 hover:bg-gray-100">
<i class="fas fa-user"></i>
</button>
<button id="cart-btn" class="p-2 rounded-full text-gray-600 hover:text-gray-900 hover:bg-gray-100 relative">
<i class="fas fa-shopping-cart"></i>
<span id="cart-count" class="absolute -top-1 -right-1 bg-indigo-600 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center hidden">0</span>
</button>
<!-- Menu mobile -->
<button id="mobile-menu-button" class="md:hidden p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100">
<i class="fas fa-bars"></i>
</button>
</div>
</div>
</div>
<!-- Menu mobile (caché par défaut) -->
<div id="mobile-menu" class="md:hidden hidden">
<div class="px-2 pt-2 pb-3 space-y-1 sm:px-3">
<a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:bg-gray-100">Accueil</a>
<a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:bg-gray-100">Collections</a>
<a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:bg-gray-100">Homme</a>
<a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:bg-gray-100">Femme</a>
<a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:bg-gray-100">Enfant</a>
<a href="#" class="block px-3 py-2 rounded-md text-base font-medium text-gray-900 hover:bg-gray-100">Contact</a>
</div>
</div>
</nav>
<!-- Bannière hero -->
<div class="relative bg-indigo-700 overflow-hidden">
<div class="max-w-7xl mx-auto">
<div class="relative z-10 pb-8 bg-indigo-700 sm:pb-16 md:pb-20 lg:max-w-2xl lg:w-full lg:pb-28 xl:pb-32">
<div class="pt-10 sm:pt-16 lg:pt-8 lg:pb-14 lg:overflow-hidden">
<div class="mt-10 mx-auto max-w-7xl px-4 sm:mt-12 sm:px-6 md:mt-16 lg:mt-20 lg:px-8 xl:mt-28">
<div class="sm:text-center lg:text-left">
<h1 class="text-4xl tracking-tight font-extrabold text-white sm:text-5xl md:text-6xl">
<span class="block">Collection Été 2023</span>
<span class="block text-indigo-200">Des t-shirts uniques</span>
</h1>
<p class="mt-3 text-base text-indigo-200 sm:mt-5 sm:text-lg sm:max-w-xl sm:mx-auto md:mt-5 md:text-xl lg:mx-0">
Découvrez notre nouvelle collection de t-shirts fabriqués à partir de coton bio et conçus pour durer.
</p>
<div class="mt-5 sm:mt-8 sm:flex sm:justify-center lg:justify-start">
<div class="rounded-md shadow">
<a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-indigo-700 bg-white hover:bg-gray-50 md:py-4 md:text-lg md:px-10">
Voir la collection
</a>
</div>
<div class="mt-3 sm:mt-0 sm:ml-3">
<a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-white bg-indigo-500 bg-opacity-60 hover:bg-opacity-70 md:py-4 md:text-lg md:px-10">
En savoir plus
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="lg:absolute lg:inset-y-0 lg:right-0 lg:w-1/2">
<img class="h-56 w-full object-cover sm:h-72 md:h-96 lg:w-full lg:h-full" src="https://images.unsplash.com/photo-1529374255404-311a2a4f1fd9?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="Collection de t-shirts">
</div>
</div>
<!-- Section produits populaires -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<div class="text-center mb-12">
<h2 class="text-3xl font-extrabold text-gray-900 sm:text-4xl">Nos best-sellers</h2>
<p class="mt-4 max-w-xl mx-auto text-gray-500">Découvrez les t-shirts les plus populaires de notre boutique.</p>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
<!-- Produit 1 -->
<div class="product-card bg-white rounded-lg overflow-hidden shadow-md">
<div class="relative">
<img class="w-full h-64 object-cover" src="https://images.unsplash.com/photo-1576566588028-4147f3842f27?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="T-shirt graphique">
<div class="absolute top-0 right-0 p-2">
<button class="p-2 rounded-full bg-white text-gray-800 hover:text-indigo-600">
<i class="far fa-heart"></i>
</button>
</div>
<div class="absolute bottom-0 left-0 bg-indigo-600 text-white px-2 py-1 text-xs font-bold">
NOUVEAU
</div>
</div>
<div class="p-4">
<h3 class="text-lg font-semibold text-gray-900">T-shirt Graphique</h3>
<p class="text-gray-600 text-sm mt-1">Design exclusif - Coton bio</p>
<div class="mt-3 flex justify-between items-center">
<span class="text-lg font-bold text-gray-900">29,99€</span>
<button class="add-to-cart bg-indigo-600 text-white px-3 py-1 rounded-md text-sm hover:bg-indigo-700 transition" data-id="1" data-name="T-shirt Graphique" data-price="29.99">
Ajouter au panier
</button>
</div>
</div>
</div>
<!-- Produit 2 -->
<div class="product-card bg-white rounded-lg overflow-hidden shadow-md">
<div class="relative">
<img class="w-full h-64 object-cover" src="https://images.unsplash.com/photo-1527719327859-c6ce80353573?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="T-shirt uni">
<div class="absolute top-0 right-0 p-2">
<button class="p-2 rounded-full bg-white text-gray-800 hover:text-indigo-600">
<i class="far fa-heart"></i>
</button>
</div>
</div>
<div class="p-4">
<h3 class="text-lg font-semibold text-gray-900">T-shirt Uni</h3>
<p class="text-gray-600 text-sm mt-1">Couleurs vives - 100% coton</p>
<div class="mt-3 flex justify-between items-center">
<span class="text-lg font-bold text-gray-900">24,99€</span>
<button class="add-to-cart bg-indigo-600 text-white px-3 py-1 rounded-md text-sm hover:bg-indigo-700 transition" data-id="2" data-name="T-shirt Uni" data-price="24.99">
Ajouter au panier
</button>
</div>
</div>
</div>
<!-- Produit 3 -->
<div class="product-card bg-white rounded-lg overflow-hidden shadow-md">
<div class="relative">
<img class="w-full h-64 object-cover" src="https://images.unsplash.com/photo-1521572163474-6864f9cf17ab?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="T-shirt vintage">
<div class="absolute top-0 right-0 p-2">
<button class="p-2 rounded-full bg-white text-gray-800 hover:text-indigo-600">
<i class="far fa-heart"></i>
</button>
</div>
<div class="absolute bottom-0 left-0 bg-red-500 text-white px-2 py-1 text-xs font-bold">
PROMO -20%
</div>
</div>
<div class="p-4">
<h3 class="text-lg font-semibold text-gray-900">T-shirt Vintage</h3>
<p class="text-gray-600 text-sm mt-1">Style rétro - Coupe oversize</p>
<div class="mt-3 flex justify-between items-center">
<div>
<span class="text-lg font-bold text-gray-900">22,49€</span>
<span class="text-sm text-gray-500 line-through ml-2">27,99€</span>
</div>
<button class="add-to-cart bg-indigo-600 text-white px-3 py-1 rounded-md text-sm hover:bg-indigo-700 transition" data-id="3" data-name="T-shirt Vintage" data-price="22.49">
Ajouter au panier
</button>
</div>
</div>
</div>
<!-- Produit 4 -->
<div class="product-card bg-white rounded-lg overflow-hidden shadow-md">
<div class="relative">
<img class="w-full h-64 object-cover" src="https://images.unsplash.com/photo-1583743814966-8936f5b7be1a?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1000&q=80" alt="T-shirt sport">
<div class="absolute top-0 right-0 p-2">
<button class="p-2 rounded-full bg-white text-gray-800 hover:text-indigo-600">
<i class="far fa-heart"></i>
</button>
</div>
</div>
<div class="p-4">
<h3 class="text-lg font-semibold text-gray-900">T-shirt Sport</h3>
<p class="text-gray-600 text-sm mt-1">Respirant - Séchage rapide</p>
<div class="mt-3 flex justify-between items-center">
<span class="text-lg font-bold text-gray-900">34,99€</span>
<button class="add-to-cart bg-indigo-600 text-white px-3 py-1 rounded-md text-sm hover:bg-indigo-700 transition" data-id="4" data-name="T-shirt Sport" data-price="34.99">
Ajouter au panier
</button>
</div>
</div>
</div>
</div>
<div class="mt-12 text-center">
<a href="#" class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700">
Voir tous les produits
<i class="fas fa-arrow-right ml-2"></i>
</a>
</div>
</div>
<!-- Section avantages -->
<div class="bg-gray-100 py-12">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div class="text-center p-6 bg-white rounded-lg shadow-sm">
<div class="mx-auto flex items-center justify-center h-12 w-12 rounded-md bg-indigo-100 text-indigo-600 mb-4">
<i class="fas fa-leaf text-xl"></i>
</div>
<h3 class="text-lg font-medium text-gray-900">Matériaux durables</h3>
<p class="mt-2 text-gray-600">Nos t-shirts sont fabriqués à partir de coton bio et de matériaux recyclés.</p>
</div>
<div class="text-center p-6 bg-white rounded-lg shadow-sm">
<div class="mx-auto flex items-center justify-center h-12 w-12 rounded-md bg-indigo-100 text-indigo-600 mb-4">
<i class="fas fa-truck text-xl"></i>
</div>
<h3 class="text-lg font-medium text-gray-900">Livraison rapide</h3>
<p class="mt-2 text-gray-600">Expédition sous 24h et livraison gratuite à partir de 50€ d'achat.</p>
</div>
<div class="text-center p-6 bg-white rounded-lg shadow-sm">
<div class="mx-auto flex items-center justify-center h-12 w-12 rounded-md bg-indigo-100 text-indigo-600 mb-4">
<i class="fas fa-undo text-xl"></i>
</div>
<h3 class="text-lg font-medium text-gray-900">Retours faciles</h3>
<p class="mt-2 text-gray-600">30 jours pour changer d'avis, retour gratuit et sans frais.</p>
</div>
</div>
</div>
</div>
<!-- Section newsletter -->
<div class="bg-indigo-700 py-12">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="md:flex md:items-center md:justify-between">
<div class="md:w-1/2">
<h2 class="text-2xl font-bold text-white">Abonnez-vous à notre newsletter</h2>
<p class="mt-2 text-indigo-200">Recevez en exclusivité nos offres spéciales et nouveautés.</p>
</div>
<div class="mt-4 md:mt-0 md:w-1/2">
<form class="flex">
<input type="email" placeholder="Votre email" class="flex-1 px-4 py-2 rounded-l-md focus:outline-none focus:ring-2 focus:ring-indigo-500">
<button type="submit" class="bg-indigo-900 text-white px-6 py-2 rounded-r-md hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-indigo-500">
S'abonner
</button>
</form>
<p class="mt-2 text-xs text-indigo-200">En vous abonnant, vous acceptez notre politique de confidentialité.</p>
</div>
</div>
</div>
</div>
<!-- Footer -->
<footer class="bg-gray-900 text-white pt-12 pb-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
<div>
<h3 class="text-lg font-semibold mb-4">T-SHIRT STORE</h3>
<p class="text-gray-400 text-sm">Votre boutique en ligne de t-shirts premium depuis 2015.</p>
<div class="mt-4 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-pinterest"></i></a>
</div>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Boutique</h3>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Nouveautés</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Collections</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Homme</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Femme</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Enfant</a></li>
</ul>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Informations</h3>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white text-sm">À propos</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Blog</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Livraison</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Retours</a></li>
<li><a href="#" class="text-gray-400 hover:text-white text-sm">Contact</a></li>
</ul>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Contact</h3>
<address class="text-gray-400 text-sm not-italic">
<p>123 Rue du Commerce</p>
<p>75000 Paris, France</p>
<p class="mt-2"><i class="fas fa-phone-alt mr-2"></i> +33 1 23 45 67 89</p>
<p><i class="fas fa-envelope mr-2"></i> contact@tshirtstore.com</p>
</address>
</div>
</div>
<div class="mt-12 pt-8 border-t border-gray-800 flex flex-col md:flex-row justify-between items-center">
<p class="text-gray-400 text-sm">© 2023 T-SHIRT STORE. Tous droits réservés.</p>
<div class="mt-4 md:mt-0 flex space-x-6">
<a href="#" class="text-gray-400 hover:text-white text-sm">Mentions légales</a>
<a href="#" class="text-gray-400 hover:text-white text-sm">CGV</a>
<a href="#" class="text-gray-400 hover:text-white text-sm">Politique de confidentialité</a>
</div>
</div>
</div>
</footer>
<!-- Panier latéral -->
<div id="cart-sidebar" class="fixed inset-y-0 right-0 w-full md:w-96 bg-white shadow-xl 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 border-b pb-4">
<h2 class="text-xl font-bold text-gray-900">Votre panier</h2>
<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="mt-6 space-y-4">
<!-- Les articles du panier seront ajoutés ici dynamiquement -->
<div class="text-center py-8 text-gray-500" id="empty-cart-message">
<i class="fas fa-shopping-cart text-3xl mb-2"></i>
<p>Votre panier est vide</p>
</div>
</div>
<div class="border-t mt-6 pt-6">
<div class="flex justify-between mb-2">
<span class="text-gray-600">Sous-total</span>
<span id="cart-subtotal" class="font-medium">0,00€</span>
</div>
<div class="flex justify-between mb-2">
<span class="text-gray-600">Livraison</span>
<span class="font-medium">Gratuite</span>
</div>
<div class="flex justify-between text-lg font-bold mt-4">
<span>Total</span>
<span id="cart-total">0,00€</span>
</div>
<div class="mt-6">
<button id="checkout-btn" class="w-full bg-indigo-600 text-white py-3 px-4 rounded-md hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed" disabled>
Passer la commande
</button>
<a href="#" class="block text-center mt-2 text-indigo-600 hover:text-indigo-800 text-sm">
Continuer mes achats
</a>
</div>
</div>
</div>
</div>
<div id="cart-overlay" class="hidden fixed inset-0 bg-black bg-opacity-50 z-40"></div>
<script>
// Gestion du menu mobile
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
mobileMenuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
// Gestion du panier
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 cartCount = document.getElementById('cart-count');
const cartItemsContainer = document.getElementById('cart-items');
const emptyCartMessage = document.getElementById('empty-cart-message');
const cartSubtotal = document.getElementById('cart-subtotal');
const cartTotal = document.getElementById('cart-total');
const checkoutBtn = document.getElementById('checkout-btn');
let cart = [];
// Ouvrir/fermer le panier
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 = 'auto';
});
cartOverlay.addEventListener('click', () => {
cartSidebar.classList.add('translate-x-full');
cartOverlay.classList.add('hidden');
document.body.style.overflow = 'auto';
});
// Ajouter au panier
document.querySelectorAll('.add-to-cart').forEach(button => {
button.addEventListener('click', (e) => {
const productId = e.target.getAttribute('data-id');
const productName = e.target.getAttribute('data-name');
const productPrice = parseFloat(e.target.getAttribute('data-price'));
// Animation du bouton
e.target.innerHTML = '<i class="fas fa-check mr-1"></i> Ajouté';
e.target.classList.add('bg-green-600');
e.target.classList.remove('bg-indigo-600');
setTimeout(() => {
e.target.innerHTML = 'Ajouter au panier';
e.target.classList.remove('bg-green-600');
e.target.classList.add('bg-indigo-600');
}, 2000);
// Ajouter au panier
addToCart(productId, productName, productPrice);
});
});
function addToCart(id, name, price) {
// Vérifier si le produit est déjà dans le panier
const existingItem = cart.find(item => item.id === id);
if (existingItem) {
existingItem.quantity += 1;
} else {
cart.push({
id,
name,
price,
quantity: 1
});
}
updateCart();
}
function updateCart() {
// Mettre à jour le compteur
const totalItems = cart.reduce((sum, item) => sum + item.quantity, 0);
cartCount.textContent = totalItems;
if (totalItems > 0) {
cartCount.classList.remove('hidden');
cartCount.classList.add('animate-pulse');
setTimeout(() => cartCount.classList.remove('animate-pulse'), 1000);
} else {
cartCount.classList.add('hidden');
}
// Mettre à jour le contenu du panier
if (cart.length === 0) {
emptyCartMessage.classList.remove('hidden');
cartItemsContainer.innerHTML = '';
cartItemsContainer.appendChild(emptyCartMessage);
checkoutBtn.disabled = true;
} else {
emptyCartMessage.classList.add('hidden');
let itemsHTML = '';
let subtotal = 0;
cart.forEach(item => {
const itemTotal = item.price * item.quantity;
subtotal += itemTotal;
itemsHTML += `
<div class="flex justify-between items-center border-b pb-4">
<div>
<h4 class="font-medium">${item.name}</h4>
<p class="text-sm text-gray-500">${item.price.toFixed(2)}€</p>
</div>
<div class="flex items-center">
<button class="decrease-quantity text-gray-500 px-2 py-1" data-id="${item.id}">
<i class="fas fa-minus text-xs"></i>
</button>
<span class="mx-2">${item.quantity}</span>
<button class="increase-quantity text-gray-500 px-2 py-1" data-id="${item.id}">
<i class="fas fa-plus text-xs"></i>
</button>
<button class="remove-item text-red-500 ml-4" data-id="${item.id}">
<i class="fas fa-trash"></i>
</button>
</div>
</div>
`;
});
cartItemsContainer.innerHTML = itemsHTML;
// Ajouter les événements aux nouveaux boutons
document.querySelectorAll('.decrease-quantity').forEach(button => {
button.addEventListener('click', (e) => {
const id = e.target.closest('button').getAttribute('data-id');
updateQuantity(id, -1);
});
});
document.querySelectorAll('.increase-quantity').forEach(button => {
button.addEventListener('click', (e) => {
const id = e.target.closest('button').getAttribute('data-id');
updateQuantity(id, 1);
});
});
document.querySelectorAll('.remove-item').forEach(button => {
button.addEventListener('click', (e) => {
const id = e.target.closest('button').getAttribute('data-id');
removeItem(id);
});
});
checkoutBtn.disabled = false;
}
// Mettre à jour les totaux
cartSubtotal.textContent = subtotal.toFixed(2) + '€';
cartTotal.textContent = subtotal.toFixed(2) + '€';
}
function updateQuantity(id, change) {
const item = cart.find(item => item.id === id);
if (item) {
item.quantity += change;
if (item.quantity <= 0) {
cart = cart.filter(item => item.id !== id);
}
updateCart();
}
}
function removeItem(id) {
cart = cart.filter(item => item.id !== id);
updateCart();
}
// Gestion du checkout
checkoutBtn.addEventListener('click', () => {
alert('Fonctionnalité de paiement à implémenter !');
});
</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=Pbuvard/test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |