'use client';
import * as React from 'react';
import * as AvatarPrimitive from '@radix-ui/react-avatar';
import { cn } from '../../shared/utils';
/**
* User identity image with automatic fallback.
*
* @description
* Natively handles 404 errors and image loading timeouts by showing a
* text fallback (initials). Supports 5 sizes via the `size` prop.
*
* @ai-rules
* 1. NEVER use a raw `
` for user profile images — the internal fallback prevents broken UI.
* 2. Always compose as ` > + ` — both sub-components are required.
* 3. In ``, render initials (1–2 characters) using ``, not a full name.
*/
function Avatar({
className,
size = 'md',
...props
}: React.ComponentProps & {
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
}) {
const sizeClasses = {
xs: 'size-6',
sm: 'size-8',
md: 'size-10',
lg: 'size-12',
xl: 'size-16',
};
return (
);
}
function AvatarImage({ className, ...props }: React.ComponentProps) {
return (
);
}
function AvatarFallback({
className,
...props
}: React.ComponentProps) {
return (
);
}
export { Avatar, AvatarImage, AvatarFallback };