返回 JoyAI-Echo
avatar.tsx
1 import * as React from "react";
2 import * as AvatarPrimitive from "@radix-ui/react-avatar";
3
4 import { cn } from "@/lib/utils";
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-9 w-9 shrink-0 overflow-hidden rounded-full",
14 className,
15 )}
16 {...props}
17 />
18 ));
19 Avatar.displayName = AvatarPrimitive.Root.displayName;
20
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;
32
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 text-xs font-medium",
41 className,
42 )}
43 {...props}
44 />
45 ));
46 AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
47
48 export { Avatar, AvatarFallback, AvatarImage };
49
49 lines Plain Text