-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
33303d9
commit c715a44
Showing
4 changed files
with
176 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,90 @@ | ||
import React from "react"; | ||
import { | ||
Navbar, | ||
Collapse, | ||
Typography, | ||
IconButton, | ||
} from "@material-tailwind/react"; | ||
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline"; | ||
import { useRecoilValue } from 'recoil'; | ||
import { userloggedin } from '../atom/userAtom' | ||
|
||
|
||
function NavList() { | ||
const loggedUser = useRecoilValue(userloggedin); | ||
return ( | ||
loggedUser == 'anonymous-not-loggedin' ? ( | ||
< ul className="my-2 flex flex-col gap-2 lg:mb-0 lg:mt-0 lg:flex-row lg:items-center lg:gap-6" > | ||
<Typography | ||
as="li" | ||
variant="small" | ||
color="blue-gray" | ||
className="p-1 font-medium" | ||
> | ||
<a href="http://localhost:5173/register" className="flex items-center hover:text-blue-500 transition-colors"> | ||
Register | ||
</a> | ||
</Typography> | ||
<Typography | ||
as="li" | ||
variant="small" | ||
color="blue-gray" | ||
className="p-1 font-medium" | ||
> | ||
<a href="http://localhost:5173/login" className="flex items-center hover:text-blue-500 transition-colors"> | ||
Login | ||
</a> | ||
</Typography> | ||
|
||
</ul > | ||
) : (<div> User logged in as : {loggedUser}</div>) | ||
); | ||
} | ||
|
||
export function NavbarSimple() { | ||
const [openNav, setOpenNav] = React.useState(false); | ||
|
||
const handleWindowResize = () => | ||
window.innerWidth >= 960 && setOpenNav(false); | ||
|
||
React.useEffect(() => { | ||
window.addEventListener("resize", handleWindowResize); | ||
|
||
return () => { | ||
window.removeEventListener("resize", handleWindowResize); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<Navbar className="mx-auto max-w-screen-xl px-6 py-3"> | ||
<div className="flex items-center justify-between text-blue-gray-900"> | ||
<Typography | ||
as="a" | ||
href="#" | ||
variant="h6" | ||
className="mr-4 cursor-pointer py-1.5" | ||
> | ||
Chat Room | ||
</Typography> | ||
<div className="hidden lg:block"> | ||
<NavList /> | ||
</div> | ||
<IconButton | ||
variant="text" | ||
className="ml-auto h-6 w-6 text-inherit hover:bg-transparent focus:bg-transparent active:bg-transparent lg:hidden" | ||
ripple={false} | ||
onClick={() => setOpenNav(!openNav)} | ||
> | ||
{openNav ? ( | ||
<XMarkIcon className="h-6 w-6" strokeWidth={2} /> | ||
) : ( | ||
<Bars3Icon className="h-6 w-6" strokeWidth={2} /> | ||
)} | ||
</IconButton> | ||
</div> | ||
<Collapse open={openNav}> | ||
<NavList /> | ||
</Collapse> | ||
</Navbar> | ||
); | ||
} |