Improve usability of toggled button labels (#12426)

* feat(a11y) buttons can now have toggled-aware a11y labels
This commit is contained in:
Emmanuel Pelletier
2023-03-13 09:19:28 +01:00
committed by GitHub
parent 27765b47d7
commit 45b7f53294
15 changed files with 108 additions and 148 deletions

View File

@@ -17,9 +17,12 @@ type Props = AbstractButtonProps & {
* Implementation of a button for toggling fullscreen state.
*/
class FullscreenButton extends AbstractButton<Props, *> {
accessibilityLabel = 'toolbar.accessibilityLabel.fullScreen';
accessibilityLabel = 'toolbar.accessibilityLabel.enterFullScreen';
toggledAccessibilityLabel = 'toolbar.accessibilityLabel.exitFullScreen';
label = 'toolbar.enterFullScreen';
toggledLabel = 'toolbar.exitFullScreen';
tooltip = 'toolbar.enterFullScreen';
toggledTooltip = 'toolbar.exitFullScreen';
/**
* Retrieves icon dynamically.
@@ -41,26 +44,6 @@ class FullscreenButton extends AbstractButton<Props, *> {
// Unused.
}
/**
* Retrieves icon dynamically.
*/
get tooltip() {
if (this._isToggled()) {
return 'toolbar.exitFullScreen';
}
return 'toolbar.enterFullScreen';
}
/**
* Required by linter due to AbstractButton overwritten prop being writable.
*
* @param {string} _value - The value.
*/
set tooltip(_value) {
// Unused.
}
/**
* Indicates whether this button is in toggled state or not.
*