Skip to content

Commit

Permalink
feat(parser): Update Button (#857)
Browse files Browse the repository at this point in the history
* Add `style` property
* Add `size` property
* Add `target_id` property
* Parse `data.accessibilityData.accessibilityData.label` if `data.accessibility.label` is unavailable
  • Loading branch information
jonz94 authored Dec 31, 2024
1 parent c631022 commit 5f899fc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/parser/classes/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,46 @@ export default class Button extends YTNode {
text?: string;
label?: string;
tooltip?: string;
style?: string;
size?: string;
icon_type?: string;
is_disabled?: boolean;
target_id?: string;
endpoint: NavigationEndpoint;

constructor(data: RawNode) {
super();
if (Reflect.has(data, 'text'))
this.text = new Text(data.text).toString();

if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'label'))
if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'label')) {
this.label = data.accessibility.label;
} else if (
Reflect.has(data, 'accessibilityData') &&
Reflect.has(data.accessibilityData, 'accessibilityData') &&
Reflect.has(data.accessibilityData.accessibilityData, 'label')
) {
this.label = data.accessibilityData.accessibilityData.label;
}

if (Reflect.has(data, 'tooltip'))
this.tooltip = data.tooltip;

if (Reflect.has(data, 'style'))
this.style = data.style;

if (Reflect.has(data, 'size'))
this.size = data.size;

if (Reflect.has(data, 'icon') && Reflect.has(data.icon, 'iconType'))
this.icon_type = data.icon.iconType;

if (Reflect.has(data, 'isDisabled'))
this.is_disabled = data.isDisabled;

if (Reflect.has(data, 'targetId'))
this.target_id = data.targetId;

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

0 comments on commit 5f899fc

Please sign in to comment.