Created
August 24, 2022 03:50
-
-
Save techygrrrl/c921087d2f1f7697badd80d8e05937c6 to your computer and use it in GitHub Desktop.
A loading spinner component in Svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
</script> | |
<div class="loading-state"> | |
<div class="lds-ripple"> | |
<div /> | |
<div /> | |
</div> | |
</div> | |
<style> | |
.loading-state { | |
height: 80vh; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
/* Source: https://loading.io/css/ */ | |
.lds-ripple { | |
display: inline-block; | |
position: relative; | |
width: 80px; | |
height: 80px; | |
} | |
.lds-ripple div { | |
position: absolute; | |
border: 4px solid #ff38db; | |
opacity: 1; | |
border-radius: 50%; | |
animation: lds-ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite; | |
} | |
.lds-ripple div:nth-child(2) { | |
animation-delay: -0.5s; | |
} | |
@keyframes lds-ripple { | |
0% { | |
top: 36px; | |
left: 36px; | |
width: 0; | |
height: 0; | |
opacity: 0; | |
} | |
4.9% { | |
top: 36px; | |
left: 36px; | |
width: 0; | |
height: 0; | |
opacity: 0; | |
} | |
5% { | |
top: 36px; | |
left: 36px; | |
width: 0; | |
height: 0; | |
opacity: 1; | |
} | |
100% { | |
top: 0px; | |
left: 0px; | |
width: 72px; | |
height: 72px; | |
opacity: 0; | |
} | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment