defmodule MusicLibraryWeb.StatsComponents do
use MusicLibraryWeb, :live_component
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1, artist_links: 1]
alias MusicLibrary.Records
attr :record, Records.Record, required: true
attr :title, :string, required: true
attr :class, :string
def album_preview(assigns) do
~H"""
{@title}
{@record.title}
<.link
:for={artist <- @record.artists}
class="text-sm md:text-base text-zinc-600 dark:text-zinc-200 hover:text-zinc-500 dark:text-zinc-300 dark:hover:text-zinc-200"
navigate={~p"/artists/#{artist.musicbrainz_id}"}
>
{artist.name}
"""
end
attr :title, :string, required: true
attr :count, :integer, required: true
attr :path, :string, required: true
def counter(assigns) do
~H"""
{@title}
<.link
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}
"""
end
def refresh_lastfm_feed_button(assigns) do
~H"""
{gettext("Refresh LastFm Feed")}
<.icon name="hero-arrow-path" class="-mt-1 h-5 w-5" aria-hidden="true" data-slot="icon" />
"""
end
attr :record_show_path, :any, required: true
attr :records, :list, required: true
attr :current_date, Date, required: false, default: nil
def records_on_this_day(assigns) do
~H"""
0}
class={[
"absolute right-0 bottom-0 rounded-br-lg rounded-tl-lg px-1",
"text-xs font-medium",
"bg-zinc-200/80 dark:bg-zinc-500/70",
"text-zinc-700 dark:text-zinc-200",
"border-1 border-zinc-600/20 dark:border-zinc-500/20"
]}
>
{Records.Record.included_release_groups_count(record)}
<.artist_links joinphrase_class="text-xs" artists={record.artists} />
{record.title}
{Records.Record.format_release_date(record.release_date)}
({gettext("Unreleased")})
{format_label(record.format)} · {type_label(record.type)}
·
{gettext("Purchased on")}
<.icon
name="hero-banknotes"
class="-mt-1 h-4 w-4"
aria-hidden="true"
data-slot="icon"
/>
{Records.Record.format_as_date(record.purchased_at)}
·
{gettext("Wishlisted on")}
<.icon name="hero-star" class="-mt-1 h-4 w-4" aria-hidden="true" data-slot="icon" />
{Records.Record.format_as_date(record.inserted_at)}
"""
end
def tracked_record?(tracked_releases, release_id) do
Enum.find_value(tracked_releases, fn tracked_release ->
if tracked_release.release_id == release_id, do: tracked_release.record_id
end)
end
end