|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+import { Theme } from '@mui/material';
|
|
1
|
2
|
import { withStyles } from '@mui/styles';
|
|
2
|
3
|
import clsx from 'clsx';
|
|
3
|
4
|
import React from 'react';
|
|
4
|
5
|
|
|
5
|
6
|
import Icon from '../../../icons/components/Icon';
|
|
|
7
|
+import { IconUser } from '../../../icons/svg';
|
|
|
8
|
+import { withPixelLineHeight } from '../../../styles/functions.web';
|
|
6
|
9
|
import AbstractStatelessAvatar, { type IProps as AbstractProps } from '../AbstractStatelessAvatar';
|
|
7
|
10
|
import { PRESENCE_AVAILABLE_COLOR, PRESENCE_AWAY_COLOR, PRESENCE_BUSY_COLOR, PRESENCE_IDLE_COLOR } from '../styles';
|
|
8
|
11
|
|
|
|
@@ -47,17 +50,21 @@ interface IProps extends AbstractProps {
|
|
47
|
50
|
/**
|
|
48
|
51
|
* Creates the styles for the component.
|
|
49
|
52
|
*
|
|
|
53
|
+ * @param {Theme} theme - The MUI theme.
|
|
50
|
54
|
* @returns {Object}
|
|
51
|
55
|
*/
|
|
52
|
|
-const styles = () => {
|
|
|
56
|
+const styles = (theme: Theme) => {
|
|
53
|
57
|
return {
|
|
54
|
58
|
avatar: {
|
|
55
|
59
|
backgroundColor: '#AAA',
|
|
56
|
60
|
borderRadius: '50%',
|
|
57
|
|
- color: 'rgba(255, 255, 255, 1)',
|
|
58
|
|
- fontWeight: '100',
|
|
|
61
|
+ fontWeight: '600',
|
|
|
62
|
+ color: theme.palette?.text01 || '#fff',
|
|
|
63
|
+ ...withPixelLineHeight(theme.typography?.heading1 ?? {}),
|
|
|
64
|
+ fontSize: 'inherit',
|
|
59
|
65
|
objectFit: 'cover' as const,
|
|
60
|
66
|
textAlign: 'center' as const,
|
|
|
67
|
+ overflow: 'hidden',
|
|
61
|
68
|
|
|
62
|
69
|
'&.avatar-small': {
|
|
63
|
70
|
height: '28px !important',
|
|
|
@@ -79,6 +86,14 @@ const styles = () => {
|
|
79
|
86
|
}
|
|
80
|
87
|
},
|
|
81
|
88
|
|
|
|
89
|
+ initialsContainer: {
|
|
|
90
|
+ width: '100%',
|
|
|
91
|
+ height: '100%',
|
|
|
92
|
+ display: 'flex',
|
|
|
93
|
+ justifyContent: 'center',
|
|
|
94
|
+ alignItems: 'center'
|
|
|
95
|
+ },
|
|
|
96
|
+
|
|
82
|
97
|
badge: {
|
|
83
|
98
|
position: 'relative' as const,
|
|
84
|
99
|
|
|
|
@@ -173,35 +188,23 @@ class StatelessAvatar extends AbstractStatelessAvatar<IProps> {
|
|
173
|
188
|
data-testid = { this.props.testId }
|
|
174
|
189
|
id = { this.props.id }
|
|
175
|
190
|
style = { this._getAvatarStyle(this.props.color) }>
|
|
176
|
|
- <svg
|
|
177
|
|
- className = 'avatar-svg'
|
|
178
|
|
- viewBox = '0 0 100 100'
|
|
179
|
|
- xmlns = 'http://www.w3.org/2000/svg'
|
|
180
|
|
- xmlnsXlink = 'http://www.w3.org/1999/xlink'>
|
|
181
|
|
- <text
|
|
182
|
|
- dominantBaseline = 'central'
|
|
183
|
|
- fill = 'rgba(255,255,255,1)'
|
|
184
|
|
- fontSize = '40pt'
|
|
185
|
|
- textAnchor = 'middle'
|
|
186
|
|
- x = '50'
|
|
187
|
|
- y = '50'>
|
|
188
|
|
- { initials }
|
|
189
|
|
- </text>
|
|
190
|
|
- </svg>
|
|
|
191
|
+ <div className = { this.props.classes.initialsContainer }>
|
|
|
192
|
+ {initials}
|
|
|
193
|
+ </div>
|
|
191
|
194
|
</div>
|
|
192
|
195
|
);
|
|
193
|
196
|
}
|
|
194
|
197
|
|
|
195
|
198
|
// default avatar
|
|
196
|
199
|
return (
|
|
197
|
|
- <div className = { this._getBadgeClassName() }>
|
|
198
|
|
- <img
|
|
199
|
|
- alt = 'avatar'
|
|
200
|
|
- className = { this._getAvatarClassName('defaultAvatar') }
|
|
201
|
|
- data-testid = { this.props.testId }
|
|
202
|
|
- id = { this.props.id }
|
|
203
|
|
- src = { this.props.defaultAvatar || 'images/avatar.png' }
|
|
204
|
|
- style = { this._getAvatarStyle() } />
|
|
|
200
|
+ <div
|
|
|
201
|
+ className = { clsx(this._getAvatarClassName('defaultAvatar'), this._getBadgeClassName()) }
|
|
|
202
|
+ data-testid = { this.props.testId }
|
|
|
203
|
+ id = { this.props.id }
|
|
|
204
|
+ style = { this._getAvatarStyle() }>
|
|
|
205
|
+ <Icon
|
|
|
206
|
+ size = { '50%' }
|
|
|
207
|
+ src = { IconUser } />
|
|
205
|
208
|
</div>
|
|
206
|
209
|
);
|
|
207
|
210
|
}
|
|
|
@@ -217,7 +220,7 @@ class StatelessAvatar extends AbstractStatelessAvatar<IProps> {
|
|
217
|
220
|
|
|
218
|
221
|
return {
|
|
219
|
222
|
background: color || undefined,
|
|
220
|
|
- fontSize: size ? size * 0.5 : '180%',
|
|
|
223
|
+ fontSize: size ? size * 0.4 : '180%',
|
|
221
|
224
|
height: size || '100%',
|
|
222
|
225
|
width: size || '100%'
|
|
223
|
226
|
};
|