Преглед на файлове

feat(toolbox): add ability to specify a toggled label on AbstractButton

master
Saúl Ibarra Corretgé преди 7 години
родител
ревизия
7012c77fe9
променени са 1 файла, в които са добавени 19 реда и са изтрити 1 реда
  1. 19
    1
      react/features/base/toolbox/components/AbstractButton.js

+ 19
- 1
react/features/base/toolbox/components/AbstractButton.js Целия файл

@@ -68,6 +68,11 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
68 68
      */
69 69
     label: string;
70 70
 
71
+    /**
72
+     * The label for this button, when toggled.
73
+     */
74
+    toggledLabel: string;
75
+
71 76
     /**
72 77
      * The name of the icon of this button, when toggled.
73 78
      *
@@ -119,6 +124,19 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
119 124
             || this.iconName;
120 125
     }
121 126
 
127
+    /**
128
+     * Gets the current label, taking the toggled state into account. If no
129
+     * toggled label is provided, the regular label will also be used in the
130
+     * toggled state.
131
+     *
132
+     * @private
133
+     * @returns {string}
134
+     */
135
+    _getLabel() {
136
+        return (this._isToggled() ? this.toggledLabel : this.label)
137
+            || this.label;
138
+    }
139
+
122 140
     /**
123 141
      * Gets the current styles, taking the toggled state into account. If no
124 142
      * toggled styles are provided, the regular styles will also be used in the
@@ -179,7 +197,7 @@ export default class AbstractButton<P: Props, S: *> extends Component<P, S> {
179 197
             ...this.props,
180 198
             accessibilityLabel: this.accessibilityLabel,
181 199
             iconName: this._getIconName(),
182
-            label: this.label,
200
+            label: this._getLabel(),
183 201
             styles: this._getStyles(),
184 202
             tooltip: this.tooltip
185 203
         };

Loading…
Отказ
Запис