bigbuffet-rw/app/soapbox/components/avatar.js

40 lines
945 B
JavaScript
Raw Normal View History

import classNames from 'classnames';
2020-03-27 13:59:38 -07:00
import PropTypes from 'prop-types';
import React from 'react';
2020-03-27 13:59:38 -07:00
import ImmutablePropTypes from 'react-immutable-proptypes';
import StillImage from 'soapbox/components/still_image';
2020-03-27 13:59:38 -07:00
export default class Avatar extends React.PureComponent {
2020-03-27 13:59:38 -07:00
static propTypes = {
account: ImmutablePropTypes.map,
size: PropTypes.number,
style: PropTypes.object,
2022-03-21 11:09:01 -07:00
className: PropTypes.string,
2020-03-27 13:59:38 -07:00
};
render() {
2022-03-21 11:09:01 -07:00
const { account, size, className } = this.props;
if (!account) return null;
2020-03-27 13:59:38 -07:00
// : TODO : remove inline and change all avatars to be sized using css
const style = !size ? {} : {
width: `${size}px`,
height: `${size}px`,
};
2022-02-07 11:06:20 -08:00
return (
<StillImage
2022-03-21 11:09:01 -07:00
className={classNames('rounded-full', {
[className]: typeof className !== 'undefined',
})}
2022-02-07 11:06:20 -08:00
style={style}
src={account.get('avatar')}
alt=''
/>
);
2020-03-27 13:59:38 -07:00
}
}