Parcourir la source

feat(avatar) Update style (#13019)

factor2
Robert Pintilii il y a 2 ans
Parent
révision
43c4ec0808
Aucun compte lié à l'adresse e-mail de l'auteur

+ 30
- 27
react/features/base/avatar/components/web/StatelessAvatar.tsx Voir le fichier

@@ -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
         };

+ 14
- 2
react/features/filmstrip/components/web/Thumbnail.tsx Voir le fichier

@@ -650,6 +650,17 @@ class Thumbnail extends Component<IProps, IState> {
650 650
         });
651 651
     }
652 652
 
653
+    /**
654
+     * Returns the size the avatar should have.
655
+     *
656
+     * @returns {number}
657
+     */
658
+    _getAvatarSize() {
659
+        const { _height, _width } = this.props;
660
+
661
+        return Math.min(_height / 2, _width - 30, 200);
662
+    }
663
+
653 664
     /**
654 665
      * Returns an object with the styles for thumbnail.
655 666
      *
@@ -687,7 +698,7 @@ class Thumbnail extends Component<IProps, IState> {
687 698
             video: {}
688 699
         };
689 700
 
690
-        const avatarSize = Math.min(_height / 2, _width - 30, 200);
701
+        const avatarSize = this._getAvatarSize();
691 702
         let { left } = style || {};
692 703
 
693 704
         if (typeof left === 'number' && horizontalOffset) {
@@ -923,7 +934,8 @@ class Thumbnail extends Component<IProps, IState> {
923 934
                 style = { styles }>
924 935
                 <Avatar
925 936
                     className = 'userAvatar'
926
-                    participantId = { id } />
937
+                    participantId = { id }
938
+                    size = { this._getAvatarSize() } />
927 939
             </div>
928 940
         );
929 941
     }

+ 4
- 4
react/features/speaker-stats/components/web/SpeakerStatsItem.tsx Voir le fichier

@@ -79,13 +79,13 @@ const SpeakerStatsItem = (props: Props) => {
79 79
                             <StatelessAvatar
80 80
                                 className = 'userAvatar'
81 81
                                 color = { BaseTheme.palette.ui04 }
82
-                                initials = { getInitials(props.displayName) } />
82
+                                initials = { getInitials(props.displayName) }
83
+                                size = { 32 } />
83 84
                         ) : (
84 85
                             <Avatar
85
-
86
-                                // @ts-ignore
87 86
                                 className = 'userAvatar'
88
-                                participantId = { props.participantId } />
87
+                                participantId = { props.participantId }
88
+                                size = { 32 } />
89 89
                         )
90 90
                     }
91 91
                 </div>

+ 1
- 3
react/features/speaker-stats/components/web/SpeakerStatsList.tsx Voir le fichier

@@ -23,9 +23,7 @@ const useStyles = makeStyles()(theme => {
23 23
                     color: theme.palette.text03
24 24
                 },
25 25
                 '& .avatar': {
26
-                    width: '32px',
27
-                    marginRight: theme.spacing(3),
28
-                    height: theme.spacing(5)
26
+                    marginRight: theme.spacing(3)
29 27
                 },
30 28
                 '& .time': {
31 29
                     padding: '2px 4px',

Chargement…
Annuler
Enregistrer