Added help tooltip to source content view
This commit is contained in:
parent
da989daa0f
commit
ecd9d0e96f
4 changed files with 74 additions and 20 deletions
|
|
@ -3,6 +3,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
|
|||
use Phoenix.Component, global_prefixes: ~w(x-)
|
||||
|
||||
alias PinchflatWeb.CoreComponents
|
||||
alias PinchflatWeb.CustomComponents.TextComponents
|
||||
|
||||
@doc """
|
||||
Render a button
|
||||
|
|
@ -104,7 +105,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
|
|||
|
||||
def icon_button(assigns) do
|
||||
~H"""
|
||||
<div class="group relative inline-block">
|
||||
<TextComponents.tooltip position="bottom" tooltip={@tooltip} tooltip_class="text-nowrap">
|
||||
<button
|
||||
class={[
|
||||
"flex justify-center items-center rounded-lg ",
|
||||
|
|
@ -117,18 +118,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
|
|||
>
|
||||
<CoreComponents.icon name={@icon_name} class="text-stroke" />
|
||||
</button>
|
||||
<div
|
||||
:if={@tooltip}
|
||||
class={[
|
||||
"hidden absolute left-1/2 top-full z-20 mt-3 -translate-x-1/2 whitespace-nowrap rounded-md",
|
||||
"px-4.5 py-1.5 text-sm font-medium opacity-0 drop-shadow-4 group-hover:opacity-100 group-hover:block bg-meta-4"
|
||||
]}
|
||||
>
|
||||
<span class="border-light absolute -top-1 left-1/2 -z-10 h-2 w-2 -translate-x-1/2 rotate-45 rounded-sm bg-meta-4">
|
||||
</span>
|
||||
<span>{@tooltip}</span>
|
||||
</div>
|
||||
</div>
|
||||
</TextComponents.tooltip>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -146,4 +146,56 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
|||
<.localized_number number={@num} /> {@suffix}
|
||||
"""
|
||||
end
|
||||
|
||||
attr :tooltip, :string, required: true
|
||||
attr :position, :string, default: ""
|
||||
attr :tooltip_class, :any, default: ""
|
||||
attr :tooltip_arrow_class, :any, default: ""
|
||||
slot :inner_block
|
||||
|
||||
def tooltip(%{position: "bottom-right"} = assigns) do
|
||||
~H"""
|
||||
<.tooltip tooltip={@tooltip} tooltip_class={@tooltip_class} tooltip_arrow_class={["-top-1", @tooltip_arrow_class]}>
|
||||
{render_slot(@inner_block)}
|
||||
</.tooltip>
|
||||
"""
|
||||
end
|
||||
|
||||
def tooltip(%{position: "bottom"} = assigns) do
|
||||
~H"""
|
||||
<.tooltip
|
||||
tooltip={@tooltip}
|
||||
tooltip_class={["left-1/2 -translate-x-1/2", @tooltip_class]}
|
||||
tooltip_arrow_class={["-top-1 left-1/2 -translate-x-1/2", @tooltip_arrow_class]}
|
||||
>
|
||||
{render_slot(@inner_block)}
|
||||
</.tooltip>
|
||||
"""
|
||||
end
|
||||
|
||||
def tooltip(assigns) do
|
||||
~H"""
|
||||
<div class="group relative inline-block cursor-pointer">
|
||||
<div>
|
||||
{render_slot(@inner_block)}
|
||||
</div>
|
||||
<div
|
||||
:if={@tooltip}
|
||||
class={[
|
||||
"hidden absolute top-full z-20 mt-3 whitespace-nowrap rounded-md",
|
||||
"p-1.5 text-sm font-medium opacity-0 drop-shadow-4 group-hover:opacity-100 group-hover:block bg-meta-4",
|
||||
"border border-form-strokedark text-wrap",
|
||||
@tooltip_class
|
||||
]}
|
||||
>
|
||||
<span class={[
|
||||
"border-t border-l border-form-strokedark absolute -z-10 h-2 w-2 rotate-45 rounded-sm bg-meta-4",
|
||||
@tooltip_arrow_class
|
||||
]}>
|
||||
</span>
|
||||
<div class="px-3">{@tooltip}</div>
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
<:tab title="Media Profile" id="media-profile">
|
||||
<div class="flex flex-col gap-10 text-white">
|
||||
<section>
|
||||
<h3 class="font-bold text-xl mt-6 mb-2">Raw Attributes</h3>
|
||||
<.list_items_from_map map={Map.from_struct(@media_profile)} />
|
||||
<h3 class="font-bold text-xl mt-6 mb-2">Raw Attributes</h3>
|
||||
<.list_items_from_map map={Map.from_struct(@media_profile)} />
|
||||
</section>
|
||||
</div>
|
||||
</:tab>
|
||||
|
|
|
|||
|
|
@ -46,10 +46,22 @@ defmodule PinchflatWeb.Sources.MediaItemTableLive do
|
|||
</div>
|
||||
</header>
|
||||
<.table rows={@records} table_class="text-white">
|
||||
<:col :let={media_item} label="Title" class="truncate max-w-xs">
|
||||
<.subtle_link href={~p"/sources/#{@source.id}/media/#{media_item.id}"}>
|
||||
{media_item.title}
|
||||
</.subtle_link>
|
||||
<:col :let={media_item} label="Title" class="max-w-xs">
|
||||
<section class="flex items-center space-x-1">
|
||||
<.tooltip
|
||||
:if={media_item.last_error}
|
||||
tooltip={media_item.last_error}
|
||||
position="bottom-right"
|
||||
tooltip_class="w-64"
|
||||
>
|
||||
<.icon name="hero-exclamation-circle-solid" class="text-red-500" />
|
||||
</.tooltip>
|
||||
<span class="truncate">
|
||||
<.subtle_link href={~p"/sources/#{@source.id}/media/#{media_item.id}"}>
|
||||
{media_item.title}
|
||||
</.subtle_link>
|
||||
</span>
|
||||
</section>
|
||||
</:col>
|
||||
<:col :let={media_item} :if={@media_state == "other"} label="Manually Ignored?">
|
||||
<.icon name={if media_item.prevent_download, do: "hero-check", else: "hero-x-mark"} />
|
||||
|
|
@ -205,6 +217,6 @@ defmodule PinchflatWeb.Sources.MediaItemTableLive do
|
|||
|
||||
# Selecting only what we need GREATLY speeds up queries on large tables
|
||||
defp select_fields do
|
||||
[:id, :title, :uploaded_at, :prevent_download]
|
||||
[:id, :title, :uploaded_at, :prevent_download, :last_error]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue