Add example loading slot

This commit is contained in:
Wout De Puysseleir 2025-04-18 09:41:00 -07:00
parent 640dd6eaea
commit 7fd90a59ca
4 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1 @@
<p>This is the component!</p>

View file

@ -119,6 +119,12 @@
>
15
</a>
<a
href={~p"/client-side-loading"}
class="font-semibold leading-6 text-zinc-900 hover:text-zinc-700 hover:underline p-2"
>
16
</a>
</div>
<div class="flex items-center gap-4">

View file

@ -0,0 +1,29 @@
defmodule ExampleWeb.LiveClientSideLoading do
use ExampleWeb, :live_view
def render(assigns) do
~H"""
<h1 class="text-3xl bold mb-4">Examples of the loading slot</h1>
<div class="flex flex-col gap-4">
<div>
<h2 class="text-xl">Client side</h2>
<.svelte name="ClientSideLoading" ssr={false}>
<:loading>
<div class="animate-spin h-4 w-4 border-4 border-blue-500 rounded-full border-t-transparent"></div>
</:loading>
</.svelte>
</div>
<div>
<h2 class="text-xl">Server side (should not be used)</h2>
<p class="bold italic">This should flicker and throw a console warning</p>
<.svelte name="ClientSideLoading" socket={@socket}>
<:loading>
<div class="animate-spin h-4 w-4 border-4 border-blue-500 rounded-full border-t-transparent"></div>
</:loading>
</.svelte>
</div>
</div>
"""
end
end

View file

@ -34,6 +34,7 @@ defmodule ExampleWeb.Router do
live "/slots-simple", LiveSlotsSimple
live "/slots-dynamic", LiveSlotsDynamic
live "/composition", LiveComposition
live "/client-side-loading", LiveClientSideLoading
end
# Other scopes may use custom stacks.