2020-11-13 16:42:32 +01:00
|
|
|
<script>
|
2020-11-25 19:30:09 +01:00
|
|
|
import { fade } from "svelte/transition"
|
2020-11-18 20:18:18 +01:00
|
|
|
import { screenStore, routeStore } from "../store"
|
2020-11-13 16:42:32 +01:00
|
|
|
import Component from "./Component.svelte"
|
|
|
|
|
2020-11-18 20:18:18 +01:00
|
|
|
// Keep route params up to date
|
2020-11-13 16:42:32 +01:00
|
|
|
export let params
|
2020-11-23 12:29:24 +01:00
|
|
|
$: routeStore.actions.setRouteParams(params || {})
|
2020-11-13 16:42:32 +01:00
|
|
|
|
|
|
|
// Get the screen definition for the current route
|
2020-11-18 20:18:18 +01:00
|
|
|
$: screenDefinition = $screenStore.activeScreen?.props
|
2020-11-17 13:08:24 +01:00
|
|
|
|
|
|
|
// Redirect to home page if no matching route
|
2020-11-18 20:18:18 +01:00
|
|
|
$: screenDefinition == null && routeStore.actions.navigate("/")
|
2020-11-24 10:31:54 +01:00
|
|
|
|
|
|
|
// Make a screen array so we can use keying to properly re-render each screen
|
|
|
|
$: screens = screenDefinition ? [screenDefinition] : []
|
2020-11-13 16:42:32 +01:00
|
|
|
</script>
|
|
|
|
|
2020-11-24 10:31:54 +01:00
|
|
|
{#each screens as screen (screen._id)}
|
2020-11-25 19:30:09 +01:00
|
|
|
<div in:fade>
|
|
|
|
<Component definition={screen} />
|
|
|
|
</div>
|
2020-11-24 10:31:54 +01:00
|
|
|
{/each}
|
2020-11-25 19:30:09 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
div {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
align-self: stretch;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: stretch;
|
|
|
|
}
|
|
|
|
</style>
|