From 5e3b37288d96277a6eacb7d6464760b63f72874a Mon Sep 17 00:00:00 2001 From: Biswa Kalyan Bhuyan Date: Wed, 28 May 2025 19:44:26 +0530 Subject: feat: improved UI and added dynamic theme toggle - improved the nav bar components - added the theme toggle button to toggle theme - fixed the button background for the nav bar - fixed the theme color issue to the ThemeToggle funtion - added more vibrant colors - fixed the theme logo render --- frontend/src/components/header.tsx | 110 +++++++++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 29 deletions(-) (limited to 'frontend/src/components/header.tsx') diff --git a/frontend/src/components/header.tsx b/frontend/src/components/header.tsx index d64061a..851f637 100644 --- a/frontend/src/components/header.tsx +++ b/frontend/src/components/header.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import Link from "next/link"; import Image from "next/image"; import { Button } from "@/components/ui/button"; @@ -22,7 +22,7 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { ThemeToggle } from "@/components/theme-toggle"; import { Search, ShoppingBag, @@ -30,7 +30,6 @@ import { User, Menu, Phone, - Mail, Truck, RefreshCw, Shield, @@ -40,7 +39,7 @@ import { export function Header() { const [cartItems] = useState(3); const [wishlistItems] = useState(5); - + const categories = [ { title: "Women", @@ -73,6 +72,20 @@ export function Header() { }, ]; + // Preload both logo variants to ensure smooth loading + useEffect(() => { + const preloadLogos = () => { + if (typeof window !== 'undefined') { + const lightLogo = new window.Image(); + const darkLogo = new window.Image(); + lightLogo.src = '/black-logo.png'; + darkLogo.src = '/white-logo.png'; + } + }; + + preloadLogos(); + }, []); + return (
{/* Top banner */} @@ -83,20 +96,24 @@ export function Header() { {/* Announcement bar */} -
+

πŸ”₯ WINTER SALE - Up to 50% off on selected items

{/* Main header */} -
+
{/* Mobile menu */} - @@ -128,12 +145,22 @@ export function Header() { {/* Logo */}
+ {/* Light theme logo - visible by default, hidden in dark mode */} blcklst + {/* Dark theme logo - hidden by default, visible in dark mode */} + blcklst @@ -144,16 +171,18 @@ export function Header() { {categories.map((category) => ( - + {category.title} -
+
{category.items.map((item) => (
{item.name}
@@ -165,7 +194,7 @@ export function Header() { ))} - + Sale @@ -187,42 +216,57 @@ export function Header() { {/* Action buttons */}
{/* Search icon for mobile */} - + {/* Theme toggle */} + + {/* User menu */} - - - + + My Account - + Orders - + Wishlist - - + + Sign In - + Create Account {/* Wishlist */} - {/* Cart */} - - - πŸ‡ΊπŸ‡Έ USD - πŸ‡ͺπŸ‡Ί EUR - πŸ‡¬πŸ‡§ GBP + + πŸ‡ΊπŸ‡Έ USD + πŸ‡ͺπŸ‡Ί EUR + πŸ‡¬πŸ‡§ GBP
@@ -260,7 +312,7 @@ export function Header() {
{/* Service features */} -
+
-- cgit v1.2.3-59-g8ed1b