Extract play_count and on_tour_link components
This commit is contained in:
@@ -14,6 +14,34 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
|||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr :lastfm_artist_info, :map, required: true
|
||||||
|
|
||||||
|
defp on_tour_link(assigns) do
|
||||||
|
~H"""
|
||||||
|
<a
|
||||||
|
:if={@lastfm_artist_info.on_tour}
|
||||||
|
class="flex items-center"
|
||||||
|
href={LastFm.Artist.events_url(@lastfm_artist_info)}
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<.badge variant="pill" class="mr-2">{gettext("On Tour")}</.badge>
|
||||||
|
</a>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
attr :play_count, :integer, required: true
|
||||||
|
|
||||||
|
defp play_count(assigns) do
|
||||||
|
~H"""
|
||||||
|
<span :if={@play_count > 0} class="text-xs font-medium text-zinc-700 dark:text-zinc-300 grow">
|
||||||
|
{ngettext("1 scrobble", "%{count} scrobbles", @play_count)}
|
||||||
|
</span>
|
||||||
|
<span :if={@play_count == 0} class="text-xs font-medium text-zinc-700 dark:text-zinc-300 grow">
|
||||||
|
{gettext("No scrobbles")}
|
||||||
|
</span>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(_params, _session, socket) do
|
def mount(_params, _session, socket) do
|
||||||
{:ok, socket}
|
{:ok, socket}
|
||||||
|
|||||||
@@ -22,26 +22,8 @@
|
|||||||
{gettext("Error loading play count")}
|
{gettext("Error loading play count")}
|
||||||
</div>
|
</div>
|
||||||
</:failed>
|
</:failed>
|
||||||
<a
|
<.on_tour_link lastfm_artist_info={lastfm_artist_info} />
|
||||||
:if={lastfm_artist_info.on_tour}
|
<.play_count play_count={lastfm_artist_info.play_count} />
|
||||||
class="flex items-center"
|
|
||||||
href={LastFm.Artist.events_url(lastfm_artist_info)}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<.badge variant="pill" class="mr-2">{gettext("On Tour")}</.badge>
|
|
||||||
</a>
|
|
||||||
<span
|
|
||||||
:if={lastfm_artist_info.play_count > 0}
|
|
||||||
class="text-xs font-medium text-zinc-700 dark:text-zinc-300 grow"
|
|
||||||
>
|
|
||||||
{ngettext("1 scrobble", "%{count} scrobbles", lastfm_artist_info.play_count)}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
:if={lastfm_artist_info.play_count == 0}
|
|
||||||
class="text-xs font-medium text-zinc-700 dark:text-zinc-300 grow"
|
|
||||||
>
|
|
||||||
{gettext("No scrobbles")}
|
|
||||||
</span>
|
|
||||||
</.async_result>
|
</.async_result>
|
||||||
<.button variant="solid" as="link" patch={~p"/artists/#{@artist.musicbrainz_id}/import"}>
|
<.button variant="solid" as="link" patch={~p"/artists/#{@artist.musicbrainz_id}/import"}>
|
||||||
<.icon name="hero-plus" class="h-4 w-4 mr-2" aria-hidden="true" data-slot="icon" />
|
<.icon name="hero-plus" class="h-4 w-4 mr-2" aria-hidden="true" data-slot="icon" />
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ msgstr ""
|
|||||||
msgid "Errors"
|
msgid "Errors"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/artist_live/show.html.heex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "On Tour"
|
msgid "On Tour"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -441,7 +441,7 @@ msgid_plural "%{count} records"
|
|||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/artist_live/show.html.heex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "1 scrobble"
|
msgid "1 scrobble"
|
||||||
msgid_plural "%{count} scrobbles"
|
msgid_plural "%{count} scrobbles"
|
||||||
@@ -692,7 +692,7 @@ msgstr ""
|
|||||||
msgid "Record wishlisted successfully"
|
msgid "Record wishlisted successfully"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/artist_live/show.html.heex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "No scrobbles"
|
msgid "No scrobbles"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ msgstr ""
|
|||||||
msgid "Errors"
|
msgid "Errors"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/artist_live/show.html.heex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "On Tour"
|
msgid "On Tour"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -441,7 +441,7 @@ msgid_plural "%{count} records"
|
|||||||
msgstr[0] ""
|
msgstr[0] ""
|
||||||
msgstr[1] ""
|
msgstr[1] ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/artist_live/show.html.heex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "1 scrobble"
|
msgid "1 scrobble"
|
||||||
msgid_plural "%{count} scrobbles"
|
msgid_plural "%{count} scrobbles"
|
||||||
@@ -692,7 +692,7 @@ msgstr ""
|
|||||||
msgid "Record wishlisted successfully"
|
msgid "Record wishlisted successfully"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/artist_live/show.html.heex
|
#: lib/music_library_web/live/artist_live/show.ex
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "No scrobbles"
|
msgid "No scrobbles"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user