Sjokode commited on
Commit
785c419
·
verified ·
1 Parent(s): 2bc24e3

add a way to choose categories and add keywords

Browse files
Files changed (1) hide show
  1. feed.html +173 -5
feed.html CHANGED
@@ -207,16 +207,20 @@
207
  </label>
208
 
209
  <!-- Location Picker -->
210
- <button class="p-2 text-gray-500 hover:text-orange-600 transition-colors duration-200">
211
  <i data-feather="map-pin" class="h-5 w-5"></i>
212
  </button>
213
 
214
  <!-- Category Selector -->
215
- <button class="p-2 text-gray-500 hover:text-orange-600 transition-colors duration-200">
216
  <i data-feather="tag" class="h-5 w-5"></i>
217
  </button>
218
- </div>
219
-
 
 
 
 
220
  <!-- Publish Button -->
221
  <button class="bg-orange-500 text-white px-4 py-2 rounded-full text-sm font-medium hover:bg-orange-600 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
222
  id="publish-button"
@@ -225,6 +229,89 @@
225
  Publier
226
  </button>
227
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
  <!-- Image Preview (hidden by default) -->
230
  <div class="mt-3 hidden" id="image-preview">
@@ -480,7 +567,88 @@
480
  // Initialize Feather Icons
481
  feather.replace();
482
 
483
- // Sidebar filter functionality
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  const sidebarFilterBtns = document.querySelectorAll('.sidebar-filter-btn');
485
  const categoryFilterBtns = document.querySelectorAll('.category-filter-btn');
486
  const cards = document.querySelectorAll('.promo-card, .news-card');
 
207
  </label>
208
 
209
  <!-- Location Picker -->
210
+ <button class="p-2 text-gray-500 hover:text-orange-600 transition-colors duration-200" id="location-button">
211
  <i data-feather="map-pin" class="h-5 w-5"></i>
212
  </button>
213
 
214
  <!-- Category Selector -->
215
+ <button class="p-2 text-gray-500 hover:text-orange-600 transition-colors duration-200" id="category-button">
216
  <i data-feather="tag" class="h-5 w-5"></i>
217
  </button>
218
+
219
+ <!-- Keywords Input -->
220
+ <button class="p-2 text-gray-500 hover:text-orange-600 transition-colors duration-200" id="keywords-button">
221
+ <i data-feather="hash" class="h-5 w-5"></i>
222
+ </button>
223
+ </div>
224
  <!-- Publish Button -->
225
  <button class="bg-orange-500 text-white px-4 py-2 rounded-full text-sm font-medium hover:bg-orange-600 transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
226
  id="publish-button"
 
229
  Publier
230
  </button>
231
  </div>
232
+
233
+ <!-- Category Selection Modal -->
234
+ <div id="category-modal" class="hidden absolute top-full right-0 mt-2 w-64 bg-white rounded-lg shadow-xl border border-gray-200 z-50 p-4">
235
+ <h4 class="font-semibold text-gray-900 mb-3">Choisir une catégorie</h4>
236
+ <div class="space-y-2 max-h-60 overflow-y-auto">
237
+ <label class="flex items-center">
238
+ <input type="checkbox" name="category" value="construction" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
239
+ <span class="text-sm">Construction</span>
240
+ </label>
241
+ <label class="flex items-center">
242
+ <input type="checkbox" name="category" value="beauty" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
243
+ <span class="text-sm">Beauté</span>
244
+ </label>
245
+ <label class="flex items-center">
246
+ <input type="checkbox" name="category" value="tech" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
247
+ <span class="text-sm">Tech</span>
248
+ </label>
249
+ <label class="flex items-center">
250
+ <input type="checkbox" name="category" value="gardening" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
251
+ <span class="text-sm">Jardinage</span>
252
+ </label>
253
+ <label class="flex items-center">
254
+ <input type="checkbox" name="category" value="wellness" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
255
+ <span class="text-sm">Wellness</span>
256
+ </label>
257
+ <label class="flex items-center">
258
+ <input type="checkbox" name="category" value="education" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
259
+ <span class="text-sm">Éducation</span>
260
+ </label>
261
+ <label class="flex items-center">
262
+ <input type="checkbox" name="category" value="food" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
263
+ <span class="text-sm">Nourriture</span>
264
+ </label>
265
+ <label class="flex items-center">
266
+ <input type="checkbox" name="category" value="art" class="mr-2 rounded text-orange-600 focus:ring-orange-500">
267
+ <span class="text-sm">Art</span>
268
+ </label>
269
+ </div>
270
+ <button class="mt-3 w-full bg-orange-600 text-white py-2 rounded-md text-sm font-medium hover:bg-orange-700">
271
+ Appliquer
272
+ </button>
273
+ </div>
274
+
275
+ <!-- Keywords Input Modal -->
276
+ <div id="keywords-modal" class="hidden absolute top-full right-0 mt-2 w-64 bg-white rounded-lg shadow-xl border border-gray-200 z-50 p-4">
277
+ <h4 class="font-semibold text-gray-900 mb-3">Ajouter des mots-clés</h4>
278
+ <input type="text" placeholder="Entrez des mots-clés..." class="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-orange-500 mb-3">
279
+ <div class="flex flex-wrap gap-2 mb-3" id="keywords-container">
280
+ <!-- Keywords will be added here -->
281
+ </div>
282
+ <button class="w-full bg-orange-600 text-white py-2 rounded-md text-sm font-medium hover:bg-orange-700">
283
+ Ajouter
284
+ </button>
285
+ </div>
286
+
287
+ <!-- Location Modal -->
288
+ <div id="location-modal" class="hidden absolute top-full right-0 mt-2 w-64 bg-white rounded-lg shadow-xl border border-gray-200 z-50 p-4">
289
+ <h4 class="font-semibold text-gray-900 mb-3">Sélectionner un lieu</h4>
290
+ <input type="text" placeholder="Rechercher un lieu..." class="w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-orange-500 mb-3">
291
+ <div class="space-y-2 max-h-60 overflow-y-auto">
292
+ <div class="flex items-center p-2 hover:bg-gray-50 rounded cursor-pointer">
293
+ <i data-feather="map-pin" class="h-4 w-4 mr-2 text-gray-500"></i>
294
+ <span class="text-sm">Barbade</span>
295
+ </div>
296
+ <div class="flex items-center p-2 hover:bg-gray-50 rounded cursor-pointer">
297
+ <i data-feather="map-pin" class="h-4 w-4 mr-2 text-gray-500"></i>
298
+ <span class="text-sm">Martinique</span>
299
+ </div>
300
+ <div class="flex items-center p-2 hover:bg-gray-50 rounded cursor-pointer">
301
+ <i data-feather="map-pin" class="h-4 w-4 mr-2 text-gray-500"></i>
302
+ <span class="text-sm">Guadeloupe</span>
303
+ </div>
304
+ <div class="flex items-center p-2 hover:bg-gray-50 rounded cursor-pointer">
305
+ <i data-feather="map-pin" class="h-4 w-4 mr-2 text-gray-500"></i>
306
+ <span class="text-sm">Jamaïque</span>
307
+ </div>
308
+ <div class="flex items-center p-2 hover:bg-gray-50 rounded cursor-pointer">
309
+ <i data-feather="map-pin" class="h-4 w-4 mr-2 text-gray-500"></i>
310
+ <span class="text-sm">Trinité-et-Tobago</span>
311
+ </div>
312
+ </div>
313
+ </div>
314
+ </div>
315
 
