Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu captions to the TV UI #459

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
70d45f8
Add menu captions to the TV UI
kishorens Jun 28, 2022
ed0bb81
fix the merge conflicts
kishorens Jun 28, 2022
a6ac6a1
Update src/ts/components/settingstogglebutton.ts
kishorens Jul 8, 2022
861cb28
Update src/ts/components/menucaption.ts
kishorens Jul 8, 2022
3c04fad
Update src/ts/uifactory.ts
kishorens Jul 8, 2022
098a82d
Update src/ts/uifactory.ts
kishorens Jul 8, 2022
299dbb0
Merge branch 'develop' into feature/SOL_3687
dweinber Jun 28, 2024
f1f9688
Rename MenuCaption component (camel-case)
dweinber Jun 28, 2024
9c1f3b6
Export component
dweinber Jun 28, 2024
13a84d6
Change positioning of the MenuCaption components in the TV UI
dweinber Jun 28, 2024
a05a2e5
Change MenuCaption to show when the button is focused, e.g. it is hov…
dweinber Jun 28, 2024
7f5c3da
Use the UI's standard Label component instead of the new menuCaption …
dweinber Jun 28, 2024
01cf093
Remove menuCaption component as it's not needed
dweinber Jun 28, 2024
2c57d86
Fix lint-sass warnings in TV UI SCSS
dweinber Jul 1, 2024
90857e5
Merge branch 'develop' into feature/SOL_3687
dweinber Jul 1, 2024
cea5b6c
Fix tslint errors
dweinber Jul 1, 2024
9f277e7
Add changelog entry
dweinber Jul 1, 2024
10a6ba0
Remove menuLabel code from settingstogglebutton
dweinber Jul 10, 2024
44ae9ce
Use the Label component instead of creating a label/span HTML element…
dweinber Jul 10, 2024
cb3c3c4
Add a new option for all buttons to show the associated label(/span) …
dweinber Jul 10, 2024
363c53b
Use different offsets from the button depending on whether the button…
dweinber Jul 10, 2024
7e80e27
Merge branch 'develop' into feature/SOL_3687
dweinber Jul 10, 2024
604c91f
Add documentation for new config option
dweinber Jul 10, 2024
eb04be3
Use component's setText method
dweinber Jul 10, 2024
99ff56a
Initialize and release the super class as well
dweinber Jul 10, 2024
f5b814c
Mock the textLabel property
dweinber Jul 10, 2024
67482e0
Move label creation to the toDomElement method to be inline with othe…
dweinber Jul 10, 2024
5efe823
Remove outdated CSS class
dweinber Jul 10, 2024
f185b58
Satisfy the linter
dweinber Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [unreleased]

### Added
- Configuration option in `Button` component to show button title on hover/focus

## [3.67.0] - 2024-07-03

### Added
Expand All @@ -20,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Eco Mode toggle button


## [3.64.0] - 2024-05-28

### Added
Expand Down
8 changes: 8 additions & 0 deletions spec/components/fullscreentogglebutton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ describe('FullscreenToggleButton', () => {
uiInstanceManagerMock = MockHelper.getUiInstanceManagerMock();

fullscreenToggleButton = new FullscreenToggleButton();
(<any>fullscreenToggleButton).textLabel = {
setText: jest.fn(),
getDomElement: () => MockHelper.generateDOMMock(),
initialize: jest.fn(),
show: jest.fn(),
hide: jest.fn(),
release: jest.fn(),
};
fullscreenToggleButton.initialize();

// Setup DOM Mock
Expand Down
8 changes: 8 additions & 0 deletions spec/components/pictureinpicturetogglebutton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ describe('PictureInPictureToggleButton', () => {
uiInstanceManagerMock = MockHelper.getUiInstanceManagerMock();

pictureInPictureToggleButton = new PictureInPictureToggleButton();
(<any>pictureInPictureToggleButton).textLabel = {
setText: jest.fn(),
getDomElement: () => MockHelper.generateDOMMock(),
initialize: jest.fn(),
show: jest.fn(),
hide: jest.fn(),
release: jest.fn(),
};
pictureInPictureToggleButton.initialize();

// Setup DOM Mock
Expand Down
36 changes: 36 additions & 0 deletions src/scss/skin-modern/components/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,39 @@
.#{$prefix}-ui-button {
@extend %ui-button;
}

.#{$prefix}-ui-labeledbutton {
@extend %ui-button;

span,
label {
text-align: center;

Check warning on line 52 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Expected `color`, found `text-align`
position: absolute;
color: $color-primary;

Check warning on line 54 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Expected `text-align`, found `color`
transform: translateX(-50%);
white-space: normal;
}

span.#{$prefix}-hidden,

Check warning on line 59 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Class should be nested within its parent Type-selector

Check warning on line 59 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Qualifying elements are not allowed for class selectors
label.#{$prefix}-hidden {

Check warning on line 60 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Class should be nested within its parent Type-selector

Check warning on line 60 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Qualifying elements are not allowed for class selectors
display: none;
}
}

.#{$prefix}-ui-controlbar {
.#{$prefix}-ui-labeledbutton {
span,
label {
margin-top: -1.7em;
}
}
}

