ATProto forum built with ESAV
at main 1.9 kB view raw
1import { Link } from "@tanstack/react-router"; 2import Login from "./OAuthLogin"; 3import { SearchBox } from "./Search"; 4import { useCachedProfileJotai } from "@/esav/hooks"; 5import { useAuth } from "@/providers/OAuthProvider"; 6import { 7 DropdownMenu, 8 DropdownMenuTrigger, 9 DropdownMenuContent, 10 DropdownMenuLabel, 11 DropdownMenuSeparator, 12 DropdownMenuItem, 13} from "@radix-ui/react-dropdown-menu"; 14 15export default function Header() { 16 const { agent, status } = useAuth(); 17 const did = agent && agent.did && status === "signedIn" ? agent.did : null; 18 const [profile, profileloading] = useCachedProfileJotai(did); 19 20 const avatarUrl = 21 profile?.profile.avatar?.ref.$link && profile?.pdsUrl 22 ? `${profile.pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${profile.did}&cid=${profile?.profile.avatar?.ref.$link}` 23 : undefined; 24 25 return ( 26 <div className=" flex flex-row h-10 items-center px-2 sticky top-0 bg-gray-700 z-50"> 27 <Link to="/"> 28 <span className=" text-gray-50 font-bold">ForumTest</span> 29 </Link> 30 {/* <div className="spacer flex-1" /> */} 31 <SearchBox /> 32 33 {profile && !profileloading ? ( 34 <> 35 <DropdownMenu> 36 <DropdownMenuTrigger asChild> 37 <img 38 style={{ height: 28, width: 28, borderRadius: 9999 }} 39 src={avatarUrl} 40 alt={`Avatar for @${profile?.handle}`} 41 /> 42 </DropdownMenuTrigger> 43 <DropdownMenuContent className="w-48 mt-2 bg-gray-800 p-4 rounded-md" align="end"> 44 <DropdownMenuLabel className="font-semibold text-gray-50"> 45 @{profile.handle} 46 </DropdownMenuLabel> 47 <DropdownMenuSeparator /> 48 <Login compact /> 49 </DropdownMenuContent> 50 </DropdownMenu> 51 </> 52 ) : ( 53 <Login compact /> 54 )} 55 </div> 56 ); 57}