Fazbeeer commited on
Commit
bd867c6
·
verified ·
1 Parent(s): 1a475cf

make this function the same way as the cart

Browse files
Files changed (1) hide show
  1. index.html +22 -14
index.html CHANGED
@@ -84,25 +84,19 @@
84
  <span id="cart-count" class="text-white">0</span>
85
  </button>
86
  </div>
87
- <div class="relative group z-50">
88
- <button class="flex items-center space-x-1 bg-yellow-500 hover:bg-yellow-600 text-black px-4 py-2 rounded-lg transition">
89
- <i data-feather="globe" class="mr-1"></i>
90
  <span id="current-language">EN</span>
91
- <i data-feather="chevron-down" class="ml-1"></i>
92
  </button>
93
- <div class="absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 hidden group-hover:block" style="z-index: 1000;">
94
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="en">English</a>
95
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="es">Español</a>
96
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="fr">Français</a>
97
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="de">Deutsch</a>
98
  </div>
99
- <div class="absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 hidden group-hover:block" style="z-index: 1000;">
100
- <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="en">English</a>
101
- <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="es">Español</a>
102
- <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="fr">Français</a>
103
- <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="de">Deutsch</a>
104
- </div>
105
- </div>
106
  <a href="login.html" class="bg-yellow-500 hover:bg-yellow-600 text-black font-bold px-4 py-2 rounded-lg transition flex items-center">
107
  <i data-feather="user" class="mr-2"></i> Login
108
  </a>
@@ -646,8 +640,15 @@ Get Started
646
  // Initial translations loaded
647
  updateContent();
648
  });
649
-
650
  // Language switcher
 
 
 
 
 
 
 
 
651
  document.querySelectorAll('.language-switch').forEach(link => {
652
  link.addEventListener('click', (e) => {
653
  e.preventDefault();
@@ -655,11 +656,18 @@ Get Started
655
  i18next.changeLanguage(lang, () => {
656
  document.getElementById('current-language').textContent = lang.toUpperCase();
657
  updateContent();
 
658
  });
659
  });
660
  });
661
 
662
- // Update page content
 
 
 
 
 
 
663
  function updateContent() {
664
  // Translate all elements with data-i18n attribute
665
  document.querySelectorAll('[data-i18n]').forEach(el => {
 
84
  <span id="cart-count" class="text-white">0</span>
85
  </button>
86
  </div>
87
+ <div class="relative">
88
+ <button id="language-button" class="flex items-center space-x-1 bg-yellow-500 hover:bg-yellow-600 text-black px-4 py-2 rounded-lg transition">
89
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-globe mr-1"><circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path></svg>
90
  <span id="current-language">EN</span>
91
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down ml-1"><polyline points="6 9 12 15 18 9"></polyline></svg>
92
  </button>
93
+ <div id="language-dropdown" class="hidden absolute right-0 mt-2 w-48 bg-black border border-yellow-500 rounded-lg shadow-lg py-1 z-50">
94
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="en">English</a>
95
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="es">Español</a>
96
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="fr">Français</a>
97
  <a href="#" class="language-switch block px-4 py-2 text-white hover:bg-yellow-500 hover:text-black" data-lang="de">Deutsch</a>
98
  </div>
99
+ </div>
 
 
 
 
 
 
100
  <a href="login.html" class="bg-yellow-500 hover:bg-yellow-600 text-black font-bold px-4 py-2 rounded-lg transition flex items-center">
101
  <i data-feather="user" class="mr-2"></i> Login
102
  </a>
 
640
  // Initial translations loaded
641
  updateContent();
642
  });
 
643
  // Language switcher
644
+ const languageButton = document.getElementById('language-button');
645
+ const languageDropdown = document.getElementById('language-dropdown');
646
+
647
+ languageButton.addEventListener('click', (e) => {
648
+ e.stopPropagation();
649
+ languageDropdown.classList.toggle('hidden');
650
+ });
651
+
652
  document.querySelectorAll('.language-switch').forEach(link => {
653
  link.addEventListener('click', (e) => {
654
  e.preventDefault();
 
656
  i18next.changeLanguage(lang, () => {
657
  document.getElementById('current-language').textContent = lang.toUpperCase();
658
  updateContent();
659
+ languageDropdown.classList.add('hidden');
660
  });
661
  });
662
  });
663
 
664
+ // Close dropdown when clicking outside
665
+ document.addEventListener('click', (e) => {
666
+ if (!languageButton.contains(e.target) && !languageDropdown.contains(e.target)) {
667
+ languageDropdown.classList.add('hidden');
668
+ }
669
+ });
670
+ // Update page content
671
  function updateContent() {
672
  // Translate all elements with data-i18n attribute
673
  document.querySelectorAll('[data-i18n]').forEach(el => {