Fazbeeer commited on
Commit
b689b8f
·
verified ·
1 Parent(s): de4b7a5

add buy buttons and carts

Browse files
Files changed (1) hide show
  1. index.html +142 -10
index.html CHANGED
@@ -54,25 +54,147 @@
54
  <a href="#pricing" class="text-white hover:text-yellow-500 transition">Pricing</a>
55
  <a href="#about" class="text-white hover:text-yellow-500 transition">About</a>
56
  </div>
57
-
58
  <div class="flex items-center space-x-4">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <div class="relative group">
60
  <button class="flex items-center space-x-1 bg-black bg-opacity-50 px-3 py-2 rounded-lg border border-yellow-500">
61
  <i data-feather="globe" class="text-yellow-500"></i>
62
  <span class="text-white">EN</span>
63
  </button>
64
- <div class="absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 z-20 hidden group-hover:block">
65
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">English</a>
66
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Español</a>
67
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Français</a>
68
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Deutsch</a>
69
  </div>
70
  </div>
71
-
72
  <button class="bg-yellow-500 hover:bg-yellow-600 text-black font-bold px-4 py-2 rounded-lg transition flex items-center">
73
  <i data-feather="user" class="mr-2"></i> Login
74
  </button>
75
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  </div>
77
  </div>
78
  </nav>
@@ -267,10 +389,15 @@
267
  <span class="text-gray-500">Limited professional access</span>
268
  </li>
269
  </ul>
270
- <button class="w-full bg-yellow-500 hover:bg-yellow-600 text-black font-bold py-3 rounded-lg transition mb-2">
271
- Start Free Trial
 
 
 
 
 
272
  </button>
273
- <p class="text-xs text-center text-gray-400">No credit card required</p>
274
  </div>
275
  <!-- Elite Tier -->
276
  <div class="bg-gradient-to-b from-gray-900 to-black p-8 rounded-xl border border-red-500 transform hover:scale-105 transition md:col-span-1">
@@ -309,10 +436,15 @@
309
  <span>Personalized training plan</span>
310
  </li>
311
  </ul>
312
- <button class="w-full bg-red-500 hover:bg-red-600 text-white font-bold py-3 rounded-lg transition mb-2">
313
- Start Free Trial
 
 
 
 
 
314
  </button>
315
- <p class="text-xs text-center text-gray-400">No credit card required</p>
316
  </div>
317
  </div>
318
  </div>
 
54
  <a href="#pricing" class="text-white hover:text-yellow-500 transition">Pricing</a>
55
  <a href="#about" class="text-white hover:text-yellow-500 transition">About</a>
56
  </div>
 
57
  <div class="flex items-center space-x-4">
58
+ <div class="relative">
59
+ <button id="cart-button" class="flex items-center space-x-1 bg-black bg-opacity-50 px-3 py-2 rounded-lg border border-yellow-500 hover:bg-yellow-500 hover:text-black transition">
60
+ <i data-feather="shopping-cart" class="text-yellow-500 hover:text-black"></i>
61
+ <span id="cart-count" class="text-white">0</span>
62
+ </button>
63
+ <div id="cart-dropdown" class="hidden absolute right-0 mt-2 w-72 bg-black border border-yellow-500 rounded-lg shadow-lg py-2 z-20">
64
+ <div class="px-4 py-2 text-white border-b border-gray-700">Your Cart</div>
65
+ <div id="cart-items" class="max-h-60 overflow-y-auto">
66
+ <div class="px-4 py-3 text-gray-300 text-center">Your cart is empty</div>
67
+ </div>
68
+ <div class="px-4 py-2 border-t border-gray-700">
69
+ <button id="checkout-btn" class="w-full bg-yellow-500 hover:bg-yellow-600 text-black font-bold py-2 rounded transition disabled:opacity-50" disabled>
70
+ Checkout
71
+ </button>
72
+ </div>
73
+ </div>
74
+ </div>
75
  <div class="relative group">
76
  <button class="flex items-center space-x-1 bg-black bg-opacity-50 px-3 py-2 rounded-lg border border-yellow-500">
77
  <i data-feather="globe" class="text-yellow-500"></i>
78
  <span class="text-white">EN</span>
79
  </button>
80
+ <div class="absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 z-20 hidden group-hover:block">
81
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">English</a>
82
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Español</a>
83
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Français</a>
84
  <a href="#" class="block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black">Deutsch</a>
85
  </div>
86
  </div>
 
87
  <button class="bg-yellow-500 hover:bg-yellow-600 text-black font-bold px-4 py-2 rounded-lg transition flex items-center">
88
  <i data-feather="user" class="mr-2"></i> Login
89
  </button>
