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"
|
2021-02-10 16:49:23 +01:00
|
|
|
import Provider from "./Provider.svelte"
|
2020-11-13 16:42:32 +01:00
|
|
|
|
2020-11-18 20:18:18 +01:00
|
|
|
// Keep route params up to date
|
2020-11-30 16:05:36 +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
|
|
|
|
2020-11-27 17:36:31 +01:00
|
|
|
// Redirect to home layout if no matching route
|
2020-11-18 20:18:18 +01:00
|
|
|
$: screenDefinition == null && routeStore.actions.navigate("/")
|
2020-11-13 16:42:32 +01:00
|
|
|
</script>
|
|
|
|
|
2021-02-10 16:49:23 +01:00
|
|
|
<!-- Ensure to fully remount when screen changes -->
|
|
|
|
{#key screenDefinition?._id}
|
|
|
|
<Provider key="url" data={params}>
|
|
|
|
<Component definition={screenDefinition} />
|
|
|
|
</Provider>
|
|
|
|
{/key}
|
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>
|