bigbuffet-rw/app/soapbox/components/ui/avatar/avatar.tsx
marcin mikołajczak 785c6b57e3 RTL support, use Stack and HStack in more places
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-11-25 18:04:11 +01:00

36 lines
817 B
TypeScript

import classNames from 'clsx';
import React from 'react';
import StillImage from 'soapbox/components/still-image';
const AVATAR_SIZE = 42;
interface IAvatar {
/** URL to the avatar image. */
src: string,
/** Width and height of the avatar in pixels. */
size?: number,
/** Extra class names for the div surrounding the avatar image. */
className?: string,
}
/** Round profile avatar for accounts. */
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', className)}
style={style}
src={src}
alt='Avatar'
/>
);
};
export { Avatar as default, AVATAR_SIZE };