Browse Source

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

master
Saúl Ibarra Corretgé 7 years ago
parent
commit
7012c77fe9
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      react/features/base/toolbox/components/AbstractButton.js

+ 19
- 1
react/features/base/toolbox/components/AbstractButton.js View File

68
      */
68
      */
69
     label: string;
69
     label: string;
70
 
70
 
71
+    /**
72
+     * The label for this button, when toggled.
73
+     */
74
+    toggledLabel: string;
75
+
71
     /**
76
     /**
72
      * The name of the icon of this button, when toggled.
77
      * The name of the icon of this button, when toggled.
73
      *
78
      *
119
             || this.iconName;
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
      * Gets the current styles, taking the toggled state into account. If no
141
      * Gets the current styles, taking the toggled state into account. If no
124
      * toggled styles are provided, the regular styles will also be used in the
142
      * toggled styles are provided, the regular styles will also be used in the
179
             ...this.props,
197
             ...this.props,
180
             accessibilityLabel: this.accessibilityLabel,
198
             accessibilityLabel: this.accessibilityLabel,
181
             iconName: this._getIconName(),
199
             iconName: this._getIconName(),
182
-            label: this.label,
200
+            label: this._getLabel(),
183
             styles: this._getStyles(),
201
             styles: this._getStyles(),
184
             tooltip: this.tooltip
202
             tooltip: this.tooltip
185
         };
203
         };

Loading…
Cancel
Save