Ver código fonte

feat: icon type circular label

master
Bettenbuk Zoltan 5 anos atrás
pai
commit
9525cab60f

+ 6
- 1
react/features/base/label/components/AbstractCircularLabel.js Ver arquivo

@@ -4,10 +4,15 @@ import { Component } from 'react';
4 4
 
5 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 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 Ver arquivo

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

+ 10
- 1
react/features/base/label/components/CircularLabel.web.js Ver arquivo

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

+ 8
- 4
react/features/base/label/components/styles.js Ver arquivo

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

+ 2
- 5
react/features/e2ee/components/E2EELabel.js Ver arquivo

@@ -4,7 +4,7 @@ import Tooltip from '@atlaskit/tooltip';
4 4
 import React, { Component } from 'react';
5 5
 
6 6
 import { translate } from '../../base/i18n';
7
-import { Icon, IconE2EE } from '../../base/icons';
7
+import { IconE2EE } from '../../base/icons';
8 8
 import { CircularLabel } from '../../base/label';
9 9
 import { connect } from '../../base/redux';
10 10
 
@@ -29,16 +29,13 @@ class E2EELabel extends Component<Props> {
29 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 32
         return (
36 33
             <Tooltip
37 34
                 content = { this.props.t('e2ee.labelToolTip') }
38 35
                 position = { 'left' }>
39 36
                 <CircularLabel
40 37
                     className = 'e2ee'
41
-                    label = { icon } />
38
+                    icon = { IconE2EE } />
42 39
             </Tooltip>
43 40
         );
44 41
     }

Carregando…
Cancelar
Salvar