mirror of
https://github.com/shadcn-ui/taxonomy
synced 2026-05-24 09:48:32 +00:00
fix: user avatar fallback image
This commit is contained in:
parent
f4be613866
commit
0bace50fca
2 changed files with 10 additions and 7 deletions
|
|
@ -11,11 +11,14 @@ interface UserAvatarProps extends AvatarProps {
|
|||
export function UserAvatar({ user, ...props }: UserAvatarProps) {
|
||||
return (
|
||||
<Avatar {...props}>
|
||||
<Avatar.Image alt="Picture" src={user.image} />
|
||||
<Avatar.Fallback>
|
||||
<span className="sr-only">{user.name}</span>
|
||||
<Icons.user className="h-4 w-4" />
|
||||
</Avatar.Fallback>
|
||||
{user.image ? (
|
||||
<Avatar.Image alt="Picture" src={user.image} />
|
||||
) : (
|
||||
<Avatar.Fallback>
|
||||
<span className="sr-only">{user.name}</span>
|
||||
<Icons.user className="h-4 w-4" />
|
||||
</Avatar.Fallback>
|
||||
)}
|
||||
</Avatar>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import Image, { ImageProps } from "next/image"
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import Image, { ImageProps } from "next/image"
|
||||
|
||||
type AvatarProps = AvatarPrimitive.AvatarProps
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ Avatar.Image = function AvatarImage({
|
|||
return (
|
||||
<Image
|
||||
src={src}
|
||||
className={cn("", className)}
|
||||
className={cn("object-cover", className)}
|
||||
alt={alt}
|
||||
width={width}
|
||||
height={height}
|
||||
|
|
|
|||
Loading…
Reference in a new issue