Pinafore-Web-Client-Frontend/routes/_components/LazyTimeline.html

50 lines
1.0 KiB
HTML

<div class="lazy-timeline">
{{#if loading}}
<div transition:fade>
<div class="loading-page">
<LoadingSpinner />
</div>
</div>
{{/if}}
{{#await promise}}
{{then constructor}}
<:Component {constructor} :timeline on:initialized="set({'loading': false})"/>
{{catch error}}
<div>Component failed to load. Please try refreshing! {{error}}</div>
{{/await}}
</div>
<style>
.lazy-timeline {
width: 100%;
min-height: 60vh;
}
.loading-page {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
align-items: center;
justify-content: center;
z-index: 50
}
</style>
<script>
import { importTimeline } from '../_utils/asyncModules'
import LoadingSpinner from './LoadingSpinner.html'
import { fade } from 'svelte-transitions'
export default {
data: () => ({
promise: importTimeline(),
loading: true
}),
components: {
LoadingSpinner
},
transitions: {
fade
}
}
</script>