diff --git a/app/assets/stylesheets/artist.css b/app/assets/stylesheets/artist.css index 93ac255..9492f5e 100644 --- a/app/assets/stylesheets/artist.css +++ b/app/assets/stylesheets/artist.css @@ -17,3 +17,7 @@ .artist-meta { @apply mt-2; } + +.artist--section-link { + @apply icon-btn text-small float-right; +} diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 990d6b4..55d3260 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -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) diff --git a/app/views/artists/_header.html.erb b/app/views/artists/_header.html.erb new file mode 100644 index 0000000..681dd18 --- /dev/null +++ b/app/views/artists/_header.html.erb @@ -0,0 +1,20 @@ +<%# locals: (artist:) -%> +
+
+ <% if artist.cover.attached? %> + <%= image_tag artist.cover %> + <% end %> +
+
+
+

<%= artist.name %>

+
+
+ <% artist.tags.each do |tag| %> + <%= tag %> + <% end %> +
+
+
+ +
diff --git a/app/views/artists/_tracks.html.erb b/app/views/artists/_tracks.html.erb new file mode 100644 index 0000000..5cfe9e5 --- /dev/null +++ b/app/views/artists/_tracks.html.erb @@ -0,0 +1,12 @@ +<%# locals: (artist:, tracks:, page: params[:page].to_i) -%> +<%= turbo_frame_tag dom_id(artist, :tracks) do %> + <% if tracks.any? %> + + <%= turbo_frame_tag dom_id(artist, :tracks), target: "_self", + loading: :lazy, src: tracks_artist_path(artist, page: page + 1) do %> + loading tracks... + <% end %> + <% end %> +<% end %> diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index f2443fc..a98d14b 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -1,24 +1,9 @@ -
-
- <% if artist.cover.attached? %> - <%= image_tag artist.cover %> - <% end %> -
-
-
-

<%= artist.name %>

-
-
- <% artist.tags.each do |tag| %> - <%= tag %> - <% end %> -
-
-
+<%= render partial: "header", locals: {artist:} %> -
+

Popular + <%= link_to "See all", tracks_artist_path(artist), class: "artist--section-link" %> +

-

Popular