import { FC, ImgHTMLAttributes, useState } from "react";
import { getInitials } from "../utils";
interface Props extends ImgHTMLAttributes {
// className?: string;
// alt?: string;
// src?: string;
width: number;
height: number;
name?: string;
type?: "user" | "channel";
}
function getFontSize(width: number): number {
if (width <= 16) return 8;
if (width <= 24) return 12;
if (width <= 32) return 16;
if (width <= 40) return 18;
if (width <= 56) return 22;
if (width <= 80) return 48;
return 64;
}
const Avatar: FC = ({
src = "",
name = "Deleted User",
type = "user",
width,
height,
...rest
}) => {
const [error, setError] = useState(false);
const handleError = () => {
setError(true);
};
if (!error && src) {
return
;
}
return (
{getInitials(name)}
);
};
export default Avatar;