diff --git a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte index 12159f675c..d769321de1 100644 --- a/packages/builder/src/components/userInterface/ComponentSelectionList.svelte +++ b/packages/builder/src/components/userInterface/ComponentSelectionList.svelte @@ -20,7 +20,7 @@ pipe, } from "components/common/core" - import Tab from "./ComponentTab/Tab.svelte" + import Tab from "./ItemTab/Tab.svelte" import { store } from "builderStore" export let toggleTab @@ -51,6 +51,15 @@ selectTemplateDialog.show() } + const onComponentChosen = component => { + if (component.template) { + onTemplateChosen(component.template) + } else { + store.addChildComponent(component._component) + toggleTab() + } + } + const onTemplateInstanceChosen = () => { selectedComponent = null const instance = templateInstances.find( @@ -63,16 +72,13 @@ $: templatesByComponent = groupBy(t => t.component)($store.templates) $: hierarchy = $store.hierarchy $: libraryModules = $store.libraries - $: standaloneTemplates = pipe( - templatesByComponent, - [ - values, - flatten, - filter(t => !$store.components.some(c => c.name === t.component)), - map(t => ({ name: splitName(t.component).componentName, template: t })), - uniqBy(t => t.name), - ] - ) + $: standaloneTemplates = pipe(templatesByComponent, [ + values, + flatten, + filter(t => !$store.components.some(c => c.name === t.component)), + map(t => ({ name: splitName(t.component).componentName, template: t })), + uniqBy(t => t.name), + ])
@@ -86,7 +92,9 @@ {/each}
- + onComponentChosen(e.detail)} />
diff --git a/packages/builder/src/components/userInterface/ComponentTab/Item.svelte b/packages/builder/src/components/userInterface/ItemTab/Item.svelte similarity index 64% rename from packages/builder/src/components/userInterface/ComponentTab/Item.svelte rename to packages/builder/src/components/userInterface/ItemTab/Item.svelte index 5730df484c..23d978813f 100644 --- a/packages/builder/src/components/userInterface/ComponentTab/Item.svelte +++ b/packages/builder/src/components/userInterface/ItemTab/Item.svelte @@ -1,21 +1,21 @@ -
-
- +
+
+
-
-
{component.name}
-
-

{component.description}

+
+
{item.name}
+
+

{item.description}