diff --git a/lib/music_library_web/live/stats_live/data_components.ex b/lib/music_library_web/live/stats_live/data_components.ex index 5aae9624..f2c96965 100644 --- a/lib/music_library_web/live/stats_live/data_components.ex +++ b/lib/music_library_web/live/stats_live/data_components.ex @@ -65,4 +65,53 @@ defmodule MusicLibraryWeb.StatsLive.DataComponents do """ end + + attr :color, :atom, values: [:green, :yellow, :gray], required: true + attr :text, :string, required: true + + def badge(assigns) do + case assigns.color do + :green -> + ~H""" + + {@text} + + """ + + :yellow -> + ~H""" + + {@text} + + """ + + :gray -> + ~H""" + + {@text} + + """ + end + end end diff --git a/lib/music_library_web/live/stats_live/index.html.heex b/lib/music_library_web/live/stats_live/index.html.heex index 53967ce1..3521790f 100644 --- a/lib/music_library_web/live/stats_live/index.html.heex +++ b/lib/music_library_web/live/stats_live/index.html.heex @@ -129,48 +129,22 @@
- - {gettext("No MB ID")} - + color={:gray} + text={gettext("No MB ID")} + /> <.link :if={record_id = tracked_record?(@collected_releases, track.album.musicbrainz_id)} navigate={~p"/collection/#{record_id}"} > - - {gettext("Collected")} - + <.badge color={:green} text={gettext("Collected")} /> <.link :if={record_id = tracked_record?(@wishlisted_releases, track.album.musicbrainz_id)} navigate={~p"/wishlist/#{record_id}"} > - - {gettext("Wishlisted")} - + <.badge color={:yellow} text={gettext("Wishlisted")} />
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 52fc35fb..fd498923 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -342,17 +342,17 @@ msgid "Scrobble activity" msgstr "" #: lib/music_library_web/live/record_live/import_component.ex:80 -#: lib/music_library_web/live/stats_live/index.html.heex:193 +#: lib/music_library_web/live/stats_live/index.html.heex:167 #, elixir-autogen, elixir-format msgid "Choose which format to import" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:157 +#: lib/music_library_web/live/stats_live/index.html.heex:141 #, elixir-autogen, elixir-format msgid "Collected" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:172 +#: lib/music_library_web/live/stats_live/index.html.heex:147 #, elixir-autogen, elixir-format msgid "Wishlisted" msgstr "" @@ -402,7 +402,7 @@ msgstr "" msgid "Error refreshing cover" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:143 +#: lib/music_library_web/live/stats_live/index.html.heex:135 #, elixir-autogen, elixir-format msgid "No MB ID" msgstr ""