mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 10:19:50 -04:00
4a0bb36ca8
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
35 lines
904 B
TypeScript
35 lines
904 B
TypeScript
import { User } from 'icons'
|
|
import Image from 'next/image'
|
|
import { ReactNode, useState } from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
interface ProfileImageProps {
|
|
alt?: string
|
|
src?: string
|
|
placeholder?: ReactNode
|
|
className?: string
|
|
}
|
|
|
|
export const ProfileImage = ({ alt, src, placeholder, className }: ProfileImageProps) => {
|
|
const [hasInvalidImg, setHasInvalidImg] = useState(false)
|
|
|
|
return !!src && !hasInvalidImg ? (
|
|
<Image
|
|
alt={alt ?? ''}
|
|
src={src}
|
|
width="24"
|
|
height="24"
|
|
className={cn('aspect-square bg-foreground rounded-full object-cover', className)}
|
|
onError={() => setHasInvalidImg(true)}
|
|
/>
|
|
) : (
|
|
(placeholder ?? (
|
|
<figure
|
|
className={cn('bg-foreground rounded-full flex items-center justify-center', className)}
|
|
>
|
|
<User size={18} strokeWidth={1.5} className="text-background" />
|
|
</figure>
|
|
))
|
|
)
|
|
}
|