-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tester
committed
Oct 7, 2024
1 parent
8556c52
commit ba5515f
Showing
3 changed files
with
97 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Outlet, useNavigate } from 'react-router-dom'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { Link } from 'react-router-dom'; | ||
const Navbar = () => { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
useEffect(() => { | ||
console.log("here"); | ||
if (location.pathname === '/') navigate("/homepage"); | ||
}, [location]); | ||
return ( | ||
<div> | ||
<nav className="flex bg-gray-800 p-4"> | ||
<div className="container mx-auto flex justify-between items-center"> | ||
<div className="text-white text-xl font-bold"> | ||
<Link to="/">MyApp</Link> | ||
</div> | ||
<div className="hidden md:flex space-x-4"> | ||
<Link to="/homepage" className="text-gray-300 hover:text-white m-3"> | ||
Home | ||
</Link> | ||
<Link to="/login" className="text-gray-300 hover:text-white"> | ||
Login | ||
</Link> | ||
<Link to="/posts" className="text-gray-300 hover:text-white"> | ||
post | ||
</Link> | ||
<Link to="/room" className="text-gray-300 hover:text-white"> | ||
room | ||
</Link> | ||
</div> | ||
<div className="md:hidden"> | ||
<button className="text-gray-300 hover:text-white focus:outline-none"> | ||
{/* Icon for mobile menu (e.g. hamburger icon) */} | ||
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> | ||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 6h16M4 12h16m-7 6h7" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</div> | ||
</nav> | ||
<Outlet></Outlet> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Navbar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react" | ||
export default function Loader(){ | ||
return( | ||
<div | ||
className="w-12 h-12 rounded-full animate-spin border-y-8 border-solid border-green-500 border-t-transparent shadow-md" | ||
> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters