Scrum4Me/components/shared/user-avatar.tsx
Scrum4Me Agent f555cb547b refactor(PBI-49): migrate 17 shared/ components to debugProps helper
Replace hardcoded data-debug-id + data-debug-label attribute pairs with
{...debugProps(id, component, file)} spread in all 17 components/shared/
files. Existing debug-ids preserved unchanged.
2026-05-09 20:47:51 +02:00

36 lines
1 KiB
TypeScript

'use client'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { cn } from '@/lib/utils'
import { debugProps } from '@/lib/debug'
type AvatarSize = 'xs' | 'sm' | 'md' | 'lg'
const SIZE_CLASSES: Record<AvatarSize, string> = {
xs: 'size-6 text-[10px]',
sm: 'size-8 text-xs',
md: 'size-10 text-sm',
lg: 'size-12 text-base',
}
interface UserAvatarProps {
userId: string
username: string
size?: AvatarSize
className?: string
}
export function UserAvatar({ userId, username, size = 'md', className }: UserAvatarProps) {
const initials = username.slice(0, 2).toUpperCase()
return (
<span {...debugProps('user-avatar', 'UserAvatar', 'shared/user-avatar.tsx')}>
<Avatar className={cn(SIZE_CLASSES[size], className)}>
<AvatarImage src={`/api/users/${userId}/avatar`} alt={username} />
<AvatarFallback className="bg-primary-container text-primary-container-foreground font-medium">
{initials}
</AvatarFallback>
</Avatar>
</span>
)
}