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) %>
""" 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"""
<%= render_slot(@icon) %>

<%= render_slot(@title) %>

<%= render_slot(@message) %>

<.clear_flash_button on_close={@on_close} />
""" end def icon_success(assigns) do ~H"""
""" end def icon_error(assigns) do ~H""" """ end def clear_flash_button(assigns) do ~H""" """ end end