Skip to content

Commit

Permalink
feat(ToggleMenuServiceItem): parse default nav endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Apr 13, 2023
1 parent a9cad49 commit a056696
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/parser/classes/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import Text from './misc/Text.js';
import NavigationEndpoint from './NavigationEndpoint.js';

import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';

class Button extends YTNode {
export default class Button extends YTNode {
static type = 'Button';

text?: string;
Expand All @@ -15,7 +16,7 @@ class Button extends YTNode {

endpoint: NavigationEndpoint;

constructor(data: any) {
constructor(data: RawNode) {
super();

if (data.text) {
Expand All @@ -40,6 +41,4 @@ class Button extends YTNode {

this.endpoint = new NavigationEndpoint(data.navigationEndpoint || data.serviceEndpoint || data.command);
}
}

export default Button;
}
15 changes: 8 additions & 7 deletions src/parser/classes/ToggleMenuServiceItem.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import Text from './misc/Text.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';

class ToggleMenuServiceItem extends YTNode {
export default class ToggleMenuServiceItem extends YTNode {
static type = 'ToggleMenuServiceItem';

text: Text;
toggled_text: Text;
icon_type: string;
toggled_icon_type: string;
endpoint: NavigationEndpoint;
default_endpoint: NavigationEndpoint;
toggled_endpoint: NavigationEndpoint;

constructor(data: any) {
constructor(data: RawNode) {
super();
this.text = new Text(data.defaultText);
this.toggled_text = new Text(data.toggledText);
this.icon_type = data.defaultIcon.iconType;
this.toggled_icon_type = data.toggledIcon.iconType;
this.endpoint = new NavigationEndpoint(data.toggledServiceEndpoint);
this.default_endpoint = new NavigationEndpoint(data.defaultServiceEndpoint);
this.toggled_endpoint = new NavigationEndpoint(data.toggledServiceEndpoint);
}
}

export default ToggleMenuServiceItem;
}
1 change: 1 addition & 0 deletions src/parser/classes/menus/MenuNavigationItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Button from '../Button.js';
import type { RawNode } from '../../index.js';

class MenuNavigationItem extends Button {
static type = 'MenuNavigationItem';

Expand Down

0 comments on commit a056696

Please sign in to comment.