From dcce3a72c792eda1a7214ce65572c465c9595a3a Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Thu, 2 Oct 2025 12:36:01 +0300 Subject: [PATCH] Move external links component to Core --- .../components/core_components.ex | 34 +++++++++++++++++++ .../live/artist_live/show.html.heex | 28 +-------------- priv/gettext/default.pot | 2 +- priv/gettext/en/LC_MESSAGES/default.po | 2 +- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/lib/music_library_web/components/core_components.ex b/lib/music_library_web/components/core_components.ex index 64fecfe6..cb47548c 100644 --- a/lib/music_library_web/components/core_components.ex +++ b/lib/music_library_web/components/core_components.ex @@ -136,6 +136,40 @@ defmodule MusicLibraryWeb.CoreComponents do """ end + attr :external_links, :list, default: [] + + def external_links(assigns) do + ~H""" +
+ {gettext("External links")} +
+
+ + {external_link.name} + + {external_link.name} + + +
+ """ + end + def favicon_url(url) do uri = URI.parse(url) "https://www.google.com/s2/favicons?domain=#{uri.host}&sz=16" diff --git a/lib/music_library_web/live/artist_live/show.html.heex b/lib/music_library_web/live/artist_live/show.html.heex index b8f8f392..bbb066c1 100644 --- a/lib/music_library_web/live/artist_live/show.html.heex +++ b/lib/music_library_web/live/artist_live/show.html.heex @@ -173,33 +173,7 @@ {render_bio(lastfm_artist_info.bio)} -
- {gettext("External links")} -
-
- <.button - :for={external_link <- @external_links} - href={external_link.url} - target="_blank" - rel="noopener noreferrer" - variant="ghost" - size="sm" - class="ml-2 first:ml-0" - > - {external_link.name} - - {external_link.name} - - -
+ <.external_links external_links={@external_links} />
<.record_grid diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 82afd4fb..fdee2503 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -1469,7 +1469,7 @@ msgstr "" msgid "You need to connect your Last.fm account to scrobble. Please set up your Last.fm session key in the settings." msgstr "" -#: lib/music_library_web/live/artist_live/show.html.heex +#: lib/music_library_web/components/core_components.ex #, elixir-autogen, elixir-format msgid "External links" msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index f82c4f44..d4941238 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -1469,7 +1469,7 @@ msgstr "" msgid "You need to connect your Last.fm account to scrobble. Please set up your Last.fm session key in the settings." msgstr "" -#: lib/music_library_web/live/artist_live/show.html.heex +#: lib/music_library_web/components/core_components.ex #, elixir-autogen, elixir-format msgid "External links" msgstr ""