diff --git a/packages/builder/src/builderStore/index.js b/packages/builder/src/builderStore/index.js index 1dd1df0cd3..28ef1f4376 100644 --- a/packages/builder/src/builderStore/index.js +++ b/packages/builder/src/builderStore/index.js @@ -1,7 +1,7 @@ import { getFrontendStore } from "./store/frontend" import { getAutomationStore } from "./store/automation" import { getThemeStore } from "./store/theme" -import { derived, writable } from "svelte/store" +import { derived } from "svelte/store" import { LAYOUT_NAMES } from "../constants" import { findComponent, findComponentPath } from "./componentUtils" import { RoleUtils } from "@budibase/frontend-core" @@ -14,6 +14,20 @@ export const selectedScreen = derived(store, $store => { return $store.screens.find(screen => screen._id === $store.selectedScreenId) }) +export const selectedLayout = derived(store, $store => { + return $store.layouts?.find(layout => layout._id === $store.selectedLayoutId) +}) + +export const selectedComponent = derived( + [store, selectedScreen], + ([$store, $selectedScreen]) => { + if (!$selectedScreen || !$store.selectedComponentId) { + return null + } + return findComponent($selectedScreen?.props, $store.selectedComponentId) + } +) + export const sortedScreens = derived(store, $store => { return $store.screens.slice().sort((a, b) => { // Sort by role first @@ -43,16 +57,6 @@ export const sortedScreens = derived(store, $store => { }) }) -export const selectedComponent = derived( - [store, selectedScreen], - ([$store, $selectedScreen]) => { - if (!$selectedScreen || !$store.selectedComponentId) { - return null - } - return findComponent($selectedScreen?.props, $store.selectedComponentId) - } -) - export const selectedComponentPath = derived( [store, selectedScreen], ([$store, $selectedScreen]) => { diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 78e75e9b3f..286e44d868 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -43,7 +43,6 @@ const INITIAL_FRONTEND_STATE = { continueIfAction: false, }, currentFrontEndType: "none", - selectedLayoutId: "", errors: [], hasAppPackage: false, libraries: null, @@ -57,6 +56,7 @@ const INITIAL_FRONTEND_STATE = { // URL params selectedScreenId: null, selectedComponentId: null, + selectedLayoutId: null, } export const getFrontendStore = () => { 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 a9b344ce41..38ad9b73b7 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 @@ -1,7 +1,12 @@