Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/assets/stylesheets/artist.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
.artist-meta {
@apply mt-2;
}

.artist--section-link {
@apply icon-btn text-small float-right;
}
11 changes: 11 additions & 0 deletions app/controllers/artists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ def show
end
end

def tracks
artist = Artist.find(params[:id])
page = params[:page].to_i
tracks = artist.tracks.popularity_ordered.offset(page * 10).limit(10)
if turbo_frame_request?
render partial: "tracks", locals: {artist:, tracks:, page:}
else
render locals: {artist:, tracks:}
end
end

private

def selected_albums(albums, album_type)
Expand Down
20 changes: 20 additions & 0 deletions app/views/artists/_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%# locals: (artist:) -%>
<div class="artist-header">
<div class="artist-image">
<% if artist.cover.attached? %>
<%= image_tag artist.cover %>
<% end %>
</div>
<div class="artist-info">
<div class="flex items-center">
<h1 class="text-header-2"><%= artist.name %></h1>
</div>
<div>
<% artist.tags.each do |tag| %>
<span class="meta"><%= tag %></span>
<% end %>
</div>
</div>
</div>

<hr class="my-4">
12 changes: 12 additions & 0 deletions app/views/artists/_tracks.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%# locals: (artist:, tracks:, page: params[:page].to_i) -%>
<%= turbo_frame_tag dom_id(artist, :tracks) do %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется, тут не хватает target — что будет с кликом по треку?

<% if tracks.any? %>
<ul class="tracks">
<%= render tracks, enqueueble: true, offset: page * 10 %>
</ul>
<%= turbo_frame_tag dom_id(artist, :tracks), target: "_self",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Интересная идея с target: "_self", но тот же вопрос про клики по трекам остается. Можно, конечно, представить, что мы их уже переделали на стримы.. Но сейчас явно будет глючить.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дааа. из-за target-ов глючит нещадно! Действительно, клики... Попробую на досуге доработать, кажется, что тут еще надо подумать, как упаковать фреймы.

loading: :lazy, src: tracks_artist_path(artist, page: page + 1) do %>
loading tracks...
<% end %>
<% end %>
<% end %>
23 changes: 4 additions & 19 deletions app/views/artists/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
<div class="artist-header">
<div class="artist-image">
<% if artist.cover.attached? %>
<%= image_tag artist.cover %>
<% end %>
</div>
<div class="artist-info">
<div class="flex items-center">
<h1 class="text-header-2"><%= artist.name %></h1>
</div>
<div>
<% artist.tags.each do |tag| %>
<span class="meta"><%= tag %></span>
<% end %>
</div>
</div>
</div>
<%= render partial: "header", locals: {artist:} %>

<hr class="my-4">
<h2 class="mt-4 text-header-2">Popular
<%= link_to "See all", tracks_artist_path(artist), class: "artist--section-link" %>
</h2>

<h2 class="mt-4 text-header-2">Popular</h2>
<ul class="tracks mt-2">
<%= render tracks, enqueueble: true %>
<li class="track">
Expand Down
5 changes: 5 additions & 0 deletions app/views/artists/tracks.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%= render partial: "header", locals: {artist:} %>

<h2 class="mt-4 mb-2 text-header-2">Tracks</h2>

<%= render "tracks", artist:, tracks:, page: 0 %>
4 changes: 2 additions & 2 deletions app/views/tracks/_track.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<%# locals: (track:, track_counter: nil, track_iteration: nil, deletable: false, enqueueble: false) -%>
<%# locals: (track:, track_counter: nil, track_iteration: nil, deletable: false, enqueueble: false, offset: 0) -%>
<li class="track">
<span class="track--number">
<% if track.id == current_track&.id %>
<span class="track--number--text track--playing-indicator"></span>
<% else %>
<%= track_counter + 1 %>
<%= offset + track_counter + 1 %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

<% end %>
</span>
<% if current_user&.live_station&.live? %>
Expand Down
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
post "sign_up", to: "registrations#create"
delete "sign_out", to: "sessions#destroy", as: :sign_out

resources :artists, only: [:show]
resources :artists, only: [:show] do
get :tracks, on: :member
end

resources :albums, only: [:show] do
patch :play, on: :member
end
Expand Down