From 167f1df8cb69fdb5d8486dbf0d00a960880ab9dc Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Wed, 4 Jun 2025 17:42:10 +0100 Subject: [PATCH] Extract artist_links/1 component --- .../components/record_components.ex | 31 ++++++++++++------- .../live/collection_live/show.ex | 3 +- .../live/collection_live/show.html.heex | 12 +------ .../live/wishlist_live/show.ex | 3 +- .../live/wishlist_live/show.html.heex | 12 +------ 5 files changed, 26 insertions(+), 35 deletions(-) diff --git a/lib/music_library_web/components/record_components.ex b/lib/music_library_web/components/record_components.ex index 92668612..29e88832 100644 --- a/lib/music_library_web/components/record_components.ex +++ b/lib/music_library_web/components/record_components.ex @@ -5,6 +5,25 @@ defmodule MusicLibraryWeb.RecordComponents do alias MusicLibrary.Records alias Phoenix.LiveView.JS + attr :artists, :list, required: true + attr :joinphrase_class, :string, default: nil + + def artist_links(assigns) do + ~H""" + + <.link + class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300" + navigate={~p"/artists/#{artist.musicbrainz_id}"} + > + {artist.name} + + + {artist.joinphrase} + + + """ + end + attr :record_show_path, :any, required: true attr :record_edit_path, :any, required: true attr :records, :list, required: true @@ -46,17 +65,7 @@ defmodule MusicLibraryWeb.RecordComponents do

- - <.link - class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300" - navigate={~p"/artists/#{artist.musicbrainz_id}"} - > - {artist.name} - - - {artist.joinphrase} - - + <.artist_links joinphrase_class="text-xs" artists={record.artists} />

{record.title} diff --git a/lib/music_library_web/live/collection_live/show.ex b/lib/music_library_web/live/collection_live/show.ex index 32b3d3b7..41801c79 100644 --- a/lib/music_library_web/live/collection_live/show.ex +++ b/lib/music_library_web/live/collection_live/show.ex @@ -7,7 +7,8 @@ defmodule MusicLibraryWeb.CollectionLive.Show do only: [ format_label: 1, type_label: 1, - release_summary: 1 + release_summary: 1, + artist_links: 1 ] alias MusicLibrary.{Records, ScrobbleActivity} diff --git a/lib/music_library_web/live/collection_live/show.html.heex b/lib/music_library_web/live/collection_live/show.html.heex index 902eb7e2..7fc6c29e 100644 --- a/lib/music_library_web/live/collection_live/show.html.heex +++ b/lib/music_library_web/live/collection_live/show.html.heex @@ -11,17 +11,7 @@

- - <.link - class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300" - navigate={~p"/artists/#{artist.musicbrainz_id}"} - > - {artist.name} - - - {artist.joinphrase} - - + <.artist_links joinphrase_class="text-sm" artists={@record.artists} />

{@record.title} diff --git a/lib/music_library_web/live/wishlist_live/show.ex b/lib/music_library_web/live/wishlist_live/show.ex index dafbc8bc..6734a8d4 100644 --- a/lib/music_library_web/live/wishlist_live/show.ex +++ b/lib/music_library_web/live/wishlist_live/show.ex @@ -5,7 +5,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do only: [ format_label: 1, type_label: 1, - release_summary: 1 + release_summary: 1, + artist_links: 1 ] alias MusicLibrary.Records diff --git a/lib/music_library_web/live/wishlist_live/show.html.heex b/lib/music_library_web/live/wishlist_live/show.html.heex index d8b6d904..6dc8642c 100644 --- a/lib/music_library_web/live/wishlist_live/show.html.heex +++ b/lib/music_library_web/live/wishlist_live/show.html.heex @@ -11,17 +11,7 @@

- - <.link - class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300" - navigate={~p"/artists/#{artist.musicbrainz_id}"} - > - {artist.name} - - - {artist.joinphrase} - - + <.artist_links joinphrase_class="text-sm" artists={@record.artists} />

{@record.title}