
Above is image of new flash layout if I had a flash message on mount.
Below is the image on disconnection

It seems to lose the flex class.
This is the amended flash component code
attr :id, :string, default: "flash", doc: "the optional id of flash container"
attr :flash, :map, default: %{}, doc: "the map of flash messages to display"
attr :title, :string, default: nil
attr :kind, :atom, values: [:info, :error], doc: "used for styling and flash lookup"
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"
def flash(assigns) do
~H"""
<div
:if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
id={@id}
phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
role="alert"
class={[
"flex fixed top-2 right-2 w-80 sm:w-96 z-50 text-gray-800"
]}
{@rest}
>
<div
:if={@kind == :info}
class="text-white flex items-center justify-center p-3 stroke-blue-500 bg-blue-600 rounded-l-lg"
>
<.icon class="" name="hero-information-circle-mini" class="h-6 w-6" />
</div>
<div
:if={@kind == :error}
class="text-white flex items-center justify-center p-3 stroke-red-500 bg-red-600 rounded-l-lg"
>
<.icon name="hero-shield-exclamation-mini" class="h-6 w-6" />
</div>
<div
:if={@kind == :warning}
class="text-white flex items-center justify-center p-3 stroke-yellow-500 bg-yellow-600 rounded-l-lg"
>
<.icon name="hero-exclamation-triangle-mini" class="h-6 w-6" />
</div>
<div
:if={@kind == :success}
class="text-white flex items-center justify-center p-3 stroke-primary-500 bg-primary-600 rounded-l-lg"
>
<.icon name="hero-exclamation-triangle-mini" class="h-6 w-6" />
</div>
<div class="p-2 border-l-2 border-white bg-white w-full">
<p
:if={@title}
class={[
"flex items-center gap-1.5 text-sm font-semibold leading-6",
@kind == :info && "text-blue-600",
@kind == :error && "text-red-600",
@kind == :warning && "text-yellow-600",
@kind == :success && "text-primary-600"
]}
>
<%= @title %>
</p>
<p class="mt-2 text-sm leading-5 text-gray-800"><%= msg %></p>
<button type="button" class="group absolute top-1 right-1 p-2" aria-label={gettext("close")}>
<.icon name="hero-x-mark-solid" class="h-5 w-5 opacity-40 group-hover:opacity-70" />
</button>
</div>
</div>
"""
end
and the amended flash group code
attr :flash, :map, required: true, doc: "the map of flash messages"
def flash_group(assigns) do
~H"""
<.flash kind={:info} title="Info!" flash={@flash} />
<.flash kind={:error} title="Error!" flash={@flash} />
<.flash kind={:warning} title="Warning!" flash={@flash} />
<.flash kind={:success} title="Success!" flash={@flash} />
<.flash
id="client-error"
kind={:error}
title="We can't find the internet"
phx-disconnected={show(".phx-client-error #client-error")}
phx-connected={hide("#client-error")}
hidden
>
Attempting to reconnect <.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" />
</.flash>
<.flash
id="server-error"
kind={:error}
title="Something went wrong!"
phx-disconnected={show(".phx-server-error #server-error")}
phx-connected={hide("#server-error")}
hidden
>
Hang in there while we get back on track
<.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" />
</.flash>
"""
end
As you can see - all I’ve done is added the different types of flash alert to the flash group.
I’m really at a loss as to what’s going on.
The flash group is called in app.html.heex and is simple
<main>
<.flash_group flash={@flash} />
<%= @inner_content %>
</main>
Not sure at all about what’s going on. Am I doing something stupid here?
Thanks.