Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b6aa6e3
All the components are in Hamburg menu for desktop mode. It is not ex…
Akanksha6209127 Sep 27, 2025
126775f
I remove all the unusual comments.
Akanksha6209127 Sep 29, 2025
0f87583
Formattinh of code and remove all unusual comments.
Akanksha6209127 Sep 30, 2025
d18df43
The conflict arises due to formatting is resolved in Header file.
Akanksha6209127 Oct 2, 2025
2a82a3f
Merge conflict is resolution.
Akanksha6209127 Oct 2, 2025
3d84658
I try to resolve conflict
Akanksha6209127 Oct 2, 2025
ae1d318
...
Akanksha6209127 Oct 2, 2025
4d2ed6b
Merge branch 'new' of https://github.com/Akanksha6209127/InfantCareCo…
Akanksha6209127 Oct 2, 2025
cf32f36
..
Akanksha6209127 Oct 2, 2025
bf43b14
Merge branch 'master' into new
Akanksha6209127 Oct 2, 2025
f057b40
Try to resole merge conflict.
Akanksha6209127 Oct 2, 2025
2f25088
All the components are in Hamburg menu for desktop mode. It is not ex…
Akanksha6209127 Sep 27, 2025
f213983
I remove all the unusual comments.
Akanksha6209127 Sep 29, 2025
7310777
Formattinh of code and remove all unusual comments.
Akanksha6209127 Sep 30, 2025
03bb0d5
The conflict arises due to formatting is resolved in Header file.
Akanksha6209127 Oct 2, 2025
c499794
I try to resolve conflict
Akanksha6209127 Oct 2, 2025
7395e2e
...
Akanksha6209127 Oct 2, 2025
00a0f5d
Merge conflict is resolution.
Akanksha6209127 Oct 2, 2025
9733b58
..
Akanksha6209127 Oct 2, 2025
5be957a
Try to resole merge conflict.
Akanksha6209127 Oct 2, 2025
93a19cd
Merge branches 'new' and 'new' of https://github.com/Akanksha6209127/…
Akanksha6209127 Oct 4, 2025
b098116
Fix header layout and adjust spacing for Get Started button
Akanksha6209127 Oct 4, 2025
3134112
Resolved merge conflict in Header.jsx
Akanksha6209127 Oct 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 45 additions & 86 deletions client/src/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import React, { useState, useEffect } from "react";
import { NavLink, Link, useNavigate } from "react-router-dom";
import { useSelector, useDispatch } from "react-redux";
Expand All @@ -24,7 +25,7 @@ import ThemeToggle from "./ThemeToggle";
export default function Header() {
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const [isScrolled, setIsScrolled] = useState(false);
const { user, isAuthenticated } = useSelector(state => state.user);
const { user, isAuthenticated } = useSelector((state) => state.user);
const dispatch = useDispatch();
const navigate = useNavigate();

Expand All @@ -35,10 +36,10 @@ export default function Header() {
}, []);

const handleLogout = () => {
localStorage.removeItem('token');
localStorage.removeItem('userData');
localStorage.removeItem("token");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

if you want to do formatting fixes then please do it on whole project also better to create a editor rule file and add the rules there or add eslint config file. ESLint will do all formatting changes in one go.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thank you for the suggestion. I will configure ESLint rules for consistent formatting instead of fixing it file by file.

localStorage.removeItem("userData");
dispatch(logout());
navigate('/');
navigate("/");
};

