Skip to content

Commit

Permalink
Add a loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Oct 15, 2023
1 parent acc214a commit 007f07c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
7 changes: 5 additions & 2 deletions webif/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Characteristics from './Characteristics.svelte'
import MainsPower from './MainsPower.svelte'
import Circuits from './Circuits.svelte'
import Loader from './Loader.svelte'
let configuration
let webSocketUrl
Expand Down Expand Up @@ -62,8 +63,10 @@
})
</script>

{#if webSocketUrl === undefined}
<p>Please add ?ws=ws://x.x.x.x:yyyy to your URL to connect to a server</p>
{#if lastUpdateTimestamp === undefined}
<div class="pure-u-1-1 l-box">
<Loader />
</div>
{:else}
<div class="pure-u-1-1 l-box">
<LastUpdate {lastUpdateTimestamp} {webSocketUrl} />
Expand Down
50 changes: 50 additions & 0 deletions webif/src/routes/Loader.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<style>
/* Source: https://cssloaders.github.io/ */
.loader {
width: 48px;
height: 48px;
border: 3px dotted #FFF;
border-style: solid solid dotted dotted;
border-radius: 50%;
display: inline-block;
position: relative;
box-sizing: border-box;
animation: rotation 2s linear infinite;
}
.loader::after {
content: '';
box-sizing: border-box;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
border: 3px dotted #FF3D00;
border-style: solid solid dotted;
width: 24px;
height: 24px;
border-radius: 50%;
animation: rotationBack 1s linear infinite;
transform-origin: center center;
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes rotationBack {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(-360deg);
}
}
</style>

<span class="loader"></span>

0 comments on commit 007f07c

Please sign in to comment.