defmodule ScalesCmsWeb.MediaComponents do @moduledoc """ Provides custom made Media components. """ use Phoenix.Component use Gettext, backend: ScalesCmsWeb.Gettext import ScalesCmsWeb.CoreComponents alias ScalesCmsWeb.CmsMediaLibraryLive.MediaLibraryUtils attr :id, :string, required: true attr :item, :map, required: true attr :target, :any, default: nil attr :with_context_button, :boolean, default: false attr :show_date, :boolean, default: false attr :keep_aspect, :boolean, default: false attr :on_click, :any, default: nil def media_preview(%{item: %{type: "image"}} = assigns) do ~H"""
<.icon name="hero-photo" class="h-8 w-8 text-gray-500" />
{@item.name}
{@item.type}

{@item.name}

{Calendar.strftime(@item.inserted_at, "%d-%m-%Y")}

""" end def media_preview(%{item: %{type: "video"}} = assigns) do ~H"""
<.icon name="hero-film" class="h-8 w-8 text-gray-500" />
{@item.type}

{@item.name}

{Calendar.strftime(@item.inserted_at, "%d-%m-%Y")}

""" end def media_preview(%{item: %{type: "lottie"}} = assigns) do ~H"""
<.icon name="hero-sparkles" class="h-8 w-8 text-gray-500" />
{@item.type}

{@item.name}

{Calendar.strftime(@item.inserted_at, "%d-%m-%Y")}

""" end def media_preview(assigns) do ~H"""
<.icon name="hero-cross" class="h-8 w-8 text-gray-400" />
{@item.type}

{@item.name}

{Calendar.strftime(@item.inserted_at, "%d-%m-%Y")}

""" end defdelegate type_badge_class(type), to: MediaLibraryUtils end