Skip to content

Commit

Permalink
Add loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Aug 7, 2023
1 parent 962c644 commit 14a933a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn Home(cx: Scope) -> impl IntoView {
<p class="py-6">
<h2 class="text-3xl font-bold text-gray-500">"Nix Info"</h2>
<div class="my-1">
<Suspense fallback=move || view! {cx, <p>"Loading nix-info"</p> }>
<Suspense fallback=move || view! {cx, <Spinner /> }>
<ErrorBoundary fallback=|cx, errors| view! { cx, <Errors errors=errors.get() /> } >
{nix_info.read(cx)}
</ErrorBoundary>
Expand All @@ -56,6 +56,16 @@ fn Home(cx: Scope) -> impl IntoView {
}
}

// A loading spinner
#[component]
fn Spinner(cx: Scope) -> impl IntoView {
view! {cx,
<div class="animate-spin inline-block w-6 h-6 border-[3px] border-current border-t-transparent text-blue-600 rounded-full" role="status" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
}
}

/// <a> link
#[component]
fn Link(
Expand Down

0 comments on commit 14a933a

Please sign in to comment.