defmodule PlausibleWeb.Live.Flash do
@moduledoc """
Flash component for LiveViews - works also when embedded within dead views
"""
use Phoenix.LiveComponent
alias Phoenix.LiveView.JS
alias Phoenix.Flash
def render(assigns) do
~H"""
<.flash>
<:icon>
<.icon_success :if={Flash.get(@flash, :success)} />
<.icon_error :if={Flash.get(@flash, :error)} />
<:title :if={Flash.get(@flash, :success)}>
<%= Flash.get(@flash, :success_title) || "Success!" %>
<:message>
<%= Flash.get(@flash, :success) %>
<.flash on_close={JS.hide(to: "#live-view-connection-status")}>
<:icon>
<.icon_error />
<:title>
Oops, a server blip
<:message>
Please wait while we're trying to reconnect...
"""
end
slot(:icon, required: true)
slot(:title, require: true)
slot(:message, required: true)
attr(:on_close, :any, default: "lv:clear-flash")
def flash(assigns) do
~H"""