avatar-display.tsx 666 B

1234567891011121314151617181920212223242526272829
  1. 'use client';
  2. import { cn } from '@/lib/utils';
  3. interface AvatarDisplayProps {
  4. readonly src: string;
  5. readonly alt?: string;
  6. readonly className?: string;
  7. }
  8. export function AvatarDisplay({ src, alt, className }: AvatarDisplayProps) {
  9. const isUrl = src.startsWith('http') || src.startsWith('data:') || src.startsWith('/');
  10. if (isUrl) {
  11. return (
  12. <img src={src} alt={alt || ''} className={cn('w-full h-full object-cover', className)} />
  13. );
  14. }
  15. return (
  16. <span
  17. role="img"
  18. aria-label={alt || ''}
  19. className={cn('flex items-center justify-center w-full h-full select-none', className)}
  20. >
  21. {src}
  22. </span>
  23. );
  24. }