From 6b9ebf6d6ea496ff01ed566e7a862beebf587d98 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Wed, 30 Oct 2024 08:42:14 +0000 Subject: [PATCH] Extract counter stat component --- .../live/stats_live/data_components.ex | 24 ++++++++++++++ .../live/stats_live/index.html.heex | 32 ++----------------- priv/gettext/default.pot | 8 ++--- 3 files changed, 30 insertions(+), 34 deletions(-) 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 e0bfa049..cac29d98 100644 --- a/lib/music_library_web/live/stats_live/data_components.ex +++ b/lib/music_library_web/live/stats_live/data_components.ex @@ -39,4 +39,28 @@ defmodule MusicLibraryWeb.StatsLive.DataComponents do """ end + + attr :title, :string, required: true + attr :count, :integer, required: true + attr :path, :string, required: true + + def counter(assigns) do + ~H""" +
+
+

+ <%= @title %> +

+
+
+ + <%= @count %> + +
+
+ """ + 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 f08699bb..dc042ee8 100644 --- a/lib/music_library_web/live/stats_live/index.html.heex +++ b/lib/music_library_web/live/stats_live/index.html.heex @@ -32,36 +32,8 @@

-
-
-

- <%= gettext("Total collection") %> -

-
-
- - <%= @collection_count %> - -
-
-
-
-

- <%= gettext("Total wishlist") %> -

-
-
- - <%= @wishlist_count %> - -
-
+ <.counter title={gettext("Total collection")} count={@collection_count} path={~p"/records"} /> + <.counter title={gettext("Total wishlist")} count={@wishlist_count} path={~p"/wishlist"} /> diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 930ecf92..2b85fbce 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -97,7 +97,7 @@ msgstr "" msgid "Format" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:70 +#: lib/music_library_web/live/stats_live/index.html.heex:42 #, elixir-autogen, elixir-format msgid "Formats" msgstr "" @@ -287,12 +287,12 @@ msgstr "" msgid "The application has been updated, please reload." msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:38 +#: lib/music_library_web/live/stats_live/index.html.heex:35 #, elixir-autogen, elixir-format msgid "Total collection" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:53 +#: lib/music_library_web/live/stats_live/index.html.heex:36 #, elixir-autogen, elixir-format msgid "Total wishlist" msgstr "" @@ -302,7 +302,7 @@ msgstr "" msgid "Type" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:74 +#: lib/music_library_web/live/stats_live/index.html.heex:46 #, elixir-autogen, elixir-format msgid "Types" msgstr ""