This commit is contained in:
parent
a8d9fe6121
commit
9b4f3b140c
19 changed files with 330 additions and 43 deletions
|
|
@ -63,6 +63,11 @@ defmodule MvWeb.CoreComponents do
|
|||
values: [:info, :error, :success, :warning],
|
||||
doc: "used for styling and flash lookup"
|
||||
|
||||
attr :auto_clear_ms, :integer,
|
||||
default: nil,
|
||||
doc:
|
||||
"when set, flash is auto-dismissed after this many milliseconds (e.g. 5000 for success toasts)"
|
||||
|
||||
attr :rest, :global, doc: "the arbitrary HTML attributes to add to the flash container"
|
||||
|
||||
slot :inner_block, doc: "the optional inner block that renders the flash message"
|
||||
|
|
@ -74,6 +79,9 @@ defmodule MvWeb.CoreComponents do
|
|||
<div
|
||||
:if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
|
||||
id={@id}
|
||||
phx-hook={@auto_clear_ms && "FlashAutoDismiss"}
|
||||
data-auto-clear-ms={@auto_clear_ms}
|
||||
data-clear-flash-key={@auto_clear_ms && @kind}
|
||||
phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
|
||||
role="alert"
|
||||
class="pointer-events-auto"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue