From 862a32af9b8ce8e6f6b3829503ed44997423971a Mon Sep 17 00:00:00 2001 From: pngwn Date: Wed, 26 Feb 2020 09:43:38 +0000 Subject: [PATCH] Make page and screen props editable. --- packages/builder/src/builderStore/store.js | 11 +++ .../ComponentPropertiesPanel.svelte | 68 +++++++++++++++++-- .../ComponentsPaneSwitcher.svelte | 2 - 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/builderStore/store.js b/packages/builder/src/builderStore/store.js index 2096f932f1..3d506181c1 100644 --- a/packages/builder/src/builderStore/store.js +++ b/packages/builder/src/builderStore/store.js @@ -112,6 +112,7 @@ export const getStore = () => { store.moveDownComponent = moveDownComponent(store) store.copyComponent = copyComponent(store) store.addTemplatedComponent = addTemplatedComponent(store) + store.setDetailProp = setDetailProp(store) return store } @@ -517,6 +518,7 @@ const setCurrentScreen = store => screenName => { screen._css = generate_screen_css([screen.props]) s.currentPreviewItem = screen s.currentFrontEndType = "screen" + s.currentView = "detail" s.currentComponentInfo = makePropsSafe( getContainerComponent(s.components), @@ -764,6 +766,7 @@ const addChildComponent = store => (componentToAdd, presetName) => { ? _savePage(state) : _saveScreenApi(state.currentPreviewItem, state) + state.currentView = "component" state.currentComponentInfo = newComponent.props return state @@ -794,6 +797,7 @@ const selectComponent = store => component => { ? component : state.components.find(c => c.name === component._component) state.currentComponentInfo = makePropsSafe(componentDef, component) + state.currentView = "component" return state }) } @@ -952,6 +956,13 @@ const walkProps = (props, action, cancelToken = null) => { } } +const setDetailProp = store => (name, prop) => { + store.update(s => { + s.currentPreviewItem[name] = prop + return s + }) +} + const _saveCurrentPreviewItem = s => s.currentFrontEndType === "page" ? _savePage(s) diff --git a/packages/builder/src/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/userInterface/ComponentPropertiesPanel.svelte index 4b6f7b0631..9ee326e55d 100644 --- a/packages/builder/src/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/userInterface/ComponentPropertiesPanel.svelte @@ -1,5 +1,6 @@
@@ -64,11 +77,23 @@ {/if} - {$store.currentFrontEndType}
{#if current_view === 'props'} - + {#if $store.currentView === 'detail'} + {#each screen_props as [k, v, id] (id)} +
+ + store.setDetailProp(k, target.value)} /> +
+ {/each} + + {:else} + + {/if} {:else if current_view === 'layout'} {:else if current_view === 'events'} @@ -85,6 +110,41 @@