|
1 |
| -import * as React from "react" |
2 |
| -import * as AvatarPrimitive from "@radix-ui/react-avatar" |
| 1 | +import { cn } from '@/lib/utils'; |
| 2 | +import * as AvatarPrimitive from '@radix-ui/react-avatar'; |
3 | 3 |
|
4 |
| -import { cn } from "@/lib/utils" |
| 4 | +import * as React from 'react'; |
5 | 5 |
|
6 |
| -const Avatar = React.forwardRef< |
7 |
| - React.ElementRef<typeof AvatarPrimitive.Root>, |
8 |
| - React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> |
9 |
| ->(({ className, ...props }, ref) => ( |
10 |
| - <AvatarPrimitive.Root |
11 |
| - ref={ref} |
12 |
| - className={cn( |
13 |
| - "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", |
14 |
| - className |
15 |
| - )} |
16 |
| - {...props} |
17 |
| - /> |
18 |
| -)) |
19 |
| -Avatar.displayName = AvatarPrimitive.Root.displayName |
| 6 | +function Avatar({ ref, className, ...props }: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> & { ref?: React.RefObject<React.ElementRef<typeof AvatarPrimitive.Root>> }) { |
| 7 | + return ( |
| 8 | + <AvatarPrimitive.Root |
| 9 | + className={cn( |
| 10 | + 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', |
| 11 | + className, |
| 12 | + )} |
| 13 | + ref={ref} |
| 14 | + {...props} |
| 15 | + /> |
| 16 | + ); |
| 17 | +} |
| 18 | +Avatar.displayName = AvatarPrimitive.Root.displayName; |
20 | 19 |
|
21 |
| -const AvatarImage = React.forwardRef< |
22 |
| - React.ElementRef<typeof AvatarPrimitive.Image>, |
23 |
| - React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> |
24 |
| ->(({ className, ...props }, ref) => ( |
25 |
| - <AvatarPrimitive.Image |
26 |
| - ref={ref} |
27 |
| - className={cn("aspect-square h-full w-full", className)} |
28 |
| - {...props} |
29 |
| - /> |
30 |
| -)) |
31 |
| -AvatarImage.displayName = AvatarPrimitive.Image.displayName |
| 20 | +function AvatarImage({ ref, className, ...props }: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> & { ref?: React.RefObject<React.ElementRef<typeof AvatarPrimitive.Image>> }) { |
| 21 | + return ( |
| 22 | + <AvatarPrimitive.Image |
| 23 | + className={cn('aspect-square h-full w-full', className)} |
| 24 | + ref={ref} |
| 25 | + {...props} |
| 26 | + /> |
| 27 | + ); |
| 28 | +} |
| 29 | +AvatarImage.displayName = AvatarPrimitive.Image.displayName; |
32 | 30 |
|
33 |
| -const AvatarFallback = React.forwardRef< |
34 |
| - React.ElementRef<typeof AvatarPrimitive.Fallback>, |
35 |
| - React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> |
36 |
| ->(({ className, ...props }, ref) => ( |
37 |
| - <AvatarPrimitive.Fallback |
38 |
| - ref={ref} |
39 |
| - className={cn( |
40 |
| - "flex h-full w-full items-center justify-center rounded-full bg-muted", |
41 |
| - className |
42 |
| - )} |
43 |
| - {...props} |
44 |
| - /> |
45 |
| -)) |
46 |
| -AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName |
| 31 | +function AvatarFallback({ ref, className, ...props }: React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> & { ref?: React.RefObject<React.ElementRef<typeof AvatarPrimitive.Fallback>> }) { |
| 32 | + return ( |
| 33 | + <AvatarPrimitive.Fallback |
| 34 | + className={cn( |
| 35 | + 'flex h-full w-full items-center justify-center rounded-full bg-muted', |
| 36 | + className, |
| 37 | + )} |
| 38 | + ref={ref} |
| 39 | + {...props} |
| 40 | + /> |
| 41 | + ); |
| 42 | +} |
| 43 | +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; |
47 | 44 |
|
48 |
| -export { Avatar, AvatarImage, AvatarFallback } |
| 45 | +export { Avatar, AvatarFallback, AvatarImage }; |
0 commit comments