-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fear(parser): Add
DecoratedAvatarView
(#544)
* Add DecoratedAvatarView * Export the class * Update PageHeaderView * Adjust thumbnails * Add avatar view * Apply suggestions from code review --------- Co-authored-by: absidue <[email protected]>
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { type RawNode } from '../index.js'; | ||
import { Thumbnail } from '../misc.js'; | ||
|
||
export default class AvatarView extends YTNode { | ||
static type = 'AvatarView'; | ||
|
||
image: { | ||
sources: Thumbnail[], | ||
processor: { | ||
border_image_processor: { | ||
circular: boolean | ||
} | ||
} | ||
}; | ||
avatar_image_size: string; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.image = { | ||
sources: data.image.sources.map((x: any) => new Thumbnail(x)).sort((a: Thumbnail, b: Thumbnail) => b.width - a.width), | ||
processor: { | ||
border_image_processor: { | ||
circular: data.image.processor.borderImageProcessor.circular | ||
} | ||
} | ||
}; | ||
this.avatar_image_size = data.avatarImageSize; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import type { RawNode } from '../index.js'; | ||
import NavigationEndpoint from './NavigationEndpoint.js'; | ||
import AvatarView from './AvatarView.js'; | ||
|
||
export default class DecoratedAvatarView extends YTNode { | ||
static type = 'DecoratedAvatarView'; | ||
|
||
avatar: AvatarView; | ||
a11y_label: string; | ||
on_tap_endpoint: NavigationEndpoint; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.avatar = new AvatarView(data.avatar.avatarViewModel); | ||
this.a11y_label = data.a11yLabel; | ||
this.on_tap_endpoint = new NavigationEndpoint(data.rendererContext.commandContext.onTap.innertubeCommand); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters