feat: add a spinner when SPA mode is enabled
This commit is contained in:
parent
e7f889f1f8
commit
a321501977
3 changed files with 49 additions and 2 deletions
41
src/components/helper/spa/Spinner.astro
Normal file
41
src/components/helper/spa/Spinner.astro
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
|
||||
---
|
||||
<div id="spinner-container">
|
||||
<div class="spinner"></div>
|
||||
<span>Loading...</span>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#spinner-container {
|
||||
display: none;
|
||||
gap: 1rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
.spinner:after {
|
||||
animation: changeContent .8s linear infinite;
|
||||
display: block;
|
||||
content: "⠋";
|
||||
}
|
||||
|
||||
@keyframes changeContent {
|
||||
10% { content: "⠙"; }
|
||||
20% { content: "⠹"; }
|
||||
30% { content: "⠸"; }
|
||||
40% { content: "⠼"; }
|
||||
50% { content: "⠴"; }
|
||||
60% { content: "⠦"; }
|
||||
70% { content: "⠧"; }
|
||||
80% { content: "⠇"; }
|
||||
90% { content: "⠏"; }
|
||||
}
|
||||
</style>
|
||||
<script is:inline>
|
||||
const spinner = document.getElementById("spinner-container");
|
||||
document.addEventListener("astro:before-preparation", () => {
|
||||
spinner.style.display = 'flex';
|
||||
});
|
||||
document.addEventListener("astro:after-preparation", () => {
|
||||
spinner.style.display = 'none';
|
||||
});
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue