<nav class="bg-white border-gray-200 dark:bg-gray-900 w-full">
<div class="max-w-7xl flex flex-wrap items-center justify-between mx-auto p-4">
<a href="/" class="flex items-center space-x-3 rtl:space-x-reverse no-underline">
<img src="/src/assets/my-logo.webp" class="h-8" alt="Logo" />
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">SnipGuide</span>
</a>
<button data-collapse-toggle="navbar-default" type="button" class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-default" aria-expanded="false">
<span class="sr-only">Open main menu</span>
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 1h15M1 7h15M1 13h15"/>
</svg>
</button>
<div class="hidden w-full md:block md:w-auto mt-4" id="navbar-default">
<ul class="font-bold flex flex-col p-4 md:p-0 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
<li class="list-none">
<a href="#" class="block py-2 px-3 text-white bg-blue-700 rounded md:bg-transparent md:text-purple-700 md:p-0 dark:text-white md:dark:text-blue-500 hover:bg-purple-500 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:dark:hover:text-purple-500 hover:text-white md:dark:hover:bg-transparent" aria-current="page">Home</a>
</li>
<li class="list-none">
<a href="#" class="block py-2 px-3 text-gray-900 rounded hover:bg-purple-500 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-purple-500 hover:text-white md:dark:hover:bg-transparent no-underline">About</a>
</li>
<li class="list-none">
<a href="#" class="block py-2 px-3 text-gray-900 rounded hover:bg-purple-500 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-purple-500 hover:text-white md:dark:hover:bg-transparent no-underline">Services</a>
</li>
<li class="list-none">
<a href="#" class="block py-2 px-3 text-gray-900 rounded hover:bg-purple-500 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-purple-500 hover:text-white md:dark:hover:bg-transparent no-underline">Pricing</a>
</li>
<li class="list-none">
<a href="#" class="block py-2 px-3 text-gray-900 rounded hover:bg-purple-500 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-purple-500 hover:text-white md:dark:hover:bg-transparent no-underline">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<script>
// Event listener for the toggle button to show/hide the navbar on small screens
document.querySelector('[data-collapse-toggle]').addEventListener('click', function() {
const target = document.getElementById(this.getAttribute('data-collapse-toggle'));
target.classList.toggle('hidden'); // Toggle the 'hidden' class to show/hide the navbar
});
// Select all links within the navbar
const links = document.querySelectorAll('#navbar-default a');
// Iterate over each link and add a click event listener
links.forEach(link => {
link.addEventListener('click', function() {
// Iterate over all links to remove active styles
links.forEach(l => {
l.classList.remove('bg-blue-700', 'text-white', 'md:text-purple-700', 'md:dark:text-blue-500'); // Remove active classes
l.classList.add('text-gray-900', 'no-underline'); // Add default classes to the previously active link
});
// Add active classes to the clicked link
this.classList.add('bg-blue-700', 'text-white', 'md:bg-transparent', 'md:text-purple-700', 'md:dark:text-blue-500');
// Remove default classes from the clicked link
this.classList.remove('text-gray-900', 'no-underline');
});
});
</script>