feat(ui): Add tooltips to control panel buttons #3572
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The present pull request aims to provide a solution to #3269 (Add hover tooltips to control panel buttons) by adding configurable tooltips to control panel buttons.
Fixes: #3269
Example
How to preview
Initialize the client with a
config
that sets theenableTooltips
option totrue
.Changelog
docs/tutorials/ui-customization.md
Adds a brief description and example for the
enableTooltips
configuration.ui/airplay_button.js
,ui/fullscreen_button.js
,ui/cast_button.js
,ui/loop_button.js
,ui/mute_button.js
,ui/overflow_menu.js
,ui/small_play_button.js
Adds a regular tooltip, based on the
aria-label
attribute of the button.ui/audio_language_selection.js
,ui/fast_forward_button.js
ui/playback_rate_selection.js
,ui/resolution_selection.js
,ui/rewind_button.js
,ui/text_selection.js
Adds a status tooltip, based on the
aria-label
andshaka-status
attributes of the button.As defined on
ui/less/tooltip.less
, thecontent
of the tooltip will be displayed as "aria-label
(shaka-status
)", with the status attribute updated every time a different selection on the button is made.On same cases, a selection is not made by default, so a default
shaka-status
is added.ui/controls.js
Adds the
.shaka-tooltips-on
class to the control panel whenenableTooltips
is set to true.ui/controls.less
Imports the new
tooltip.less
file.ui/externs/ui.js
Adds the
enableTooltips
option to the configuration.ui/tooltip.less
A new tooltip class is added.
It uses the
aria-label
andshaka-status
attributes as content inside theafter
pseudo-element, and is positioned centered on top of the recipient buttons onhover
,focus-visible
andactive
.button:first-child
andbutton:last-child
selectors are adapted to maintain the first and last tooltips inside the control panel margin, overriding the original centering on top.Tooltips are only present when
enableTooltips
is set to true, and have.shaka-tooltips-on
as a parent, and will not appear in the overflow menu.ui/ui.js
Defaults the
enableTooltips
configuration option to false.Checklist