-
Notifications
You must be signed in to change notification settings - Fork 38
/
connected_profiles.tsx
61 lines (53 loc) · 1.78 KB
/
connected_profiles.tsx
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
import React from 'react';
import {OverlayTrigger, Tooltip} from 'react-bootstrap';
import {UserProfile} from 'mattermost-redux/types/users';
import Avatar from './avatar/avatar';
interface Props {
pictures: string[],
profiles: UserProfile[],
maxShowedProfiles: number,
size: number;
fontSize: number;
border?: boolean;
}
const ConnectedProfiles = ({pictures, profiles, maxShowedProfiles, size, fontSize, border}: Props) => {
maxShowedProfiles = maxShowedProfiles || 2;
const diff = profiles.length - maxShowedProfiles;
profiles = diff > 0 ? profiles.slice(0, maxShowedProfiles) : profiles;
const margin = -8;
const els = profiles.map((profile, idx) => {
const off = diff > 0 ? (profiles.length - idx) * 8 : (profiles.length - 1 - idx) * 8;
return (
<OverlayTrigger
placement='bottom'
key={'call_thread_profile_' + profile.id}
overlay={
<Tooltip id='tooltip-username'>
{profile.username}
</Tooltip>
}
>
<Avatar
size={size}
fontSize={fontSize}
url={pictures[idx]}
border={Boolean(border)}
style={{position: 'relative', left: `${margin + off}px`}}
/>
</OverlayTrigger>
);
});
if (diff > 0) {
els.push(
<Avatar
size={size}
text={`+${diff}`}
style={{position: 'relative', left: `${margin}px`}}
border={Boolean(border)}
key='call_thread_more_profiles'
/>,
);
}
return <>{els}</>;
};
export default ConnectedProfiles;