forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
team_image.tsx
49 lines (44 loc) · 1.47 KB
/
team_image.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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
type Props = {
small: boolean;
teamIconUrl: string;
displayName: string;
}
export default class TeamButton extends React.PureComponent<Props, {}> {
public render(): JSX.Element {
const {small, teamIconUrl} = this.props;
const classModifier = small ? 'small' : 'large';
let content;
if (teamIconUrl) {
content = (
<div className='team-btn__content'>
<div
className={`team-btn__image team-btn-${classModifier}__image`}
style={{backgroundImage: `url('${teamIconUrl}')`}}
/>
</div>
);
} else {
let initials = this.props.displayName;
initials = initials ? initials.replace(/\s/g, '').substring(0, 2) : '??';
content = (
<div className='team-btn__content'>
<div className={`team-btn__initials team-btn-${classModifier}__initials`}>
{initials}
</div>
</div>
);
}
return (
<div
className='team-container'
>
<div className={`team-btn team-btn-${classModifier}`} >
{content}
</div>
</div>
);
}
}