-
-
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.
feat(parser): add
MusicCardShelf
(#358)
- Loading branch information
Showing
4 changed files
with
72 additions
and
5 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,48 @@ | ||
import { ObservedArray, YTNode } from '../helpers.js'; | ||
import Parser, { RawNode } from '../index.js'; | ||
import Button from './Button.js'; | ||
import Menu from './menus/Menu.js'; | ||
import Text from './misc/Text.js'; | ||
import MusicCardShelfHeaderBasic from './MusicCardShelfHeaderBasic.js'; | ||
import MusicInlineBadge from './MusicInlineBadge.js'; | ||
import MusicItemThumbnailOverlay from './MusicItemThumbnailOverlay.js'; | ||
import MusicThumbnail from './MusicThumbnail.js'; | ||
import NavigationEndpoint from './NavigationEndpoint.js'; | ||
|
||
export default class MusicCardShelf extends YTNode { | ||
static type = 'MusicCardShelf'; | ||
|
||
thumbnail: MusicThumbnail | null; | ||
title: Text; | ||
subtitle: Text; | ||
buttons: ObservedArray<Button> | null; | ||
menu: Menu | null; | ||
on_tap: NavigationEndpoint; | ||
header: MusicCardShelfHeaderBasic | null; | ||
end_icon_type?: string; | ||
subtitle_badges: ObservedArray<MusicInlineBadge>; | ||
thumbnail_overlay: MusicItemThumbnailOverlay | null; | ||
contents?: ObservedArray<YTNode> | null; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.thumbnail = Parser.parseItem(data.thumbnail, MusicThumbnail); | ||
this.title = new Text(data.title); | ||
this.subtitle = new Text(data.subtitle); | ||
this.buttons = Parser.parseArray(data.buttons, Button); | ||
this.menu = Parser.parseItem(data.menu, Menu); | ||
this.on_tap = new NavigationEndpoint(data.onTap); | ||
this.header = Parser.parseItem(data.header, MusicCardShelfHeaderBasic); | ||
|
||
if (Reflect.has(data, 'endIcon') && Reflect.has(data.endIcon, 'iconType')) { | ||
this.end_icon_type = data.endIcon.iconType; | ||
} | ||
|
||
this.subtitle_badges = Parser.parseArray(data.subtitleBadges, MusicInlineBadge); | ||
this.thumbnail_overlay = Parser.parseItem(data.thumbnailOverlay, MusicItemThumbnailOverlay); | ||
|
||
if (Reflect.has(data, 'contents')) { | ||
this.contents = Parser.parseArray(data.contents); | ||
} | ||
} | ||
} |
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,14 @@ | ||
import { YTNode } from '../helpers.js'; | ||
import { RawNode } from '../index.js'; | ||
import Text from './misc/Text.js'; | ||
|
||
export default class MusicCardShelfHeaderBasic extends YTNode { | ||
static type = 'MusicCardShelfHeaderBasic'; | ||
|
||
title: Text; | ||
|
||
constructor(data: RawNode) { | ||
super(); | ||
this.title = new Text(data.title); | ||
} | ||
} |
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