Add similar records
Initial stab by Claude
This commit is contained in:
@@ -385,4 +385,56 @@ defmodule MusicLibraryWeb.RecordComponents do
|
||||
</span>
|
||||
"""
|
||||
end
|
||||
|
||||
attr :similar_records, :list, required: true
|
||||
attr :record_show_path, :any, required: true
|
||||
attr :section, :atom, required: true
|
||||
|
||||
def similar_records(assigns) do
|
||||
~H"""
|
||||
<div :if={@similar_records != []} class="mt-8 px-4">
|
||||
<header class="flex items-baseline justify-start">
|
||||
<h2 class="font-semibold text-base sm:text-lg leading-5 text-zinc-700 dark:text-zinc-300">
|
||||
{gettext("Similar Records")}
|
||||
</h2>
|
||||
<span class="ml-2 text-xs font-normal text-zinc-500 dark:text-zinc-400">
|
||||
{gettext("Based on genres, artists, and release year")}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<ul
|
||||
role="list"
|
||||
class="mt-4 grid grid-cols-2 gap-x-4 gap-y-6 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 sm:gap-x-6"
|
||||
>
|
||||
<li :for={{record, similarity} <- @similar_records} class="relative group">
|
||||
<div class="overflow-hidden rounded-lg bg-zinc-100 focus-within:ring-2 focus-within:ring-zinc-500 focus-within:ring-offset-2 focus-within:ring-offset-zinc-100">
|
||||
<.record_cover
|
||||
record={record}
|
||||
class="pointer-events-none aspect-square object-cover group-hover:opacity-75 transition-opacity"
|
||||
width={300}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 focus:outline-hidden"
|
||||
phx-click={JS.navigate(@record_show_path.(record))}
|
||||
>
|
||||
<span class="sr-only">{gettext("View details")}</span>
|
||||
</button>
|
||||
|
||||
<span class="absolute top-2 right-2 rounded-full px-2 py-0.5 text-xs font-medium bg-zinc-900/75 text-white backdrop-blur-sm">
|
||||
{Float.round(similarity * 100, 0)}%
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="pointer-events-none mt-2 block truncate text-sm font-medium text-zinc-900 dark:text-zinc-300">
|
||||
{record.title}
|
||||
</p>
|
||||
<p class="pointer-events-none block truncate text-xs text-zinc-500 dark:text-zinc-400">
|
||||
{Records.Record.artist_names(record)}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user