mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-03 08:07:17 +03:00
2a44f3a670
Usually when avatar or name changes
31 lines
496 B
JavaScript
31 lines
496 B
JavaScript
import './avatar.css';
|
|
|
|
const SIZES = {
|
|
s: 16,
|
|
m: 20,
|
|
l: 24,
|
|
xl: 32,
|
|
xxl: 50,
|
|
xxxl: 64,
|
|
};
|
|
|
|
function Avatar({ url, size, alt = '', ...props }) {
|
|
size = SIZES[size] || size || SIZES.m;
|
|
return (
|
|
<span
|
|
class="avatar"
|
|
style={{
|
|
width: size,
|
|
height: size,
|
|
}}
|
|
title={alt}
|
|
{...props}
|
|
>
|
|
{!!url && (
|
|
<img src={url} width={size} height={size} alt={alt} loading="lazy" />
|
|
)}
|
|
</span>
|
|
);
|
|
}
|
|
|
|
export default Avatar;
|