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 b8692722..6d559552 100644 --- a/lib/music_library_web/live/stats_live/data_components.ex +++ b/lib/music_library_web/live/stats_live/data_components.ex @@ -42,45 +42,6 @@ defmodule MusicLibraryWeb.StatsLive.DataComponents do """ end - attr :data, :list, - required: true, - doc: """ - A list of tuples, where the first element is label and the second is the count. - """ - - attr :title, :string, required: true - attr :col_class, :string - - def stats_grid(assigns) do - ~H""" -
-

- <%= @title %> -

-
-
-
- <%= format %> -
-
- - <%= count %> - -
-
-
-
- """ - end - attr :title, :string, required: true attr :count, :integer, required: true attr :path, :string, required: true diff --git a/lib/music_library_web/live/stats_live/index.ex b/lib/music_library_web/live/stats_live/index.ex index e52e11cf..0cbe483c 100644 --- a/lib/music_library_web/live/stats_live/index.ex +++ b/lib/music_library_web/live/stats_live/index.ex @@ -9,12 +9,10 @@ defmodule MusicLibraryWeb.StatsLive.Index do def mount(_params, _session, socket) do collection_count_by_format = Records.count_records_by_format() - |> Enum.map(fn {format, count} -> {Record.format_long_label(format), count} end) |> Enum.sort_by(fn {_format, count} -> count end, :desc) collection_count_by_type = Records.count_records_by_type() - |> Enum.map(fn {type, count} -> {Record.type_long_label(type), count} end) |> Enum.sort_by(fn {_type, count} -> count end, :desc) collection_count = 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 5abb7225..7e3fb870 100644 --- a/lib/music_library_web/live/stats_live/index.html.heex +++ b/lib/music_library_web/live/stats_live/index.html.heex @@ -13,10 +13,44 @@ -<.stats_grid - data={@collection_count_by_format} - title={gettext("Formats")} - col_class="grid-cols-5" -/> +
+

+ <%= gettext("Formats") %> +

+
+
+
+ <%= Record.format_long_label(format) %> +
+
+ + <%= count %> + +
+
+
+
-<.stats_grid data={@collection_count_by_type} title={gettext("Types")} col_class="grid-cols-6" /> +
+

+ <%= gettext("Types") %> +

+
+
+
+ <%= Record.type_long_label(type) %> +
+
+ + <%= count %> + +
+
+
+
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 1b386b5f..2fc139eb 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -269,7 +269,7 @@ msgid "Something went wrong!" msgstr "" #: lib/music_library_web/components/layouts/app.html.heex:7 -#: lib/music_library_web/live/stats_live/index.ex:30 +#: lib/music_library_web/live/stats_live/index.ex:28 #, elixir-autogen, elixir-format msgid "Stats" msgstr "" @@ -302,7 +302,7 @@ msgstr "" msgid "Type" msgstr "" -#: lib/music_library_web/live/stats_live/index.html.heex:22 +#: lib/music_library_web/live/stats_live/index.html.heex:39 #, elixir-autogen, elixir-format msgid "Types" msgstr "" diff --git a/test/music_library_web/live/stats_index_test.exs b/test/music_library_web/live/stats_index_test.exs index 96760031..98d08ae5 100644 --- a/test/music_library_web/live/stats_index_test.exs +++ b/test/music_library_web/live/stats_index_test.exs @@ -35,15 +35,15 @@ defmodule MusicLibraryWeb.StatsIndexTest do collection |> Enum.frequencies_by(& &1.format) |> Enum.each(fn {format, count} -> - assert html =~ "#{count}\n" - assert html =~ "#{Record.format_long_label(format)}\n" + assert html =~ "\n#{count}\n" + assert html =~ "\n#{Record.format_long_label(format)}\n" end) collection |> Enum.frequencies_by(& &1.type) |> Enum.each(fn {type, count} -> - assert html =~ "#{count}\n" - assert html =~ "#{Record.type_long_label(type)}\n" + assert html =~ "\n#{count}\n" + assert html =~ "\n#{Record.type_long_label(type)}\n" end) end