返回 AiToEarn
avatar.tsx
根目录 / project / aitoearn-web / src / components / ui / avatar.tsx
1 'use client'
2
3 import * as AvatarPrimitive from '@radix-ui/react-avatar'
4 import * as React from 'react'
5
6 import { cn } from '@/utils/className'
7
8 const Avatar = React.forwardRef<
9 React.ElementRef<typeof AvatarPrimitive.Root>,
10 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
11 >(({ className, ...props }, ref) => (
12 <AvatarPrimitive.Root
13 ref={ref}
14 className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
15 {...props}
16 />
17 ))
18 Avatar.displayName = AvatarPrimitive.Root.displayName
19
20 const AvatarImage = React.forwardRef<
21 React.ElementRef<typeof AvatarPrimitive.Image>,
22 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
23 >(({ className, ...props }, ref) => (
24 <AvatarPrimitive.Image
25 ref={ref}
26 className={cn('aspect-square h-full w-full', className)}
27 {...props}
28 />
29 ))
30 AvatarImage.displayName = AvatarPrimitive.Image.displayName
31
32 const AvatarFallback = React.forwardRef<
33 React.ElementRef<typeof AvatarPrimitive.Fallback>,
34 React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
35 >(({ className, ...props }, ref) => (
36 <AvatarPrimitive.Fallback
37 ref={ref}
38 className={cn(
39 'flex h-full w-full items-center justify-center rounded-full bg-muted',
40 className,
41 )}
42 {...props}
43 />
44 ))
45 AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
46
47 export { Avatar, AvatarFallback, AvatarImage }
48
48 lines Plain Text