-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathUserProfilePhoto.tsx
More file actions
31 lines (29 loc) · 877 Bytes
/
UserProfilePhoto.tsx
File metadata and controls
31 lines (29 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { UserCircleIcon } from "@heroicons/react/24/solid";
import { useOptionalUser } from "~/hooks/useUser";
import { cn } from "~/utils/cn";
export function UserProfilePhoto({ className }: { className?: string }) {
const user = useOptionalUser();
return <UserAvatar avatarUrl={user?.avatarUrl} name={user?.name} className={className} />;
}
export function UserAvatar({
avatarUrl,
name,
className,
}: {
avatarUrl?: string | null;
name?: string | null;
className?: string;
}) {
return avatarUrl ? (
<div className={cn("grid aspect-square place-items-center", className)}>
<img
className={cn("aspect-square rounded-full p-[7%]")}
src={avatarUrl}
alt={name ?? "User"}
referrerPolicy="no-referrer"
/>
</div>
) : (
<UserCircleIcon className={cn("aspect-square text-charcoal-400", className)} />
);
}