From f600ba5abb190f3adbb786214f0cf81bb3d7a968 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Wed, 1 Oct 2025 15:47:22 +0200 Subject: [PATCH] feat(web): add user display component with avatar and username --- web/src/components/user-display.tsx | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 web/src/components/user-display.tsx diff --git a/web/src/components/user-display.tsx b/web/src/components/user-display.tsx new file mode 100644 index 00000000..b9fc6f8b --- /dev/null +++ b/web/src/components/user-display.tsx @@ -0,0 +1,67 @@ +"use client" + +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" +import { Button } from "@/components/ui/button" +import { pb } from "@/lib/pb" + +interface UserDisplayProps { + userId?: string + displayName: string + onClick?: (userId: string, displayName: string) => void + size?: "sm" | "md" | "lg" + showAvatar?: boolean + avatar?: string +} + +const sizeClasses = { + sm: "h-6 w-6", + md: "h-8 w-8", + lg: "h-10 w-10" +} + +const textSizeClasses = { + sm: "text-xs", + md: "text-sm", + lg: "text-sm" +} + +export function UserDisplay({ + userId, + avatar, + displayName, + onClick, + size = "sm", + showAvatar = true +}: UserDisplayProps) { + // Avatar URL will attempt to load from PocketBase + // If it doesn't exist, the AvatarFallback will display instead + const avatarUrl = userId ? `${pb.baseURL}/api/files/_pb_users_auth_/${userId}/${avatar}?thumb=100x100` : undefined + + return ( +
+ {showAvatar && ( + + {avatarUrl && } + + {displayName.slice(0, 2).toUpperCase()} + + + )} + {onClick && userId ? ( + + ) : ( + {displayName} + )} +
+ ) +} +