Browse Source

improvement: nicer album overview

pull/48/head
Inhji Y. 11 months ago
parent
commit
76da2ba59c
4 changed files with 21 additions and 53 deletions
  1. +1
    -1
      apps/listens/lib/listens/albums.ex
  2. +1
    -1
      apps/tomie_web/lib/tomie_web/live/listen_live/albums.ex
  3. +18
    -50
      apps/tomie_web/lib/tomie_web/templates/listen/albums.html.leex
  4. +1
    -1
      apps/tomie_web/lib/tomie_web/templates/listen/artists.html.leex

+ 1
- 1
apps/listens/lib/listens/albums.ex View File

@ -16,7 +16,7 @@ defmodule Listens.Albums do
def list_newest_albums do
Album
|> order_by(desc: :inserted_at)
|> limit(5)
|> limit(6)
|> Db.Repo.all()
|> Db.Repo.preload([:listens, :artist])
end


+ 1
- 1
apps/tomie_web/lib/tomie_web/live/listen_live/albums.ex View File

@ -9,7 +9,7 @@ defmodule TomieWeb.ListenLive.Albums do
def fetch(),
do: [
top: Listens.Report.top(Listens.Albums.Album, 5, [weeks: -2], preloads: [:artist]),
top: Listens.Report.top(Listens.Albums.Album, 6, [weeks: -2], preloads: [:artist]),
newest: Listens.Albums.list_newest_albums()
]
end

+ 18
- 50
apps/tomie_web/lib/tomie_web/templates/listen/albums.html.leex View File

@ -2,62 +2,30 @@
<%= live_component @socket, TomieWeb.ListenLive.SidebarComponent %>
<div class="col-span-4">
<h1>Top Albums in the last 2 Weeks</h1>
<h1>Top Albums</h1>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 mb-10">
<%= for item <- @albums[:top] do %>
<div class="card">
<div class="flex">
<div class="image w-20 md:w-32">
<img src="<%= Listens.Albums.get_album_image(item.model, :large) %>" class="w-full">
</div>
<div class="content">
<h3><%= item.model.name %></h3>
<p class="text-on-surface-muted">
<span class="icon">
<%= IconView.icon(:user) %>
</span>
<%= live_patch item.model.artist.name,
class: "hover:underline",
to: Routes.live_path(@socket, TomieWeb.ArtistLive.Show, item.model.artist) %>
</p>
<p class="text-on-surface-muted">
<span class="icon">
<%= IconView.icon(:music) %>
</span>
<%= item.listens %> Listens
</p>
</div>
</div>
<div class="relative">
<img src="<%= Listens.Albums.get_album_image(item.model, :large) %>" class="w-full">
<span class="absolute top-0 left-0 m-1 p-1 bg-surface-alt text-center rounded">
<%= item.listens %>
</span>
</div>
<% end %>
</div>
<h1>Newest Albums in the last 2 Weeks</h1>
<h1>Newest Albums</h1>
<%= for album <- @albums[:newest] do %>
<div class="card">
<div class="flex">
<div class="image w-20 md:w-32">
<img src="<%= Listens.Albums.get_album_image(album, :large) %>" class="w-full">
</div>
<div class="content">
<h3><%= album.name %></h3>
<p class="text-on-surface-muted">
<span class="icon">
<%= IconView.icon(:user) %>
</span>
<%= live_patch album.artist.name,
class: "hover:underline",
to: Routes.live_path(@socket, TomieWeb.ArtistLive.Show, album.artist) %>
</p>
<p class="text-on-surface-muted">
<span class="icon">
<%= IconView.icon(:music) %>
</span>
<%= Enum.count(album.listens) %> Listens
</p>
</div>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6">
<%= for album <- @albums[:newest] do %>
<div class="relative">
<img src="<%= Listens.Albums.get_album_image(album, :large) %>">
<span class="absolute top-0 left-0 bg-surface-alt p-1 text-center">
<%= album.name %>
</span>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>

+ 1
- 1
apps/tomie_web/lib/tomie_web/templates/listen/artists.html.leex View File

@ -4,7 +4,7 @@
<div class="col-span-4">
<h1>Top Artists</h1>
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6">
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 mb-10">
<%= for item <- @artists[:top] do %>
<div class="relative">
<img src="<%= Listens.Artists.get_artist_image(item.model, :large) %>">


Loading…
Cancel
Save