feat: PageLoader
This commit is contained in:
35
src/lib/components/PageLoader.svelte
Normal file
35
src/lib/components/PageLoader.svelte
Normal file
@@ -0,0 +1,35 @@
|
||||
<script>
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { tweened } from 'svelte/motion';
|
||||
import { cubicOut } from 'svelte/easing';
|
||||
|
||||
let timeout;
|
||||
const progress = tweened(0, {
|
||||
duration: 2000,
|
||||
easing: cubicOut
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
timeout = setTimeout(() => {
|
||||
progress.set(0.7);
|
||||
}, 500);
|
||||
});
|
||||
onDestroy(() => {
|
||||
clearTimeout(timeout);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="progress-bar">
|
||||
<div class="progress-sliver" style={`--width: ${$progress * 100}%`} />
|
||||
</div>
|
||||
|
||||
<style lang="postcss">
|
||||
.progress-bar {
|
||||
height: 0.2rem;
|
||||
@apply fixed top-0 left-0 right-0;
|
||||
}
|
||||
.progress-sliver {
|
||||
width: var(--width);
|
||||
@apply h-full bg-coollabs;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user