Akhileshrangani4 e9f03d52fd feat: user avatar images
- added user avatars for each user
- it will fetch user images from github or google and if there is no image then it will show initials
2024-11-10 23:40:10 -05:00

43 lines
907 B
TypeScript

import { cn } from "@/lib/utils"
import Image from "next/image"
export default function Avatar({
name,
avatarUrl,
className,
}: {
name: string
avatarUrl?: string | null
className?: string
}) {
// Generate initials from name if no avatarUrl is provided
const initials = name
? name
.split(" ")
.slice(0, 2)
.map((letter) => letter[0].toUpperCase())
.join("")
: "?"
return (
<div
className={cn(
className,
"w-9 h-9 font-mono rounded-full overflow-hidden bg-gradient-to-t from-neutral-800 to-neutral-600 flex items-center justify-center text-sm font-medium"
)}
>
{avatarUrl ? (
<Image
src={avatarUrl}
alt={name || "User"}
width={20}
height={20}
className="w-full h-full object-cover"
/>
) : (
initials
)}
</div>
)
}