-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:LAION-AI/Open-Chat-GPT
- Loading branch information
Showing
25 changed files
with
392 additions
and
764 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,96 @@ | ||
import React from "react"; | ||
import { signOut, useSession } from "next-auth/react"; | ||
import Image from "next/image"; | ||
import { Popover } from "@headlessui/react"; | ||
import { AnimatePresence, motion } from "framer-motion"; | ||
import { FaCog, FaSignOutAlt, FaGithub } from "react-icons/fa"; | ||
|
||
export function Avatar() { | ||
const { data: session } = useSession(); | ||
|
||
if (!session) { | ||
return <></>; | ||
} | ||
if (session && session.user) { | ||
const email = session.user.email; | ||
const accountOptions = [ | ||
{ | ||
name: "Account Settings", | ||
href: "#", | ||
desc: "Account Settings", | ||
icon: FaCog, | ||
//For future use | ||
}, | ||
]; | ||
return ( | ||
<Popover className="relative"> | ||
{({ open }) => ( | ||
<> | ||
<Popover.Button aria-label="Toggle Account Options" className="flex"> | ||
<div className="flex items-center gap-4 p-1 lg:pr-6 rounded-full bg-white border border-slate-300/70 hover:bg-gray-200/50 transition-colors duration-300"> | ||
<Image | ||
src="/images/temp-avatars/av1.jpg" | ||
alt="Profile Picture" | ||
width="40" | ||
height="40" | ||
className="rounded-full" | ||
></Image> | ||
<p className="hidden lg:flex">{email}</p> | ||
{/* Will be changed to username once it is implemented */} | ||
</div> | ||
</Popover.Button> | ||
<AnimatePresence initial={false}> | ||
{open && ( | ||
<> | ||
<Popover.Panel | ||
static | ||
as={motion.div} | ||
initial={{ opacity: 0, y: -10 }} | ||
animate={{ opacity: 1, y: 0 }} | ||
exit={{ | ||
opacity: 0, | ||
y: -10, | ||
transition: { duration: 0.2 }, | ||
}} | ||
className="absolute right-0 mt-3 w-screen max-w-xs p-4 rounded-md bg-white border border-slate-300/70" | ||
> | ||
<div className="flex flex-col gap-1"> | ||
{accountOptions.map((item) => ( | ||
<a | ||
key={item.name} | ||
href={item.href} | ||
aria-label={item.desc} | ||
className="flex items-center rounded-md hover:bg-gray-200/50" | ||
> | ||
<div className="p-4"> | ||
<item.icon aria-hidden="true" /> | ||
</div> | ||
<div> | ||
<p>{item.name}</p> | ||
</div> | ||
</a> | ||
))} | ||
<a | ||
className="flex items-center rounded-md hover:bg-gray-100 cursor-pointer" | ||
onClick={() => signOut()} | ||
> | ||
<div className="p-4"> | ||
<FaSignOutAlt /> | ||
</div> | ||
<div> | ||
<p>Sign Out</p> | ||
</div> | ||
</a> | ||
</div> | ||
</Popover.Panel> | ||
</> | ||
)} | ||
</AnimatePresence> | ||
</> | ||
)} | ||
</Popover> | ||
); | ||
} | ||
} | ||
|
||
export default Avatar; |
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
Oops, something went wrong.