lightswind
Version:
A modern frontend library with pre-built Tailwind CSS components for building responsive and interactive user interfaces.
188 lines (178 loc) • 12.2 kB
JSX
import React, { useState } from 'react';
const Header = () => {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const toggleMenu = () => {
setIsMenuOpen(!isMenuOpen);
};
return (
<header className="bg-white dark:bg-gray-800 shadow-md w-full font-primarylw">
<div className="max-w-7xl mx-auto px-6 py-4 flex items-center justify-between">
{/* Logo Section */}
<div className="flex items-center space-x-2">
<img
src="https://lightswind.com/lighstwind-logo.png"
alt="Logo"
className="h-8 md:h-12"
/>
<h1 className="text-xl md:text-2xl font-bold text-gray-800 dark:text-white">LightShop</h1>
</div>
<div className="flex gap-10">
{/* Desktop Menu Section */}
<nav className="hidden md:flex space-x-6">
<a href="#" className="text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw">
Home
</a>
<a href="#products" className="text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw">
Products
</a>
<a href="#services" className="text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw">
Services
</a>
<a href="#about" className="text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw">
About
</a>
<a href="#contact" className="text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw">
Contact
</a>
</nav>
{/* Icons Section (Cart, Wishlist, User) */}
<div className="flex items-center space-x-6">
{/* Profile Icon */}
<button className="relative hidden md:flex">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className="w-6 h-6 text-gray-700 dark:text-gray-300"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
/>
</svg>
</button>
{/* User Icon */}
<button className="relative">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className="w-6 h-6 text-gray-700 dark:text-gray-300"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M15.75 10.5V6a3.75 3.75 0 1 0-7.5 0v4.5m11.356-1.993 1.263 12c.07.665-.45 1.243-1.119 1.243H4.25a1.125 1.125 0 0 1-1.12-1.243l1.264-12A1.125 1.125 0 0 1 5.513 7.5h12.974c.576 0 1.059.435 1.119 1.007ZM8.625 10.5a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm7.5 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"
/>
</svg>
</button>
{/* Hamburger Icon for Mobile */}
<button className="md:hidden flex items-center" onClick={toggleMenu}>
{!isMenuOpen ? (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className="w-6 h-6 text-gray-700 dark:text-gray-300"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M3.75 6.75h16.5M3.75 12h16.5M12 17.25h8.25"
/>
</svg>
) : (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
className="w-6 h-6 text-gray-700 dark:text-gray-300"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
)}
</button>
</div>
</div>
</div>
{/* Mobile Menu */}
<div
id="navbar-menu"
className={
"flex items-center justify-center flex-col md:hidden bg-white dark:bg-gray-800 shadow-md absolute inset-0 top-16 left-0 right-0 " + (isMenuOpen ? 'block' : 'hidden') + " transition-all duration-500 ease-in-out"
}
>
<div className="flex flex-col items-start space-y-12 py-6">
<a
href="#"
className="flex items-center gap-2 text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw min-w-[100px]"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
</svg>
Home
</a>
<a
href="#products"
className="flex items-center gap-2 text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z" />
</svg>
Products
</a>
<a
href="#services"
className="flex items-center gap-2 text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.559.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.894.149c-.424.07-.764.383-.929.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.398.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.272-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
Services
</a>
<a
href="#about"
className="flex items-center gap-2 text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
About
</a>
<a
href="#contact"
className="flex items-center gap-2 text-gray-700 dark:text-gray-300 font-semibold hover:text-primarylw dark:hover:text-primarylw"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.625 12a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H8.25m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H12m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0h-.375M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
Contact
</a>
</div>
</div>
</header>
);
};
export default Header;