[frontend/components] Add proper loading spinner to all loading indicators

This commit is contained in:
Lilian 2025-02-09 16:48:22 +01:00
parent 1b84d3b87e
commit c13ae77a8d
No known key found for this signature in database
30 changed files with 111 additions and 21 deletions

View file

@ -30,7 +30,7 @@
@Loc["ComposeNote"]<Icon Name="Icons.PaperPlaneRight"/> @Loc["ComposeNote"]<Icon Name="Icons.PaperPlaneRight"/>
</Initial> </Initial>
<Loading> <Loading>
@Loc["Sending"]<Icon Name="Icons.Spinner"/> @Loc["Sending"]<LoadingSpinner />
</Loading> </Loading>
<Success> <Success>
@Loc["Done"]<Icon Name="Icons.Check"/> @Loc["Done"]<Icon Name="Icons.Check"/>

View file

@ -10,7 +10,7 @@
<div class="confirm @(Waiting ? "waiting" : "")"> <div class="confirm @(Waiting ? "waiting" : "")">
@if (Waiting) @if (Waiting)
{ {
<Icon Name="Icons.Spinner" Size="3rem"/> <LoadingSpinner Scale="1.5"/>
} }
else else
{ {

View file

@ -20,7 +20,7 @@
} }
@if (_init == LoadState.Loading) @if (_init == LoadState.Loading)
{ {
<div>Loading!</div> <div class="loading"><LoadingSpinner Scale="2" /></div>
} }
@if (_init == LoadState.Emtpy) @if (_init == LoadState.Emtpy)
{ {

View file

@ -5,4 +5,11 @@
width: 100%; width: 100%;
overflow-x: auto; overflow-x: auto;
padding: 0.5rem; padding: 0.5rem;
}
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
} }

View file

@ -0,0 +1,5 @@
<svg class="animate-spin" viewBox="0 0 24 24" style="--scale: @Scale"></svg>
@code {
[Parameter] public double Scale { get; set; } = 1;
}

After

Width:  |  Height:  |  Size: 142 B

View file

@ -0,0 +1,25 @@
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.animate-spin {
animation: spin 1s linear infinite;
margin-block: auto;
}
svg {
--scale: 1;
display: inline;
height: calc(1rem * var(--scale));
width: calc(1rem * var(--scale));
border-radius: 9999px;
border-width: calc(2px * var(--scale));
border-color: transparent;
background-color: transparent;
border-right-color: white;
border-top-color: white;
border-style: solid;
margin-right: 0.5rem;
}

View file

@ -26,7 +26,7 @@
} }
@if (State is State.Loading) @if (State is State.Loading)
{ {
<span>Loading</span> <span class="loading"><LoadingSpinner Scale="1.5"/></span>
} }
@if (State is State.Error) @if (State is State.Error)
{ {

View file

@ -0,0 +1,5 @@
.loading {
display: flex;
align-items: center;
justify-content: center;
}

View file

@ -26,7 +26,7 @@
} }
@if (State is State.Loading) @if (State is State.Loading)
{ {
<span>Loading</span> <span class="loading"><LoadingSpinner Scale="1.5" /></span>
} }
@if (State is State.Error) @if (State is State.Error)
{ {

View file

@ -0,0 +1,5 @@
.loading {
display: flex;
align-items: center;
justify-content: center;
}

View file

@ -16,7 +16,7 @@
@if (_state == State.Loading) @if (_state == State.Loading)
{ {
<div>Loading!</div> <div class="loading"><LoadingSpinner Scale="2" /></div>
} }
@if (_state == State.Error) @if (_state == State.Error)

View file

@ -14,4 +14,12 @@
padding-left: 0.5rem; padding-left: 0.5rem;
padding-right: 0.5rem; padding-right: 0.5rem;
width: 100%; width: 100%;
}
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
margin: auto;
} }

View file