useEffect(() => {
Expand All @@ -58,26 +59,10 @@ export default function Header() {
{ to: "/blog", label: "Blog", icon: <BookOpen className="w-4 h-4" /> },
{ to: "/contactus", label: "Contact", icon: <Mail className="w-4 h-4" /> },
{ to: "/news", label: "News", icon: <Newspaper className="w-4 h-4" /> },
{
to: "/consultation",
label: "Consultation",
icon: <Phone className="w-4 h-4" />,
},
{
to: "/care-co-pilot",
label: "Care Co-Pilot",
icon: <Heart className="w-4 h-4" />,
},
{
to: "/growth-tracker",
label: "Growth Tracker",
icon: <TrendingUp className="w-4 h-4" />,
},
{
to: "/contributors",
label: "Contributors",
icon: <Users className="w-4 h-4" />,
},
{ to: "/consultation", label: "Consultation", icon: <Phone className="w-4 h-4" /> },
{ to: "/care-co-pilot", label: "Care Co-Pilot", icon: <Heart className="w-4 h-4" /> },
{ to: "/growth-tracker", label: "Growth Tracker", icon: <TrendingUp className="w-4 h-4" /> },
{ to: "/contributors", label: "Contributors", icon: <Users className="w-4 h-4" /> },
];

return (
Expand All @@ -90,128 +75,106 @@ export default function Header() {
>
<div className="w-full px-4 py-2">
<div className="max-w-screen-xl mx-auto flex items-center justify-between">
{/* Logo */}
<Link to="/" className="flex items-center gap-3">
{/* Logo on left */}
<Link to="/" className="flex items-center gap-4">
<img
src={navlogo}
alt="Logo"
className="h-12 w-12 rounded-full shadow-lg"
className="h-16 w-16 rounded-full shadow-lg"
/>
<div className="leading-tight">
<h1 className="text-xl font-bold text-gray-900 dark:text-white">
<h1 className="text-2xl font-bold text-gray-900 dark:text-white">
InfantCare
</h1>
<p className="text-xs text-gray-600 dark:text-gray-400">
<p className="text-sm text-gray-600 dark:text-gray-400">
Compass
</p>
</div>
</Link>

{/* Desktop Nav */}
<div className="hidden lg:flex items-center gap-2">
{navItems.map(({ to, label, icon }) => (
<NavLink
key={to}
to={to}
className={({ isActive }) =>
`flex items-center gap-1.5 px-2.5 py-1.5 text-sm font-medium rounded-full transition-all duration-300 ${
isActive
? "bg-gradient-to-r from-purple-600 to-pink-500 text-white shadow"
: "text-gray-700 dark:text-gray-200 hover:bg-purple-100 dark:hover:bg-gray-800 hover:text-purple-600 dark:hover:text-purple-400"
}`
}
>
{icon}
{label}
</NavLink>
))}
</div>

{/* Theme Toggle */}
<div className="hidden lg:flex items-center">
{/* Right side - Theme + Auth + Hamburger */}
<div className="flex items-center gap-6">
{/* Theme Toggle */}
<ThemeToggle />
</div>

{/* Auth Buttons */}
<div className="hidden lg:flex items-center gap-2">
{/* Desktop Auth */}
{isAuthenticated && user ? (
<>
<div className="hidden md:flex items-center gap-3">
<div className="flex items-center gap-2 px-3 py-1.5 bg-purple-50 rounded-full">
<UserCircle className="w-4 h-4 text-purple-600" />
<UserCircle className="w-5 h-5 text-purple-600" />
<span className="text-sm font-medium text-purple-800">
{user.name} ({user.role === 'doctor' ? 'Doctor' : 'Patient'})
{user.name} ({user.role === "doctor" ? "Doctor" : "Patient"})
</span>
</div>
<button
onClick={handleLogout}
className="flex items-center gap-1 border border-red-500 text-red-500 hover:bg-red-500 hover:text-white px-4 py-1.5 text-sm font-medium rounded-full transition"
className="flex items-center gap-1 border border-red-500 text-red-500 hover:bg-red-500 hover:text-white px-3 py-1 text-sm font-medium rounded-full transition"
>
<LogOut className="w-4 h-4" />
<LogOut className="w-5 h-5" />
Logout
</button>
</>
</div>
) : (
<>
<div className="hidden md:flex items-center gap-4">
<Link
to="/signin"
className="border border-purple-600 text-purple-600 hover:bg-purple-600 hover:text-white px-4 py-1.5 text-sm font-medium rounded-full transition"
className="border border-purple-600 text-purple-600 hover:bg-purple-600 hover:text-white px-3 py-1.5 text-sm font-medium rounded-full transition"
>
Sign In
</Link>
<Link
to="/registration"
className="bg-gradient-to-r from-pink-500 to-purple-600 text-white px-5 py-1.5 text-sm font-semibold rounded-full shadow hover:scale-105 transition-transform"
className="bg-gradient-to-r from-pink-500 to-purple-600 text-white px-4 py-1.5 text-sm font-semibold rounded-full shadow hover:scale-105 transition-transform"
>
Get Started
</Link>
</>
</div>
)}
</div>

{/* Hamburger */}
<div className="lg:hidden">
{/* Hamburger icon */}
<button
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
aria-label="Toggle mobile menu"
aria-label="Toggle menu"
className="p-2 rounded-md bg-purple-100 dark:bg-gray-100 hover:bg-purple-200 dark:hover:bg-gray-200"
>
{isMobileMenuOpen ? (
<X className="w-6 h-6 " />
<X className="w-7 h-7 text-gray-900 dark:text-gray-800" />
) : (
<Menu className="w-6 h-6 " />
<Menu className="w-7 h-7 text-gray-900 dark:text-gray-800" />
)}
</button>
</div>
</div>
</div>
</div>

{/* Mobile Menu - OUTSIDE header container */}
{/* Overlay for Mobile Menu */}
{isMobileMenuOpen && (
<div
className="fixed inset-0 z-40 bg-black bg-opacity-50 lg:hidden"
className="fixed inset-0 z-40 bg-black bg-opacity-50"
onClick={() => setIsMobileMenuOpen(false)}
/>
)}

{/* Slide-in Menu (right side) */}
{isMobileMenuOpen && (
<motion.div
initial={{ x: "100%" }}
animate={{ x: "0%" }}
exit={{ x: "100%" }}
transition={{ duration: 0.3 }}
className="fixed inset-y-0 right-0 z-50 w-80 bg-white dark:bg-gray-900 shadow-xl lg:hidden"
className="fixed inset-y-0 right-0 z-50 w-80 bg-white dark:bg-gray-900 shadow-xl"
>
<div className="h-full flex flex-col">
<div className="p-4 border-b">
<div className="flex justify-between items-center">
<span className="font-bold text-white">Menu</span>
<button onClick={() => setIsMobileMenuOpen(false)}>
<X className="w-6 h-6 text-white" />
</button>
</div>
<div className="p-4 border-b flex justify-between items-center">
<span className="font-bold text-gray-900 dark:text-white">Menu</span>
<button onClick={() => setIsMobileMenuOpen(false)}>
<X className="w-7 h-7 text-gray-900 dark:text-white" />
</button>
</div>

{/* Nav links */}
<div className="flex-1 overflow-y-auto p-4">
{navItems.map(({ to, label, icon }) => (
<NavLink
Expand All @@ -224,20 +187,16 @@ export default function Header() {
{label}
</NavLink>
))}

{/* Theme Toggle in Mobile Menu */}
<div className="flex items-center justify-center p-3 mt-4">
<ThemeToggle />
</div>
</div>

<div className="p-4 border-t space-y-2">
{/* Auth buttons in menu (mobile only, removed SignIn/GetStarted from desktop) */}
<div className="p-4 border-t space-y-2 md:hidden">
{isAuthenticated && user ? (
<>
<div className="flex items-center gap-2 px-4 py-2 bg-purple-50 rounded-full mb-2">
<UserCircle className="w-4 h-4 text-purple-600" />
<span className="text-sm font-medium text-purple-800">
{user.name} ({user.role === 'doctor' ? 'Doctor' : 'Patient'})
{user.name} ({user.role === "doctor" ? "Doctor" : "Patient"})
</span>
</div>
<button
Expand Down
13 changes: 8 additions & 5 deletions client/src/components/ThemeToggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ const ThemeToggle = () => {
isDarkMode ? 'opacity-0' : 'opacity-100'
}`}
/>
<Moon
className={`absolute right-1.5 h-4 w-4 text-blue-400 transition-opacity duration-300 ${
isDarkMode ? 'opacity-100' : 'opacity-0'
}`}
/>

<div className="relative flex items-center justify-center h-10 w-10">
<Moon
className={`h-6 w-6 text-blue-400 transition-opacity duration-300 ${
isDarkMode ? 'opacity-100' : 'opacity-0'
}`}
/>
</div>
</button>
);
};
Expand Down