浏览代码

feat: dynamic avatar font size

j8
Bettenbuk Zoltan 6 年前
父节点
当前提交
a35b36d6df
共有 2 个文件被更改,包括 31 次插入1 次删除
  1. 17
    0
      css/_avatar.scss
  2. 14
    1
      react/features/base/avatar/components/web/StatelessAvatar.js

+ 17
- 0
css/_avatar.scss 查看文件

9
     object-fit: cover;
9
     object-fit: cover;
10
 }
10
 }
11
 
11
 
12
+.avatar-foreign {
13
+    align-items: center;
14
+    bottom: 0;
15
+    display: flex;
16
+    font-size: 40pt;
17
+    justify-content: center;
18
+    left: 0;
19
+    position: absolute;
20
+    right: 0;
21
+    top: 0;
22
+}
23
+
24
+.avatar-svg {
25
+    height: 100%;
26
+    width: 100%;
27
+}
28
+
12
 .defaultAvatar {
29
 .defaultAvatar {
13
     opacity: 0.6
30
     opacity: 0.6
14
 }
31
 }

+ 14
- 1
react/features/base/avatar/components/web/StatelessAvatar.js 查看文件

52
                     className = { this._getAvatarClassName() }
52
                     className = { this._getAvatarClassName() }
53
                     id = { this.props.id }
53
                     id = { this.props.id }
54
                     style = { this._getAvatarStyle(this.props.color) }>
54
                     style = { this._getAvatarStyle(this.props.color) }>
55
-                    { initials }
55
+                    <svg
56
+                        className = 'avatar-svg'
57
+                        viewBox = '0 0 100 100'
58
+                        xmlns = 'http://www.w3.org/2000/svg'
59
+                        xmlnsXlink = 'http://www.w3.org/1999/xlink'>
60
+                        <foreignObject
61
+                            height = '100%'
62
+                            width = '100%'>
63
+                            <span
64
+                                className = 'avatar-foreign'>
65
+                                { initials }
66
+                            </span>
67
+                        </foreignObject>
68
+                    </svg>
56
                 </div>
69
                 </div>
57
             );
70
             );
58
         }
71
         }

正在加载...
取消
保存