added WIP, recursive children in children render

This commit is contained in:
Samuel Andert 2023-07-22 21:37:07 +02:00
parent f060090b0c
commit 613053c062
2 changed files with 17 additions and 5 deletions

View File

@ -1,12 +1,18 @@
<script lang="ts">
import Composite from './Composite.svelte'; // Recursive import
import components from '$lib/components.ts';
import { getContextStore } from '$lib/stores/contextStore.ts';
export let componentsData = [];
// For each component, get or create its context store
componentsData.children.forEach((child) => {
child.store = getContextStore(child.componentName);
});
export let componentsData = {
layout: '',
children: []
};
$: if (componentsData && componentsData.children) {
componentsData.children.forEach((child) => {
child.store = getContextStore(child.componentName);
});
}
async function getComponent(componentName) {
if (components[componentName]) {
@ -37,6 +43,11 @@
{/each}
</div>
{/if}
<!-- Recursive rendering of children -->
{#if component.children && component.children.length}
<Composite componentsData={component} />
{/if}
</div>
{:else}
<p>Component {component.componentName} not found.</p>

View File

@ -0,0 +1 @@
<div class="p-12 bg-blue-400">Hello Earth</div>