phanpy/src/components/avatar.jsx

31 lines
469 B
React
Raw Normal View History

2022-12-10 09:14:48 +00:00
import './avatar.css';
const SIZES = {
s: 16,
m: 20,
l: 24,
xl: 32,
xxl: 50,
xxxl: 64,
2022-12-10 09:14:48 +00:00
};
2022-12-16 05:27:04 +00:00
function Avatar({ url, size, alt = '' }) {
2022-12-10 09:14:48 +00:00
size = SIZES[size] || size || SIZES.m;
return (
<span
class="avatar"
style={{
width: size,
height: size,
}}
title={alt}
2022-12-10 09:14:48 +00:00
>
{!!url && (
<img src={url} width={size} height={size} alt={alt} loading="lazy" />
)}
</span>
);
2022-12-16 05:27:04 +00:00
}
export default Avatar;