瀏覽代碼

feat: icon type circular label

master
Bettenbuk Zoltan 5 年之前
父節點
當前提交
9525cab60f

+ 6
- 1
react/features/base/label/components/AbstractCircularLabel.js 查看文件

4
 
4
 
5
 export type Props = {
5
 export type Props = {
6
 
6
 
7
+    /**
8
+     * An SVG icon to be rendered as the content of the label.
9
+     */
10
+    icon: Component<any>,
11
+
7
     /**
12
     /**
8
      * String or component that will be rendered as the label itself.
13
      * String or component that will be rendered as the label itself.
9
      */
14
      */
10
-    label: string | React$Node
15
+    label: string
11
 };
16
 };
12
 
17
 
13
 /**
18
 /**

+ 14
- 4
react/features/base/label/components/CircularLabel.native.js 查看文件

2
 import React from 'react';
2
 import React from 'react';
3
 import { Animated, Text } from 'react-native';
3
 import { Animated, Text } from 'react-native';
4
 
4
 
5
+import Icon from '../../icons/components/Icon';
5
 import { combineStyles, type StyleType } from '../../styles';
6
 import { combineStyles, type StyleType } from '../../styles';
6
 
7
 
7
 import AbstractCircularLabel, {
8
 import AbstractCircularLabel, {
90
      * @inheritdoc
91
      * @inheritdoc
91
      */
92
      */
92
     render() {
93
     render() {
93
-        const { status, label, style } = this.props;
94
+        const { icon, label, status, style } = this.props;
94
 
95
 
95
         let extraStyle = null;
96
         let extraStyle = null;
96
 
97
 
105
             break;
106
             break;
106
         }
107
         }
107
 
108
 
109
+        const labelComponent = icon
110
+            ? (
111
+                <Icon
112
+                    src = { icon }
113
+                    style = { styles.indicatorIcon } />
114
+            ) : (
115
+                <Text style = { styles.indicatorText }>
116
+                    { label }
117
+                </Text>
118
+            );
119
+
108
         return (
120
         return (
109
             <Animated.View
121
             <Animated.View
110
                 style = { [
122
                 style = { [
111
                     combineStyles(styles.indicatorContainer, style),
123
                     combineStyles(styles.indicatorContainer, style),
112
                     extraStyle
124
                     extraStyle
113
                 ] }>
125
                 ] }>
114
-                <Text style = { styles.indicatorText }>
115
-                    { label }
116
-                </Text>
126
+                { labelComponent }
117
             </Animated.View>
127
             </Animated.View>
118
         );
128
         );
119
     }
129
     }

+ 10
- 1
react/features/base/label/components/CircularLabel.web.js 查看文件

2
 
2
 
3
 import React from 'react';
3
 import React from 'react';
4
 
4
 
5
+import Icon from '../../icons/components/Icon';
6
+
5
 import AbstractCircularLabel, {
7
 import AbstractCircularLabel, {
6
     type Props as AbstractProps
8
     type Props as AbstractProps
7
 } from './AbstractCircularLabel';
9
 } from './AbstractCircularLabel';
44
     render() {
46
     render() {
45
         const {
47
         const {
46
             className,
48
             className,
49
+            icon,
47
             id,
50
             id,
48
             label
51
             label
49
         } = this.props;
52
         } = this.props;
50
 
53
 
54
+        const labelComponent = icon
55
+            ? (
56
+                <Icon
57
+                    src = { icon } />
58
+            ) : label;
59
+
51
         return (
60
         return (
52
             <div
61
             <div
53
                 className = { `circular-label ${className}` }
62
                 className = { `circular-label ${className}` }
54
                 id = { id }>
63
                 id = { id }>
55
-                { label }
64
+                { labelComponent }
56
             </div>
65
             </div>
57
         );
66
         );
58
     }
67
     }

+ 8
- 4
react/features/base/label/components/styles.js 查看文件

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { BoxModel, ColorPalette, createStyleSheet } from '../../styles';
3
+import { BoxModel, ColorPalette } from '../../styles';
4
 
4
 
5
 /**
5
 /**
6
  * The default color of the {@code Label} and {@code ExpandedLabel}.
6
  * The default color of the {@code Label} and {@code ExpandedLabel}.
22
 /**
22
 /**
23
  * The styles of the native base/label feature.
23
  * The styles of the native base/label feature.
24
  */
24
  */
25
-export default createStyleSheet({
25
+export default {
26
 
26
 
27
     expandedLabelArrow: {
27
     expandedLabelArrow: {
28
         backgroundColor: ColorPalette.blue,
28
         backgroundColor: ColorPalette.blue,
64
         width: LABEL_SIZE
64
         width: LABEL_SIZE
65
     },
65
     },
66
 
66
 
67
+    indicatorIcon: {
68
+        fontSize: 24
69
+    },
70
+
67
     indicatorText: {
71
     indicatorText: {
68
         color: ColorPalette.white,
72
         color: ColorPalette.white,
69
-        fontSize: 12
73
+        fontSize: 10
70
     },
74
     },
71
 
75
 
72
     labelOff: {
76
     labelOff: {
73
         opacity: 0.3
77
         opacity: 0.3
74
     }
78
     }
75
-});
79
+};

+ 2
- 5
react/features/e2ee/components/E2EELabel.js 查看文件

4
 import React, { Component } from 'react';
4
 import React, { Component } from 'react';
5
 
5
 
6
 import { translate } from '../../base/i18n';
6
 import { translate } from '../../base/i18n';
7
-import { Icon, IconE2EE } from '../../base/icons';
7
+import { IconE2EE } from '../../base/icons';
8
 import { CircularLabel } from '../../base/label';
8
 import { CircularLabel } from '../../base/label';
9
 import { connect } from '../../base/redux';
9
 import { connect } from '../../base/redux';
10
 
10
 
29
             return null;
29
             return null;
30
         }
30
         }
31
 
31
 
32
-        // eslint-disable-next-line react/jsx-max-props-per-line
33
-        const icon = <Icon size = { 22 } src = { IconE2EE } />;
34
-
35
         return (
32
         return (
36
             <Tooltip
33
             <Tooltip
37
                 content = { this.props.t('e2ee.labelToolTip') }
34
                 content = { this.props.t('e2ee.labelToolTip') }
38
                 position = { 'left' }>
35
                 position = { 'left' }>
39
                 <CircularLabel
36
                 <CircularLabel
40
                     className = 'e2ee'
37
                     className = 'e2ee'
41
-                    label = { icon } />
38
+                    icon = { IconE2EE } />
42
             </Tooltip>
39
             </Tooltip>
43
         );
40
         );
44
     }
41
     }

Loading…
取消
儲存