90
+ <script>
91
+ // Cart functionality
92
+ let cart = [];
93
+ const cartButton = document.getElementById('cart-button');
94
+ const cartDropdown = document.getElementById('cart-dropdown');
95
+ const cartCount = document.getElementById('cart-count');
96
+ const cartItems = document.getElementById('cart-items');
97
+ const checkoutBtn = document.getElementById('checkout-btn');
98
+
99
+ function updateCart() {
100
+ cartCount.textContent = cart.reduce((sum, item) => sum + item.quantity, 0);
101
+
102
+ if(cart.length === 0) {
103
+ cartItems.innerHTML = '<div class="px-4 py-3 text-gray-300 text-center">Your cart is empty</div>';
104
+ checkoutBtn.disabled = true;
105
+ } else {
106
+ cartItems.innerHTML = cart.map(item => `
107
+ <div class="px-4 py-3 border-b border-gray-700 flex justify-between items-center">
108
+ <div>
109
+ <div class="font-medium">${item.name}</div>
110
+ <div class="text-sm text-gray-400">${item.price}/mo</div>
111
+ </div>
112
+ <div class="flex items-center">
113
+ <button class="decrease-item text-gray-400 hover:text-yellow-500 p-1" data-id="${item.id}">
114
+ <i data-feather="minus" class="w-4 h-4"></i>
115
+ </button>
116
+ <span class="mx-2">${item.quantity}</span>
117
+ <button class="increase-item text-gray-400 hover:text-yellow-500 p-1" data-id="${item.id}">
118
+ <i data-feather="plus" class="w-4 h-4"></i>
119
+ </button>
120
+ <button class="remove-item text-gray-400 hover:text-red-500 ml-2 p-1" data-id="${item.id}">
121
+ <i data-feather="trash-2" class="w-4 h-4"></i>
122
+ </button>
123
+ </div>
124
+ </div>
125
+ `).join('');
126
+
127
+ // Calculate total
128
+ const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0);
129
+ cartItems.innerHTML += `
130
+ <div class="px-4 py-3 bg-gray-900 flex justify-between font-bold">
131
+ <span>Total:</span>
132
+ <span>${total.toFixed(2)}/mo</span>
133
+ </div>
134
+ `;
135
+
136
+ checkoutBtn.disabled = false;
137
+
138
+ // Re-render feather icons
139
+ feather.replace();
140
+
141
+ // Add event listeners to new buttons
142
+ document.querySelectorAll('.increase-item').forEach(btn => {
143
+ btn.addEventListener('click', (e) => {
144
+ const id = e.target.closest('button').dataset.id;
145
+ const item = cart.find(i => i.id === id);
146
+ if(item) {
147
+ item.quantity++;
148
+ updateCart();
149
+ }
150
+ });
151
+ });
152
+
153
+ document.querySelectorAll('.decrease-item').forEach(btn => {
154
+ btn.addEventListener('click', (e) => {
155
+ const id = e.target.closest('button').dataset.id;
156
+ const item = cart.find(i => i.id === id);
157
+ if(item && item.quantity > 1) {
158
+ item.quantity--;
159
+ updateCart();
160
+ }
161
+ });
162
+ });
163
+
164
+ document.querySelectorAll('.remove-item').forEach(btn => {
165
+ btn.addEventListener('click', (e) => {
166
+ const id = e.target.closest('button').dataset.id;
167
+ cart = cart.filter(i => i.id !== id);
168
+ updateCart();
169
+ });
170
+ });
171
+ }
172
+ }
173
+
174
+ cartButton.addEventListener('click', () => {
175
+ cartDropdown.classList.toggle('hidden');
176
+ });
177
+
178
+ // Close cart when clicking outside
179
+ document.addEventListener('click', (e) => {
180
+ if(!cartButton.contains(e.target) && !cartDropdown.contains(e.target)) {
181
+ cartDropdown.classList.add('hidden');
182
+ }
183
+ });
184
+
185
+ // Add to cart functionality
186
+ function addToCart(item) {
187
+ const existingItem = cart.find(i => i.id === item.id);
188
+ if(existingItem) {
189
+ existingItem.quantity++;
190
+ } else {
191
+ cart.push({...item, quantity: 1});
192
+ }
193
+ updateCart();
194
+ cartDropdown.classList.remove('hidden');
195
+ }
196
+ </script>
197
+ </div>
198
  </div>
199
  </div>
200
  </nav>
 
389
  <span class="text-gray-500">Limited professional access</span>
390
  </li>
391
  </ul>
392
+ <button onclick="addToCart({
393
+ id: 'basic-plan',
394
+ name: 'Basic Plan',
395
+ price: 19,
396
+ description: 'Unlimited VR/AR scenarios with advanced biometric tracking'
397
+ })" class="w-full bg-yellow-500 hover:bg-yellow-600 text-black font-bold py-3 rounded-lg transition mb-2 flex items-center justify-center">
398
+ <i data-feather="shopping-cart" class="mr-2"></i> Add to Cart
399
  </button>
400
+ <p class="text-xs text-center text-gray-400">No credit card required</p>
401
  </div>
402
  <!-- Elite Tier -->
403
  <div class="bg-gradient-to-b from-gray-900 to-black p-8 rounded-xl border border-red-500 transform hover:scale-105 transition md:col-span-1">
 
436
  <span>Personalized training plan</span>
437
  </li>
438
  </ul>
439
+ <button onclick="addToCart({
440
+ id: 'elite-plan',
441
+ name: 'Elite Plan',
442
+ price: 49,
443
+ description: 'Full suite with AI analysis, custom builds, and coaching'
444
+ })" class="w-full bg-red-500 hover:bg-red-600 text-white font-bold py-3 rounded-lg transition mb-2 flex items-center justify-center">
445
+ <i data-feather="shopping-cart" class="mr-2"></i> Add to Cart
446
  </button>
447
+ <p class="text-xs text-center text-gray-400">No credit card required</p>
448
  </div>
449
  </div>
450
  </div>