Skip to content

Commit

Permalink
Added light mode for navbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
angeldevildev committed Sep 17, 2024
1 parent 2279fb3 commit 9922bde
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions app/Components/Sections/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export default function Navbar() {
]

return (
<nav className="bg-white dark:bg-gray-800 shadow-sm rounded-xl transition-colors duration-200">
<nav className={`${theme === 'light' ? 'bg-white text-gray-800' : 'bg-gray-800 text-white'} shadow-sm rounded-xl transition-colors duration-200`}>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex items-center justify-between h-16">
<div className="flex items-center">
<Link href="/" className="flex-shrink-0" prefetch={false}>
<svg className="h-8 w-8 text-blue-600 dark:text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<svg className={`h-8 w-8 ${theme === 'light' ? 'text-blue-600' : 'text-blue-400'}`} fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</Link>
Expand All @@ -50,7 +50,7 @@ export default function Navbar() {
<Link
key={item.name}
href={item.href}
className="text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 px-3 py-2 rounded-md text-sm font-medium transition-colors no-underline"
className={`${theme === 'light' ? 'text-gray-600 hover:text-blue-600' : 'text-gray-300 hover:text-blue-400'} px-3 py-2 rounded-md text-sm font-medium transition-colors no-underline`}
prefetch={false}
>
{item.name}
Expand All @@ -64,19 +64,19 @@ export default function Navbar() {
<input
type="search"
placeholder="Search..."
className={`px-3 py-2 pr-10 rounded-md text-sm bg-gray-100 dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300 ease-in-out ${isSearchOpen ? 'w-64 opacity-100' : 'w-0 opacity-0'}`}
className={`px-3 py-2 pr-10 rounded-md text-sm ${theme === 'light' ? 'bg-gray-100 text-gray-800' : 'bg-gray-700 text-white'} focus:outline-none focus:ring-2 focus:ring-blue-500 transition-all duration-300 ease-in-out ${isSearchOpen ? 'w-64 opacity-100' : 'w-0 opacity-0'}`}
/>
<button
onClick={toggleSearch}
className="p-2 rounded-md text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500 absolute right-0"
className={`p-2 rounded-md ${theme === 'light' ? 'text-gray-600 hover:text-blue-600' : 'text-gray-300 hover:text-blue-400'} focus:outline-none focus:ring-2 focus:ring-blue-500 absolute right-0`}
aria-label="Search"
>
<Search className="h-5 w-5" />
</button>
</div>
<button
onClick={toggleTheme}
className="p-2 rounded-md text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
className={`p-2 rounded-md ${theme === 'light' ? 'text-gray-600 hover:text-blue-600' : 'text-gray-300 hover:text-blue-400'} focus:outline-none focus:ring-2 focus:ring-blue-500`}
aria-label={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
>
{theme === 'light' ? <Moon className="h-5 w-5" /> : <Sun className="h-5 w-5" />}
Expand All @@ -85,7 +85,7 @@ export default function Navbar() {
<div className="md:hidden">
<button
onClick={toggleMobileMenu}
className="p-2 rounded-md text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
className={`p-2 rounded-md ${theme === 'light' ? 'text-gray-600 hover:text-blue-600' : 'text-gray-300 hover:text-blue-400'} focus:outline-none focus:ring-2 focus:ring-blue-500`}
aria-label="Open menu"
>
<Menu className="h-5 w-5" />
Expand All @@ -97,18 +97,18 @@ export default function Navbar() {
{/* Mobile menu */}
<div
ref={mobileMenuRef}
className={`fixed inset-y-0 right-0 w-64 bg-white dark:bg-gray-800 shadow-lg transform transition-transform duration-300 ease-in-out ${isMobileMenuOpen ? 'translate-x-0' : 'translate-x-full'} z-50`}
className={`fixed inset-y-0 right-0 w-64 ${theme === 'light' ? 'bg-white text-gray-800' : 'bg-gray-800 text-white'} shadow-lg transform transition-transform duration-300 ease-in-out ${isMobileMenuOpen ? 'translate-x-0' : 'translate-x-full'} z-50`}
>
<div className="p-6">
<div className="flex items-center justify-between mb-8">
<Link href="/" className="flex-shrink-0" prefetch={false}>
<svg className="h-8 w-8 text-blue-600 dark:text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<svg className={`h-8 w-8 ${theme === 'light' ? 'text-blue-600' : 'text-blue-400'}`} fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</Link>
<button
onClick={toggleMobileMenu}
className="p-2 rounded-md text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500"
className={`p-2 rounded-md ${theme === 'light' ? 'text-gray-600 hover:text-blue-600' : 'text-gray-300 hover:text-blue-400'} focus:outline-none focus:ring-2 focus:ring-blue-500`}
aria-label="Close menu"
>
<X className="h-5 w-5" />
Expand All @@ -119,7 +119,7 @@ export default function Navbar() {
<Link
key={item.name}
href={item.href}
className="block px-3 py-2 rounded-md text-base font-medium text-gray-700 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors no-underline"
className={`block px-3 py-2 rounded-md text-base font-medium ${theme === 'light' ? 'text-gray-700 hover:text-blue-600 hover:bg-gray-50' : 'text-gray-300 hover:text-blue-400 hover:bg-gray-700'} transition-colors no-underline`}
prefetch={false}
>
{item.name}
Expand All @@ -131,13 +131,13 @@ export default function Navbar() {
<input
type="search"
placeholder="Search..."
className="w-full px-3 py-2 rounded-md text-sm bg-gray-100 dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500"
className={`w-full px-3 py-2 rounded-md text-sm ${theme === 'light' ? 'bg-gray-100 text-gray-800' : 'bg-gray-700 text-white'} focus:outline-none focus:ring-2 focus:ring-blue-500`}
/>
<Search className="absolute right-3 top-2.5 h-4 w-4 text-gray-400 dark:text-gray-500" />
<Search className={`absolute right-3 top-2.5 h-4 w-4 ${theme === 'light' ? 'text-gray-400' : 'text-gray-500'}`} />
</div>
<button
onClick={toggleTheme}
className="w-full p-2 rounded-md text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 focus:outline-none focus:ring-2 focus:ring-blue-500 flex items-center justify-center"
className={`w-full p-2 rounded-md ${theme === 'light' ? 'text-gray-600 hover:text-blue-600' : 'text-gray-300 hover:text-blue-400'} focus:outline-none focus:ring-2 focus:ring-blue-500 flex items-center justify-center`}
aria-label={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
>
{theme === 'light' ? <Moon className="h-5 w-5 mr-2" /> : <Sun className="h-5 w-5 mr-2" />}
Expand All @@ -148,4 +148,4 @@ export default function Navbar() {
</div>
</nav>
)
}
}

0 comments on commit 9922bde

Please sign in to comment.