@ -10,7 +10,7 @@
<div class="prompt @(Waiting ? "waiting" : "")"> <div class="prompt @(Waiting ? "waiting" : "")">
@if (Waiting) @if (Waiting)
{ {
<Icon Name="Icons.Spinner" Size="3rem"/> <LoadingSpinner Scale="1.5"/>
} }
else else
{ {

View file

@ -5,7 +5,7 @@
<div @ref="context.Ref.Current" class="@Class" style="@Style"> <div @ref="context.Ref.Current" class="@Class" style="@Style">
@if (_state is State.Loading or State.Init) @if (_state is State.Loading or State.Init)
{ {
<Icon Name="Icons.Spinner"/> <LoadingSpinner />
} }
else else
{ {

View file

@ -10,7 +10,7 @@
<div class="select @(Waiting ? "waiting" : "")"> <div class="select @(Waiting ? "waiting" : "")">
@if (Waiting) @if (Waiting)
{ {
<Icon Name="Icons.Spinner" Size="3rem"/> <LoadingSpinner Scale="1.5" />
} }
else else
{ {

View file

@ -16,7 +16,7 @@
break; break;
case HubConnectionState.Connecting: case HubConnectionState.Connecting:
<div class="state"> <div class="state">
<svg class="animate-spin" viewBox="0 0 24 24"></svg> @Loc["Connecting"] <LoadingSpinner/> @Loc["Connecting"]
</div> </div>
break; break;
case HubConnectionState.Disconnected: case HubConnectionState.Disconnected:
@ -26,7 +26,7 @@
break; break;
case HubConnectionState.Reconnecting: case HubConnectionState.Reconnecting:
<div class="state"> <div class="state">
<svg class="animate-spin" viewBox="0 0 24 24"></svg> @Loc["Reconnecting"] <LoadingSpinner /> @Loc["Reconnecting"]
</div> </div>
break; break;
} }

View file

@ -70,7 +70,7 @@
} }
@if (_state == State.Loading) @if (_state == State.Loading)
{ {
<div>Loading</div> <div class="loading"><LoadingSpinner Scale="2"/></div>
} }
@if (_state == State.NotFound) @if (_state == State.NotFound)
{ {

View file

@ -2,6 +2,13 @@
display: none; display: none;
} }
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
}
.drive-files { .drive-files {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;

View file

@ -31,7 +31,7 @@
@if (Loading) @if (Loading)
{ {
<span>Loading!</span> <span class="loading"><LoadingSpinner Scale="2"/></span>
} }
@if (Failure) @if (Failure)
{ {

View file

@ -26,6 +26,13 @@
z-index: +11; z-index: +11;
} }
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
}
.backdrop { .backdrop {
opacity: 50%; opacity: 50%;
background-color: black; background-color: black;

View file

@ -66,7 +66,7 @@
@if (State is State.Loading) @if (State is State.Loading)
{ {
<div class="loading"> <div class="loading">
<Icon Name="Icons.Spinner" Size="3rem"/> <LoadingSpinner Scale="2" />
</div> </div>
} }

View file

@ -120,7 +120,7 @@
} }
@if (_loading) @if (_loading)
{ {
<div>loading</div> <div class="loading"><LoadingSpinner Scale="2" /></div>
} }
@if (_notFound) @if (_notFound)
{ {

View file

@ -4,6 +4,13 @@
overflow-x: clip; overflow-x: clip;
} }
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
}
.header { .header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View file

@ -54,7 +54,7 @@
<StateButton @ref="@LoginButton" ExtraClasses="button" OnClick="Submit"> <StateButton @ref="@LoginButton" ExtraClasses="button" OnClick="Submit">
<Initial>@Loc["Register"]</Initial> <Initial>@Loc["Register"]</Initial>
<Success>@Loc["Success!"]</Success> <Success>@Loc["Success!"]</Success>
<Loading>@Loc["Loading"]</Loading> <Loading>@Loc["Loading"] <LoadingSpinner /></Loading>
<Failed>@Loc["Try again"]</Failed> <Failed>@Loc["Try again"]</Failed>
</StateButton> </StateButton>
</div> </div>

View file

@ -64,7 +64,7 @@
<StateButton ExtraClasses="button" @ref="@SaveButton" OnClick="Submit"> <StateButton ExtraClasses="button" @ref="@SaveButton" OnClick="Submit">
<Initial>@Loc["Save changes"]</Initial> <Initial>@Loc["Save changes"]</Initial>
<Success>@Loc["Saved"]</Success> <Success>@Loc["Saved"]</Success>
<Loading>@Loc["Loading"]<Icon Name="Icons.Spinner"/> <Loading>@Loc["Loading"]<LoadingSpinner />
</Loading> </Loading>
<Failed>@Loc["Error"]</Failed> <Failed>@Loc["Error"]</Failed>
</StateButton> </StateButton>

View file

@ -166,7 +166,7 @@
<Initial><Icon Name="Icons.Plus"/><span>@Loc["Add Filter"]</span></Initial> <Initial><Icon Name="Icons.Plus"/><span>@Loc["Add Filter"]</span></Initial>
<Success><Icon Name="Icons.Plus"/><span>@Loc["Add Filter"]</span></Success> <Success><Icon Name="Icons.Plus"/><span>@Loc["Add Filter"]</span></Success>
<Loading> <Loading>
<Icon Name="Icons.Spinner"/> <LoadingSpinner/>
</Loading> </Loading>
<Failed> <Failed>
<Icon Name="Icons.X"/>@Loc["Error"] <Icon Name="Icons.X"/>@Loc["Error"]

View file

@ -151,7 +151,7 @@
<Icon Name="Icons.FloppyDisk"/>@Loc["Save"] <Icon Name="Icons.FloppyDisk"/>@Loc["Save"]
</Initial> </Initial>
<Loading> <Loading>
<Icon Name="Icons.Spinner"/> <LoadingSpinner />
</Loading> </Loading>
<Failed> <Failed>
<Icon Name="Icons.X"/>@Loc["Error"] <Icon Name="Icons.X"/>@Loc["Error"]
@ -164,7 +164,7 @@
} }
@if (State is State.Loading) @if (State is State.Loading)
{ {
<div>Loading!</div> <div class="loading"><LoadingSpinner Scale="2" /></div>
} }
</div> </div>

View file

@ -4,6 +4,13 @@
align-items: center; align-items: center;
} }
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
}
.button { .button {
padding: 0.75rem; padding: 0.75rem;
margin: 0.2rem; margin: 0.2rem;

View file

@ -134,7 +134,7 @@
} }
@if (_componentState == State.Loading) @if (_componentState == State.Loading)
{ {
<div>Loading</div> <div class="loading"><LoadingSpinner Scale="2" /></div>
} }
@if (_componentState == State.NotFound) @if (_componentState == State.NotFound)
{ {

View file

@ -10,6 +10,13 @@
border-radius: 0.75rem; border-radius: 0.75rem;
} }
.loading {
display: flex;
align-items: center;
justify-content: center;
padding-top: 25vh;
}
.descendants { .descendants {
display: flex; display: flex;
flex-direction: column; flex-direction: column;