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-)
|
use Phoenix.Component, global_prefixes: ~w(x-)
|
||||||
|
|
||||||
alias PinchflatWeb.CoreComponents
|
alias PinchflatWeb.CoreComponents
|
||||||
|
alias PinchflatWeb.CustomComponents.TextComponents
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Render a button
|
Render a button
|
||||||
|
|
@ -104,7 +105,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
|
||||||
|
|
||||||
def icon_button(assigns) do
|
def icon_button(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div class="group relative inline-block">
|
<TextComponents.tooltip position="bottom" tooltip={@tooltip} tooltip_class="text-nowrap">
|
||||||
<button
|
<button
|
||||||
class={[
|
class={[
|
||||||
"flex justify-center items-center rounded-lg ",
|
"flex justify-center items-center rounded-lg ",
|
||||||
|
|
@ -117,18 +118,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do
|
||||||
>
|
>
|
||||||
<CoreComponents.icon name={@icon_name} class="text-stroke" />
|
<CoreComponents.icon name={@icon_name} class="text-stroke" />
|
||||||
</button>
|
</button>
|
||||||
<div
|
</TextComponents.tooltip>
|
||||||
: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>
|
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -146,4 +146,56 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
||||||
<.localized_number number={@num} /> {@suffix}
|
<.localized_number number={@num} /> {@suffix}
|
||||||
"""
|
"""
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@
|
||||||
<:tab title="Media Profile" id="media-profile">
|
<:tab title="Media Profile" id="media-profile">
|
||||||
<div class="flex flex-col gap-10 text-white">
|
<div class="flex flex-col gap-10 text-white">
|
||||||
<section>
|
<section>
|
||||||
<h3 class="font-bold text-xl mt-6 mb-2">Raw Attributes</h3>
|
<h3 class="font-bold text-xl mt-6 mb-2">Raw Attributes</h3>
|
||||||
<.list_items_from_map map={Map.from_struct(@media_profile)} />
|
<.list_items_from_map map={Map.from_struct(@media_profile)} />
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</:tab>
|
</:tab>
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,22 @@ defmodule PinchflatWeb.Sources.MediaItemTableLive do
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<.table rows={@records} table_class="text-white">
|
<.table rows={@records} table_class="text-white">
|
||||||
<:col :let={media_item} label="Title" class="truncate max-w-xs">
|
<:col :let={media_item} label="Title" class="max-w-xs">
|
||||||
<.subtle_link href={~p"/sources/#{@source.id}/media/#{media_item.id}"}>
|
<section class="flex items-center space-x-1">
|
||||||
{media_item.title}
|
<.tooltip
|
||||||
</.subtle_link>
|
: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>
|
||||||
<:col :let={media_item} :if={@media_state == "other"} label="Manually Ignored?">
|
<: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"} />
|
<.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
|
# Selecting only what we need GREATLY speeds up queries on large tables
|
||||||
defp select_fields do
|
defp select_fields do
|
||||||
[:id, :title, :uploaded_at, :prevent_download]
|
[:id, :title, :uploaded_at, :prevent_download, :last_error]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue