From 88018aff4e7387c22e14fb72860cd567e3cf8957 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 11 May 2022 12:47:24 +0100 Subject: [PATCH] Add initial layouts panel and add explicit panels for theme and navigation tabs --- packages/builder/src/builderStore/index.js | 26 ++-- .../src/builderStore/store/frontend.js | 2 +- .../[screenId]/_components/AppPreview.svelte | 104 ++++++++------- .../_components}/LayoutDropdownMenu.svelte | 35 +---- .../_components/LayoutNavigationPanel.svelte | 34 +++++ .../_components/LayoutSettingsPanel.svelte | 5 + .../layouts/[layoutId]/_layout.svelte | 20 +++ .../layouts/[layoutId]/index.svelte | 5 + .../design/[screenId]/layouts/index.svelte | 12 +- .../NavigationSettingsPanel.svelte | 118 +++++++++++++++++ .../design/[screenId]/navigation/index.svelte | 117 +---------------- .../_components/ThemeSettingsPanel.svelte | 120 ++++++++++++++++++ .../design/[screenId]/theme/index.svelte | 119 +---------------- 13 files changed, 391 insertions(+), 326 deletions(-) rename packages/builder/src/{components/design/_old => pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components}/LayoutDropdownMenu.svelte (52%) create mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutNavigationPanel.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutSettingsPanel.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_layout.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/index.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/navigation/_components/NavigationSettingsPanel.svelte create mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/theme/_components/ThemeSettingsPanel.svelte 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 @@
diff --git a/packages/builder/src/components/design/_old/LayoutDropdownMenu.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte similarity index 52% rename from packages/builder/src/components/design/_old/LayoutDropdownMenu.svelte rename to packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte index e54beb9e41..e5eb1bedd6 100644 --- a/packages/builder/src/components/design/_old/LayoutDropdownMenu.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/layouts/[layoutId]/_components/LayoutDropdownMenu.svelte @@ -2,21 +2,11 @@ import { store } from "builderStore" import { notifications } from "@budibase/bbui" import ConfirmDialog from "components/common/ConfirmDialog.svelte" - import { - ActionMenu, - MenuItem, - Icon, - Modal, - ModalContent, - Input, - } from "@budibase/bbui" - import { cloneDeep } from "lodash/fp" + import { ActionMenu, MenuItem, Icon } from "@budibase/bbui" export let layout let confirmDeleteDialog - let editLayoutNameModal - let name = layout.name const deleteLayout = async () => { try { @@ -26,24 +16,12 @@ notifications.error("Error deleting layout") } } - - const saveLayout = async () => { - try { - const layoutToSave = cloneDeep(layout) - layoutToSave.name = name - await store.actions.layouts.save(layoutToSave) - notifications.success("Layout saved successfully") - } catch (err) { - notifications.error("Error saving layout") - } - }
- Edit Delete
@@ -55,17 +33,6 @@ onOk={deleteLayout} /> - - - - - - diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/theme/index.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/theme/index.svelte index 017483a360..c4f2f7aad5 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/theme/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/theme/index.svelte @@ -1,120 +1,5 @@ - - - - Your theme is set across all the screens within your app - - - - - - - -
- {#each ButtonBorderRadiusOptions as option} -
- -
- {/each} -
-
- - - update("primaryColor", e.detail)} - /> - - - - update("primaryColorHover", e.detail)} - /> - -
-
- - +