- PlayerAvatar component with onError fallback to initial badge; used in PlayerManager and ChatBridge. - ChatBridge: truncate long usernames to 16 chars with tooltip, add avatar column, bump tinted text colors to -300 for better dark-mode contrast. - BackupManager: confirm step for Delete (was one-click). - ModManager: confirm step for snapshot Delete, clearer "Confirm Restore" / "Confirm Delete" labels, unify outer spacing with the rest of admin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
889 B
TypeScript
40 lines
889 B
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
export function PlayerAvatar({
|
|
name,
|
|
size = 24,
|
|
className = "",
|
|
}: {
|
|
name: string;
|
|
size?: number;
|
|
className?: string;
|
|
}) {
|
|
const [failed, setFailed] = useState(false);
|
|
const dim = `${size}px`;
|
|
const initial = name.slice(0, 1).toUpperCase();
|
|
|
|
if (failed || !name) {
|
|
return (
|
|
<div
|
|
className={`rounded bg-muted text-muted-foreground shrink-0 flex items-center justify-center font-bold ${className}`}
|
|
style={{ width: dim, height: dim, fontSize: size * 0.5 }}
|
|
aria-label={name}
|
|
>
|
|
{initial}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<img
|
|
src={`https://mc-heads.net/avatar/${encodeURIComponent(name)}/${size}`}
|
|
alt=""
|
|
width={size}
|
|
height={size}
|
|
onError={() => setFailed(true)}
|
|
className={`rounded shrink-0 bg-muted ${className}`}
|
|
/>
|
|
);
|
|
}
|