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)}
{#await getComponent(component.componentName) then Component}
{#if Component}
<div class="w-full h-full overflow-hidden">
<svelte:component
this={Component}
{...component.props}
class=" h-full w-full {component.slot} "
/>
<div class="w-full h-full overflow-hidden {component.slot}">
<svelte:component this={Component} {...component.props} />
{#if component.actions}
<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>
{:else}
<p>Component {component.componentName} not found.</p>

View File

View File

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