.#{$prefix}-ui-titlebar {
.#{$prefix}-ui-labeledbutton {
span,
label {
margin-top: 1.2em;
}
}
}

Check warning on line 81 in src/scss/skin-modern/components/_button.scss

View workflow job for this annotation

GitHub Actions / test_and_build

Files must end with a new line
43 changes: 39 additions & 4 deletions src/ts/components/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ComponentConfig, Component} from './component';
import {DOM} from '../dom';
import {EventDispatcher, NoArgs, Event} from '../eventdispatcher';
import { LocalizableText , i18n } from '../localization/i18n';
import { Label, LabelConfig } from './label';

/**
* Configuration interface for a {@link Button} component.
Expand All @@ -22,12 +23,20 @@ export interface ButtonConfig extends ComponentConfig {
* Default: false
*/
acceptsTouchWithUiHidden?: boolean;

/**
* Specifies whether the text of the button should be shown when the button is hovered or focused.
*
* Default: false
*/
showTextOnFocus?: boolean;
}

/**
* A simple clickable button.
*/
export class Button<Config extends ButtonConfig> extends Component<Config> {
protected textLabel: Label<LabelConfig>;

private buttonEvents = {
onClick: new EventDispatcher<Button<Config>, NoArgs>(),
Expand All @@ -41,7 +50,12 @@ export class Button<Config extends ButtonConfig> extends Component<Config> {
role: 'button',
tabIndex: 0,
acceptsTouchWithUiHidden: false,
showTextOnFocus: false,
} as Config, this.config);

if (this.config.showTextOnFocus) {
this.config.cssClasses = this.config.cssClasses.concat('ui-labeledbutton');
}
}

protected toDomElement(): DOM {
Expand All @@ -61,10 +75,21 @@ export class Button<Config extends ButtonConfig> extends Component<Config> {
buttonElementAttributes['role'] = this.config.role;
}

this.textLabel = new Label({
text: i18n.performLocalization(this.config.text),
for: this.config.id,
hidden: true,
});

// Create the button element with the text label
let buttonElement = new DOM('button', buttonElementAttributes, this).append(new DOM('span', {
'class': this.prefixCss('label'),
}).html(i18n.performLocalization(this.config.text)));
let buttonElement = new DOM('button', buttonElementAttributes, this).append(this.textLabel.getDomElement());

if (this.config.showTextOnFocus) {
buttonElement.on('focusin', (e) => this.textLabel.show());
buttonElement.on('mouseenter', (e) => this.textLabel.show());
buttonElement.on('focusout', (e) => this.textLabel.hide());
buttonElement.on('mouseleave', (e) => this.textLabel.hide());
}

// Listen for the click event on the button element and trigger the corresponding event on the button component
buttonElement.on('click', () => {
Expand All @@ -79,13 +104,23 @@ export class Button<Config extends ButtonConfig> extends Component<Config> {
* @param text the text to put into the label of the button
*/
setText(text: LocalizableText): void {
this.getDomElement().find('.' + this.prefixCss('label')).html(i18n.performLocalization(text));
this.textLabel.setText(text);
}

protected onClickEvent() {
this.buttonEvents.onClick.dispatch(this);
}

initialize(): void {
super.initialize();
this.textLabel.initialize();
}

release(): void {
super.release();
this.textLabel.release();
}

/**
* Gets the event that is fired when the button is clicked.
* @returns {Event<Button<Config>, NoArgs>}
Expand Down
12 changes: 9 additions & 3 deletions src/ts/uifactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { AdSkipButton } from './components/adskipbutton';
import { CloseButton } from './components/closebutton';
import { MetadataLabel, MetadataLabelContent } from './components/metadatalabel';
import { PlayerUtils } from './playerutils';
import { Label } from './components/label';
import { Label, LabelConfig } from './components/label';
import { CastUIContainer } from './components/castuicontainer';
import { UIConditionContext, UIManager } from './uimanager';
import { UIConfig } from './uiconfig';
Expand Down Expand Up @@ -193,7 +193,10 @@ export namespace UIFactory {
new AdClickOverlay(),
new PlaybackToggleOverlay(),
new Container({
components: [new AdMessageLabel({ text: i18n.getLocalizer('ads.remainingTime') }), new AdSkipButton()],
components: [
new AdMessageLabel({ text: i18n.getLocalizer('ads.remainingTime') }),
new AdSkipButton(),
],
cssClass: 'ui-ads-status',
}),
new ControlBar({
Expand Down Expand Up @@ -339,7 +342,10 @@ export namespace UIFactory {
],
}),
new Container({
components: [new AdMessageLabel({ text: 'Ad: {remainingTime} secs' }), new AdSkipButton()],
components: [
new AdMessageLabel({ text: 'Ad: {remainingTime} secs' }),
new AdSkipButton(),
],
cssClass: 'ui-ads-status',
}),
],
Expand Down
Loading