diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte index abb956c9d3..c199e6c7d3 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte @@ -3,6 +3,7 @@ import { onMount, onDestroy } from "svelte" import { store, + selectedComponent, selectedScreen, selectedLayout, currentAsset, @@ -14,6 +15,7 @@ Layout, Heading, Body, + Icon, notifications, } from "@budibase/bbui" import ErrorSVG from "@budibase/frontend-core/assets/error.svg?raw" @@ -96,6 +98,9 @@ $: json = JSON.stringify(previewData) $: refreshContent(json) + // Determine if the add component menu is active + $: isAddingComponent = $isActive(`./components/${$selectedComponent._id}/new`) + // Update the iframe with the builder info to render the correct preview const refreshContent = message => { if (iframe) { @@ -219,6 +224,16 @@ idToDelete = null } + const toggleAddComponent = () => { + if (isAddingComponent) { + $goto(`../${$selectedScreen._id}/components/${$selectedComponent._id}`) + } else { + $goto( + `../${$selectedScreen._id}/components/${$selectedComponent._id}/new` + ) + } + } + onMount(() => { window.addEventListener("message", receiveMessage) if (!$store.clientFeatures.messagePassing) { @@ -282,6 +297,13 @@ class:tablet={$store.previewDevice === "tablet"} class:mobile={$store.previewDevice === "mobile"} /> +
+ Component +
diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte index 7b5f164e06..113100becc 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte @@ -151,7 +151,7 @@ }) -
+