From 4be4dd014dab49101cd22778471cea9f058e2b24 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 16 Sep 2021 07:28:59 +0100 Subject: [PATCH] Add initial DND implementation with working functionality for dropping inside components --- .../AppPreview/CurrentItemPreview.svelte | 16 ++++ .../client/src/components/ClientApp.svelte | 2 + .../client/src/components/Component.svelte | 4 + .../src/components/preview/DNDHandler.svelte | 83 +++++++++++++++++++ packages/client/src/stores/builder.js | 9 +- packages/client/src/utils/styleable.js | 2 + 6 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 packages/client/src/components/preview/DNDHandler.svelte diff --git a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte index 494050f690..422eba73b0 100644 --- a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte +++ b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte @@ -1,5 +1,6 @@ + + diff --git a/packages/client/src/stores/builder.js b/packages/client/src/stores/builder.js index 3f36af1d06..3a7eb1df61 100644 --- a/packages/client/src/stores/builder.js +++ b/packages/client/src/stores/builder.js @@ -64,13 +64,18 @@ const createBuilderStore = () => { dispatchEvent("preview-loaded") }, setSelectedPath: path => { - console.log("set to ") - console.log(path) writableStore.update(state => { state.selectedPath = path return state }) }, + moveComponent: (componentId, destinationComponentId, mode) => { + dispatchEvent("move-component", { + componentId, + destinationComponentId, + mode, + }) + }, } return { ...writableStore, diff --git a/packages/client/src/utils/styleable.js b/packages/client/src/utils/styleable.js index d9925af91a..32171b9478 100644 --- a/packages/client/src/utils/styleable.js +++ b/packages/client/src/utils/styleable.js @@ -23,6 +23,8 @@ export const styleable = (node, styles = {}) => { let applyHoverStyles let selectComponent + node.setAttribute("draggable", true) + // Creates event listeners and applies initial styles const setupStyles = (newStyles = {}) => { // Use empty state styles as base styles if required, but let them, get