soapbox/app/soapbox/components/ui/avatar/avatar.tsx

37 wiersze
838 B
TypeScript
Czysty Zwykły widok Historia

import classNames from 'clsx';
2022-03-21 18:09:01 +00:00
import * as React from 'react';
import StillImage from 'soapbox/components/still_image';
const AVATAR_SIZE = 42;
interface IAvatar {
/** URL to the avatar image. */
2022-03-21 18:09:01 +00:00
src: string,
/** Width and height of the avatar in pixels. */
2022-03-21 18:09:01 +00:00
size?: number,
/** Extra class names for the div surrounding the avatar image. */
2022-03-21 18:09:01 +00:00
className?: string,
}
/** Round profile avatar for accounts. */
2022-03-21 18:09:01 +00:00
const Avatar = (props: IAvatar) => {
const { src, size = AVATAR_SIZE, className } = props;
const style: React.CSSProperties = React.useMemo(() => ({
width: size,
height: size,
}), [size]);
return (
<StillImage
className={classNames('rounded-full overflow-hidden', className)}
2022-03-21 18:09:01 +00:00
style={style}
src={src}
alt='Avatar'
/>
);
};
export { Avatar as default, AVATAR_SIZE };