pinafore/routes/_components/timeline/LazyTimeline.html
Nolan Lawson c0c7e9fafe refactor
2018-01-27 16:35:44 -08:00

57 lines
1.3 KiB
HTML

<div class="lazy-timeline">
{{#if !$initialized}}
<div transition:fade>
<div class="loading-page">
<LoadingSpinner />
</div>
</div>
{{/if}}
{{#await promise}}
{{then constructor}}
<:Component {constructor} :timeline />
{{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'
import { store } from '../../_utils/store'
export default {
oncreate() {
let instanceName = this.store.get('currentInstance')
let timeline = this.get('timeline')
this.store.set({currentTimeline: timeline})
this.store.setForTimeline(instanceName, timeline, {runningUpdate: false})
},
store: () => store,
data: () => ({
promise: importTimeline()
}),
components: {
LoadingSpinner
},
transitions: {
fade
}
}
</script>