File size: 1,485 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
// @flow
import * as React from 'react';
import type { CommunityInfoType } from 'shared/graphql/fragments/community/communityInfo';
import AvatarImage from './image';
import { Container, AvatarLink } from './style';
import ConditionalWrap from 'src/components/conditionalWrap';
type Props = {
community: CommunityInfoType,
size?: number,
mobilesize?: number,
style?: Object,
showHoverProfile?: boolean,
isClickable?: boolean,
};
class Avatar extends React.Component<Props> {
render() {
const {
community,
size = 32,
isClickable = true,
mobilesize,
style,
} = this.props;
const src = community.profilePhoto;
const communityFallback = '/img/default_community.svg';
const source = [src, communityFallback];
return (
<Container
size={size}
mobilesize={mobilesize}
style={style}
type={'community'}
>
<ConditionalWrap
condition={isClickable}
wrap={children => (
<AvatarLink to={`/${community.slug}`}>{children}</AvatarLink>
)}
>
<AvatarImage
src={source}
size={size}
mobilesize={mobilesize}
type={'community'}
alt={community.name}
/>
</ConditionalWrap>
</Container>
);
}
}
class AvatarHandler extends React.Component<Props> {
render() {
return <Avatar {...this.props} />;
}
}
export default AvatarHandler;
|