Extract round badge component

This commit is contained in:
Claudio Ortolina
2025-01-01 21:11:44 +00:00
parent 69e71191b0
commit 0ce5326236
3 changed files with 33 additions and 31 deletions
@@ -621,6 +621,26 @@ defmodule MusicLibraryWeb.CoreComponents do
"""
end
@doc """
Renders a round badge.
"""
attr :text, :string, required: true
def round_badge(assigns) do
~H"""
<span class={[
"inline-flex items-center rounded-full",
"px-2 py-1 text-xs font-medium",
"ring-1 ring-inset",
"bg-gray-50 dark:bg-gray-400/10",
"text-gray-600 dark:text-gray-500",
"ring-gray-500/10 dark:ring-gray-400/20"
]}>
{assigns.text}
</span>
"""
end
## JS Commands
def show(js \\ %JS{}, selector) do
@@ -53,16 +53,7 @@ defmodule MusicLibraryWeb.RecordComponents do
<span class="sr-only">
{gettext("Number of included records")}
</span>
<span class={[
"inline-flex items-center rounded-full",
"px-2 py-1 text-xs font-medium",
"ring-1 ring-inset",
"bg-gray-50 dark:bg-gray-400/10",
"text-gray-600 dark:text-gray-500",
"ring-gray-500/10 dark:ring-gray-400/20"
]}>
{Records.Record.child_release_groups_count(record)}
</span>
<.round_badge text={Records.Record.child_release_groups_count(record)} />
</span>
<span :if={record.purchased_at}>
·
@@ -91,16 +82,7 @@ defmodule MusicLibraryWeb.RecordComponents do
<span class="sr-only">
{gettext("Number of included records")}
</span>
<span class={[
"inline-flex items-center rounded-full",
"px-2 py-1 text-xs font-medium",
"ring-1 ring-inset",
"bg-gray-50 dark:bg-gray-400/10",
"text-gray-600 dark:text-gray-500",
"ring-gray-500/10 dark:ring-gray-400/20"
]}>
{Records.Record.child_release_groups_count(record)}
</span>
<.round_badge text={Records.Record.child_release_groups_count(record)} />
</span>
</p>
<p :if={record.purchased_at} class="text-xs leading-6 text-zinc-900 dark:text-zinc-300">