vibe coded v1

This commit is contained in:
khannurien
2026-03-16 07:34:49 +00:00
parent 6207a7549f
commit e88fed4e98
48 changed files with 4303 additions and 595 deletions

37
src/components/Avatar.tsx Normal file
View File

@@ -0,0 +1,37 @@
import { useState } from "react";
import { API_URL } from "../config/api.ts";
interface AvatarProps {
userId: string;
username: string;
hasAvatar: boolean;
size?: number;
}
export function Avatar({ userId, username, hasAvatar, size = 36 }: AvatarProps) {
const [imgFailed, setImgFailed] = useState(false);
const sizeStyle = { width: size, height: size };
if (hasAvatar && !imgFailed) {
return (
<img
src={`${API_URL}/api/avatars/${userId}`}
alt={username}
title={username}
style={sizeStyle}
className="avatar-img"
onError={() => setImgFailed(true)}
/>
);
}
return (
<div
className="avatar-initials"
title={username}
style={{ ...sizeStyle, fontSize: size * 0.45 }}
>
{username.charAt(0).toUpperCase()}
</div>
);
}