Skip to content

Commit

Permalink
search lists
Browse files Browse the repository at this point in the history
  • Loading branch information
bocharovatd committed Dec 21, 2024
1 parent 9ed4f79 commit 1960d0e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/pages/search/ui/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class SearchPage {
}

const artistListView = new ArtistListView(this.pageContent);
await artistListView.render(artists);
await artistListView.render(artists, false, true);
}

async handleFoundAlbums(albums) {
Expand All @@ -86,7 +86,7 @@ export class SearchPage {
}

const albumListView = new AlbumListView(this.pageContent);
await albumListView.render(albums);
await albumListView.render(albums, false, true);
}

async handleFoundTracks(tracks) {
Expand All @@ -108,7 +108,7 @@ export class SearchPage {
return;
}

const trackListView = new TrackListView(this.pageContent);
const trackListView = new TrackListView(this.pageContent, { search: true });
await trackListView.render(tracks, false);
}

Expand Down
4 changes: 3 additions & 1 deletion src/widgets/albumList/ui/albumList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class AlbumListView {
/**
* Renders the album view.
*/
async render(albums, favorite = false) {
async render(albums, favorite = false, search = false) {
const albumListElement = document.createElement('div');
albumListElement.classList.add('albums');

Expand All @@ -30,6 +30,8 @@ export class AlbumListView {
titleText = "Альбомы исполнителя";
} else if (favorite) {
titleText = "Любимые альбомы";
} else if (search) {
titleText = "Альбомы";
} else {
titleText = "Популярные альбомы";
}
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/artistList/ui/artistList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export class ArtistListView {
/**
* Renders the playlist view.
*/
async render(artists, favorite = false) {
async render(artists, favorite = false, search = false) {
const artistListElement = document.createElement('div');
artistListElement.classList.add('artists');

let titleText;
if (favorite) {
titleText = "Любимые артисты";
} else if (search) {
titleText = "Артисты";
} else {
titleText = "Популярные артисты";
}
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/trackList/ui/trackList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class TrackListView {
this.albumId = args.albumId ?? null;
this.userID = args.userID ?? null;
this.favorite = args.favorite ?? null;
this.search = args.search ?? false;
this.myPlaylistId = args.myPlaylistId ?? false;
}

Expand Down Expand Up @@ -54,7 +55,9 @@ export class TrackListView {
} else if (this.favorite) {
showMoreHref = `/more_tracks/favorite/${this.userID}`;
titleText = "Любимые треки";
} else {
} else if (this.search) {
titleText = "Треки";
} else {
showMoreHref = `/more_tracks/popular`;
titleText = "Популярные треки";
}
Expand Down

0 comments on commit 1960d0e

Please sign in to comment.