Normalize display of artist names

This commit is contained in:
Claudio Ortolina
2024-10-07 14:57:30 +01:00
parent 764c4cebb3
commit ddbda5b4d2
7 changed files with 14 additions and 3 deletions
+7
View File
@@ -0,0 +1,7 @@
defmodule MusicLibraryWeb.ArtistHelpers do
def format_artist_names(artists) do
artists
|> Enum.map(fn a -> a.name end)
|> Enum.join(", ")
end
end
@@ -1,6 +1,8 @@
defmodule MusicLibraryWeb.StatsHTML do
use MusicLibraryWeb, :html
import MusicLibraryWeb.ArtistHelpers
alias MusicLibrary.Records.Record
embed_templates "stats_html/*"
@@ -48,7 +48,7 @@
<dd class="ml-16 flex items-baseline pb-6 sm:pb-7">
<p class="font-semibold">
<span class="text-2xl text-gray-900">
<%= Enum.map(@latest_record.artists, fn a -> a.name end) %>
<%= format_artist_names(@latest_record.artists) %>
</span>
<span class="text-gray-600"><%= @latest_record.title %></span>
</p>
@@ -1,6 +1,7 @@
defmodule MusicLibraryWeb.RecordLive.Index do
use MusicLibraryWeb, :live_view
import MusicLibraryWeb.Pagination
import MusicLibraryWeb.ArtistHelpers
alias MusicLibrary.Records
@@ -36,7 +36,7 @@
</span>
</:col>
<:col :let={{_id, record}}>
<p class="text-sm max-sm:text-xs"><%= Enum.map(record.artists, fn a -> a.name end) %></p>
<p class="text-sm max-sm:text-xs"><%= format_artist_names(record.artists) %></p>
<p class="text-base font-semibold text-wrap max-sm:text-xs"><%= record.title %></p>
<p class="text-sm max-sm:text-xs"><%= record.release %></p>
</:col>
@@ -1,5 +1,6 @@
defmodule MusicLibraryWeb.RecordLive.Show do
use MusicLibraryWeb, :live_view
import MusicLibraryWeb.ArtistHelpers
alias MusicLibrary.Records
@@ -1,6 +1,6 @@
<.header>
<%= @record.title %>
<:subtitle><%= Enum.map(@record.artists, fn a -> a.name end) %></:subtitle>
<:subtitle><%= format_artist_names(@record.artists) %></:subtitle>
<:actions>
<.link patch={~p"/records/#{@record}/show/edit"} phx-click={JS.push_focus()}>
<.button>Edit Metadata</.button>