瀏覽代碼

Implement ToolboxItem features: disabled, tooltip with label

j8
Bettenbuk Zoltan 6 年之前
父節點
當前提交
e59761baa2

+ 6
- 0
css/_toolbars.scss 查看文件

@@ -120,6 +120,12 @@
120 120
             height: 22px;
121 121
             padding: 5px 12px;
122 122
 
123
+            div {
124
+                display: flex;
125
+                flex-direction: row;
126
+                align-items: center;
127
+            }
128
+
123 129
             &:hover {
124 130
                 background: #313D52;
125 131
             }

+ 1
- 1
react/features/base/toolbox/components/AbstractButton.js 查看文件

@@ -114,7 +114,7 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
114 114
      *
115 115
      * @abstract
116 116
      */
117
-    tooltip: string;
117
+    tooltip: ?string;
118 118
 
119 119
     /**
120 120
      * Initializes a new {@code AbstractButton} instance.

+ 1
- 1
react/features/base/toolbox/components/AbstractToolboxItem.js 查看文件

@@ -75,7 +75,7 @@ export type Props = {
75 75
     /**
76 76
      * The text to display in the tooltip. Used only on web.
77 77
      */
78
-    tooltip: string,
78
+    tooltip: ?string,
79 79
 
80 80
     /**
81 81
      * From which direction the tooltip should appear, relative to the

+ 23
- 18
react/features/base/toolbox/components/ToolboxItem.web.js 查看文件

@@ -21,23 +21,40 @@ export default class ToolboxItem extends AbstractToolboxItem<Props> {
21 21
      */
22 22
     _renderItem() {
23 23
         const {
24
+            disabled,
24 25
             onClick,
25
-            showLabel
26
+            showLabel,
27
+            tooltipPosition
26 28
         } = this.props;
29
+        const className = showLabel ? 'overflow-menu-item' : 'toolbox-button';
27 30
         const props = {
28 31
             'aria-label': this.accessibilityLabel,
29
-            className: showLabel ? 'overflow-menu-item' : 'toolbox-button',
30
-            onClick
32
+            className: className + (disabled ? ' disabled' : ''),
33
+            onClick: disabled ? undefined : onClick
31 34
         };
32 35
         const elementType = showLabel ? 'li' : 'div';
36
+        const useTooltip = this.tooltip && this.tooltip.length > 0;
33 37
         // eslint-disable-next-line no-extra-parens
34
-        const children = (
38
+        let children = (
35 39
             <Fragment>
36 40
                 { this._renderIcon() }
37
-                { showLabel && this.label }
41
+                { showLabel && <span>
42
+                    { this.label }
43
+                </span> }
38 44
             </Fragment>
39 45
         );
40 46
 
47
+        if (useTooltip) {
48
+            // eslint-disable-next-line no-extra-parens
49
+            children = (
50
+                <Tooltip
51
+                    content = { this.tooltip }
52
+                    position = { tooltipPosition }>
53
+                    { children }
54
+                </Tooltip>
55
+            );
56
+        }
57
+
41 58
         return React.createElement(elementType, props, children);
42 59
     }
43 60
 
@@ -48,25 +65,13 @@ export default class ToolboxItem extends AbstractToolboxItem<Props> {
48 65
      * @returns {ReactElement}
49 66
      */
50 67
     _renderIcon() {
51
-        const { iconName, tooltipPosition, showLabel } = this.props;
68
+        const { iconName, showLabel } = this.props;
52 69
         const icon = <i className = { iconName } />;
53 70
         const elementType = showLabel ? 'span' : 'div';
54 71
         const className
55 72
             = showLabel ? 'overflow-menu-item-icon' : 'toolbox-icon';
56 73
         const iconWrapper
57 74
             = React.createElement(elementType, { className }, icon);
58
-        const tooltip = this.tooltip;
59
-        const useTooltip = !showLabel && tooltip && tooltip.length > 0;
60
-
61
-        if (useTooltip) {
62
-            return (
63
-                <Tooltip
64
-                    content = { tooltip }
65
-                    position = { tooltipPosition }>
66
-                    { iconWrapper }
67
-                </Tooltip>
68
-            );
69
-        }
70 75
 
71 76
         return iconWrapper;
72 77
     }

Loading…
取消
儲存