decoupled actions from the components loading dynamically

This commit is contained in:
Samuel Andert 2023-07-22 17:35:14 +02:00
parent 90e4718df3
commit dc3995e327
3 changed files with 18 additions and 7 deletions

View File

@ -15,12 +15,22 @@
{#each componentsData.children as component (component.id)} {#each componentsData.children as component (component.id)}
{#await getComponent(component.componentName) then Component} {#await getComponent(component.componentName) then Component}
{#if Component} {#if Component}
<div class="w-full h-full overflow-hidden"> <div class="w-full h-full overflow-hidden {component.slot}">
<svelte:component <svelte:component this={Component} {...component.props} />
this={Component}
{...component.props} {#if component.actions}
class=" h-full w-full {component.slot} " <div class="flex justify-end p-4">
/> {#each component.actions as action}
{#await getComponent(action) then ActionComponent}
{#if ActionComponent}
<svelte:component this={ActionComponent} {...component.props} />
{:else}
<p>Action {action} not found.</p>
{/if}
{/await}
{/each}
</div>
{/if}
</div> </div>
{:else} {:else}
<p>Component {component.componentName} not found.</p> <p>Component {component.componentName} not found.</p>

View File

View File

@ -27,7 +27,8 @@
id: 3, id: 3,
componentName: 'MessageInput', componentName: 'MessageInput',
props: {}, props: {},
slot: 'footer' slot: 'footer',
actions: ['ClearMessages', 'SendMessage']
} }
] ]
}; };