Show tooltip with raw count

This commit is contained in:
Claudio Ortolina
2025-09-02 09:00:05 +03:00
parent 7532431ae0
commit 41600df226
2 changed files with 25 additions and 3 deletions
@@ -49,6 +49,7 @@ defmodule MusicLibraryWeb.StatsComponents do
attr :title, :string, required: true attr :title, :string, required: true
attr :count, :integer, required: true attr :count, :integer, required: true
attr :path, :string, required: false, default: nil attr :path, :string, required: false, default: nil
attr :tooltip, :any, required: false, default: nil
def counter(assigns) do def counter(assigns) do
~H""" ~H"""
@@ -58,7 +59,7 @@ defmodule MusicLibraryWeb.StatsComponents do
{@title} {@title}
</p> </p>
</dt> </dt>
<dd class="mt-1"> <dd :if={!@tooltip} class="mt-1">
<.link <.link
:if={@path} :if={@path}
navigate={@path} navigate={@path}
@@ -68,11 +69,28 @@ defmodule MusicLibraryWeb.StatsComponents do
</.link> </.link>
<p <p
:if={!@path} :if={!@path}
class="block text-2xl sm:text-3xl font-semibold text-center text-zinc-900 dark:text-zinc-300" class="block cursor-default text-2xl sm:text-3xl font-semibold text-center text-zinc-900 dark:text-zinc-300"
> >
{@count} {@count}
</p> </p>
</dd> </dd>
<dd :if={@tooltip} class="mt-1">
<.tooltip value={@tooltip}>
<.link
:if={@path}
navigate={@path}
class="block text-2xl sm:text-3xl font-semibold text-center text-zinc-900 hover:text-zinc-500 dark:text-zinc-300 dark:hover:text-zinc-200"
>
{@count}
</.link>
<p
:if={!@path}
class="block cursor-default text-2xl sm:text-3xl font-semibold text-center text-zinc-900 dark:text-zinc-300"
>
{@count}
</p>
</.tooltip>
</dd>
</div> </div>
""" """
end end
@@ -15,7 +15,11 @@
path={~p"/collection"} path={~p"/collection"}
/> />
<.counter title={gettext("Total wishlist")} count={@wishlist_count} path={~p"/wishlist"} /> <.counter title={gettext("Total wishlist")} count={@wishlist_count} path={~p"/wishlist"} />
<.counter title={gettext("Total scrobbles")} count={to_compact(@scrobble_count)} /> <.counter
title={gettext("Total scrobbles")}
count={to_compact(@scrobble_count)}
tooltip={@scrobble_count}
/>
</dl> </dl>
</div> </div>