316
  <!-- Image Preview (hidden by default) -->
317
  <div class="mt-3 hidden" id="image-preview">
 
567
  // Initialize Feather Icons
568
  feather.replace();
569
 
570
+ // Category, Keywords and Location Modals functionality
571
+ const categoryButton = document.getElementById('category-button');
572
+ const keywordsButton = document.getElementById('keywords-button');
573
+ const locationButton = document.getElementById('location-button');
574
+ const categoryModal = document.getElementById('category-modal');
575
+ const keywordsModal = document.getElementById('keywords-modal');
576
+ const locationModal = document.getElementById('location-modal');
577
+
578
+ let activeModal = null;
579
+
580
+ function toggleModal(modal) {
581
+ if (activeModal === modal) {
582
+ modal.classList.add('hidden');
583
+ activeModal = null;
584
+ } else {
585
+ // Hide all modals first
586
+ categoryModal.classList.add('hidden');
587
+ keywordsModal.classList.add('hidden');
588
+ locationModal.classList.add('hidden');
589
+
590
+ // Show the selected modal
591
+ modal.classList.remove('hidden');
592
+ activeModal = modal;
593
+ }
594
+ }
595
+
596
+ categoryButton.addEventListener('click', (e) => {
597
+ e.stopPropagation();
598
+ toggleModal(categoryModal);
599
+ });
600
+
601
+ keywordsButton.addEventListener('click', (e) => {
602
+ e.stopPropagation();
603
+ toggleModal(keywordsModal);
604
+ });
605
+
606
+ locationButton.addEventListener('click', (e) => {
607
+ e.stopPropagation();
608
+ toggleModal(locationModal);
609
+ });
610
+
611
+ // Close modals when clicking outside
612
+ document.addEventListener('click', (e) => {
613
+ if (activeModal && !activeModal.contains(e.target) &&
614
+ !categoryButton.contains(e.target) &&
615
+ !keywordsButton.contains(e.target) &&
616
+ !locationButton.contains(e.target)) {
617
+ activeModal.classList.add('hidden');
618
+ activeModal = null;
619
+ }
620
+ });
621
+
622
+ // Keywords functionality
623
+ const keywordsInput = keywordsModal.querySelector('input');
624
+ const keywordsContainer = document.getElementById('keywords-container');
625
+
626
+ keywordsInput.addEventListener('keypress', (e) => {
627
+ if (e.key === 'Enter' && keywordsInput.value.trim()) {
628
+ addKeyword(keywordsInput.value.trim());
629
+ keywordsInput.value = '';
630
+ e.preventDefault();
631
+ }
632
+ });
633
+
634
+ function addKeyword(keyword) {
635
+ const keywordElement = document.createElement('div');
636
+ keywordElement.className = 'bg-orange-100 text-orange-700 px-2 py-1 rounded-full text-xs flex items-center';
637
+ keywordElement.innerHTML = `
638
+ ${keyword}
639
+ <button type="button" class="ml-1 text-orange-500 hover:text-orange-700" onclick="this.parentElement.remove()">
640
+ <i data-feather="x" class="h-3 w-3"></i>
641
+ </button>
642
+ `;
643
+ keywordsContainer.appendChild(keywordElement);
644
+ feather.replace();
645
+ }
646
+
647
+ // Prevent modals from closing when clicking inside them
648
+ categoryModal.addEventListener('click', (e) => e.stopPropagation());
649
+ keywordsModal.addEventListener('click', (e) => e.stopPropagation());
650
+ locationModal.addEventListener('click', (e) => e.stopPropagation());
651
+ // Sidebar filter functionality
652
  const sidebarFilterBtns = document.querySelectorAll('.sidebar-filter-btn');
653
  const categoryFilterBtns = document.querySelectorAll('.category-filter-btn');
654
  const cards = document.querySelectorAll('.promo-card, .news-card');