|
@@ -1,12 +1,20 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
|
3
|
+import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+import clsx from 'clsx';
|
3
|
5
|
import React from 'react';
|
4
|
6
|
|
5
|
7
|
import { Icon } from '../../../icons';
|
6
|
8
|
import AbstractStatelessAvatar, { type Props as AbstractProps } from '../AbstractStatelessAvatar';
|
|
9
|
+import { PRESENCE_AVAILABLE_COLOR, PRESENCE_AWAY_COLOR, PRESENCE_BUSY_COLOR, PRESENCE_IDLE_COLOR } from '../styles';
|
7
|
10
|
|
8
|
11
|
type Props = AbstractProps & {
|
9
|
12
|
|
|
13
|
+ /**
|
|
14
|
+ * An object containing the CSS classes.
|
|
15
|
+ */
|
|
16
|
+ classes: Object,
|
|
17
|
+
|
10
|
18
|
/**
|
11
|
19
|
* External class name passed through props.
|
12
|
20
|
*/
|
|
@@ -38,11 +46,77 @@ type Props = AbstractProps & {
|
38
|
46
|
useCORS?: ?boolean
|
39
|
47
|
};
|
40
|
48
|
|
|
49
|
+/**
|
|
50
|
+ * Creates the styles for the component.
|
|
51
|
+ *
|
|
52
|
+ * @returns {Object}
|
|
53
|
+ */
|
|
54
|
+const styles = () => {
|
|
55
|
+ return {
|
|
56
|
+ avatar: {
|
|
57
|
+ backgroundColor: '#AAA',
|
|
58
|
+ borderRadius: '50%',
|
|
59
|
+ color: 'rgba(255, 255, 255, 1)',
|
|
60
|
+ fontWeight: '100',
|
|
61
|
+ objectFit: 'cover',
|
|
62
|
+
|
|
63
|
+ '&.avatar-small': {
|
|
64
|
+ height: '28px !important',
|
|
65
|
+ width: '28px !important'
|
|
66
|
+ },
|
|
67
|
+
|
|
68
|
+ '&.avatar-xsmall': {
|
|
69
|
+ height: '16px !important',
|
|
70
|
+ width: '16px !important'
|
|
71
|
+ },
|
|
72
|
+
|
|
73
|
+ '& .jitsi-icon': {
|
|
74
|
+ transform: 'translateY(50%)'
|
|
75
|
+ },
|
|
76
|
+
|
|
77
|
+ '& .avatar-svg': {
|
|
78
|
+ height: '100%',
|
|
79
|
+ width: '100%'
|
|
80
|
+ }
|
|
81
|
+ },
|
|
82
|
+
|
|
83
|
+ badge: {
|
|
84
|
+ position: 'relative',
|
|
85
|
+
|
|
86
|
+ '&.avatar-badge:after': {
|
|
87
|
+ borderRadius: '50%',
|
|
88
|
+ content: '""',
|
|
89
|
+ display: 'block',
|
|
90
|
+ height: '35%',
|
|
91
|
+ position: 'absolute',
|
|
92
|
+ bottom: 0,
|
|
93
|
+ width: '35%'
|
|
94
|
+ },
|
|
95
|
+
|
|
96
|
+ '&.avatar-badge-available:after': {
|
|
97
|
+ backgroundColor: PRESENCE_AVAILABLE_COLOR
|
|
98
|
+ },
|
|
99
|
+
|
|
100
|
+ '&.avatar-badge-away:after': {
|
|
101
|
+ backgroundColor: PRESENCE_AWAY_COLOR
|
|
102
|
+ },
|
|
103
|
+
|
|
104
|
+ '&.avatar-badge-busy:after': {
|
|
105
|
+ backgroundColor: PRESENCE_BUSY_COLOR
|
|
106
|
+ },
|
|
107
|
+
|
|
108
|
+ '&.avatar-badge-idle:after': {
|
|
109
|
+ backgroundColor: PRESENCE_IDLE_COLOR
|
|
110
|
+ }
|
|
111
|
+ }
|
|
112
|
+ };
|
|
113
|
+};
|
|
114
|
+
|
41
|
115
|
/**
|
42
|
116
|
* Implements a stateless avatar component that renders an avatar purely from what gets passed through
|
43
|
117
|
* props.
|
44
|
118
|
*/
|
45
|
|
-export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
|
119
|
+class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
46
|
120
|
|
47
|
121
|
/**
|
48
|
122
|
* Instantiates a new {@code Component}.
|
|
@@ -66,7 +140,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
66
|
140
|
if (this._isIcon(url)) {
|
67
|
141
|
return (
|
68
|
142
|
<div
|
69
|
|
- className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
|
|
143
|
+ className = { clsx(this._getAvatarClassName(), this._getBadgeClassName()) }
|
70
|
144
|
data-testid = { this.props.testId }
|
71
|
145
|
id = { this.props.id }
|
72
|
146
|
style = { this._getAvatarStyle(this.props.color) }>
|
|
@@ -96,7 +170,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
96
|
170
|
if (initials) {
|
97
|
171
|
return (
|
98
|
172
|
<div
|
99
|
|
- className = { `${this._getAvatarClassName()} ${this._getBadgeClassName()}` }
|
|
173
|
+ className = { clsx(this._getAvatarClassName(), this._getBadgeClassName()) }
|
100
|
174
|
data-testid = { this.props.testId }
|
101
|
175
|
id = { this.props.id }
|
102
|
176
|
style = { this._getAvatarStyle(this.props.color) }>
|
|
@@ -157,7 +231,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
157
|
231
|
* @returns {string}
|
158
|
232
|
*/
|
159
|
233
|
_getAvatarClassName(additional) {
|
160
|
|
- return `avatar ${additional || ''} ${this.props.className || ''}`;
|
|
234
|
+ return clsx('avatar', additional, this.props.className, this.props.classes.avatar);
|
161
|
235
|
}
|
162
|
236
|
|
163
|
237
|
/**
|
|
@@ -169,7 +243,7 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
169
|
243
|
const { status } = this.props;
|
170
|
244
|
|
171
|
245
|
if (status) {
|
172
|
|
- return `avatar-badge avatar-badge-${status}`;
|
|
246
|
+ return clsx('avatar-badge', `avatar-badge-${status}`, this.props.classes.badge);
|
173
|
247
|
}
|
174
|
248
|
|
175
|
249
|
return '';
|
|
@@ -192,3 +266,5 @@ export default class StatelessAvatar extends AbstractStatelessAvatar<Props> {
|
192
|
266
|
}
|
193
|
267
|
}
|
194
|
268
|
}
|
|
269
|
+
|
|
270
|
+export default withStyles(styles)(StatelessAvatar);
|