From 55d43fad809618eeec4c0af482183b030d741a82 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 21 Feb 2020 18:02:02 +0000 Subject: [PATCH] finished state management ui for v2 --- packages/builder/src/common/Input.svelte | 2 +- packages/builder/src/common/Select.svelte | 4 +- .../EventsEditor/HandlerSelector.svelte | 29 +- .../EventsEditor/StateBindingCascader.svelte | 43 ++- .../PropertyCascader.svelte | 67 ++--- .../StateBindingOptions.svelte | 63 ++++ .../userInterface/PropertyCascader/index.js | 1 + .../userInterface/StateBindingControl.svelte | 2 +- packages/client/src/state/parseBinding.js | 19 +- packages/client/src/state/stateManager.js | 63 ++-- .../stateManager/dynamicPropertySource.js | 0 .../client/src/state/stateManager/index.js | 274 ++++++++++++++++++ 12 files changed, 451 insertions(+), 116 deletions(-) rename packages/builder/src/userInterface/{ => PropertyCascader}/PropertyCascader.svelte (64%) create mode 100644 packages/builder/src/userInterface/PropertyCascader/StateBindingOptions.svelte create mode 100644 packages/builder/src/userInterface/PropertyCascader/index.js create mode 100644 packages/client/src/state/stateManager/dynamicPropertySource.js create mode 100644 packages/client/src/state/stateManager/index.js diff --git a/packages/builder/src/common/Input.svelte b/packages/builder/src/common/Input.svelte index e7c5e78841..50b07f41f0 100644 --- a/packages/builder/src/common/Input.svelte +++ b/packages/builder/src/common/Input.svelte @@ -22,6 +22,6 @@ appearance: none; background: #fff; border: 1px solid #ccc; - height: 50px; + height: 35px; } diff --git a/packages/builder/src/common/Select.svelte b/packages/builder/src/common/Select.svelte index be0ccafa7c..2b9b67bb85 100644 --- a/packages/builder/src/common/Select.svelte +++ b/packages/builder/src/common/Select.svelte @@ -23,11 +23,9 @@ select { display: block; - font-size: 14px; font-family: sans-serif; font-weight: 500; color: #163057; - line-height: 1.3; padding: 1em 2.6em 0.9em 1.4em; width: 100%; max-width: 100%; @@ -38,7 +36,7 @@ appearance: none; background: #fff; border: 1px solid #ccc; - height: 50px; + height: 35px; } .arrow { diff --git a/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte b/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte index 6315736581..d34b7303ab 100644 --- a/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte +++ b/packages/builder/src/userInterface/EventsEditor/HandlerSelector.svelte @@ -50,31 +50,8 @@ const handlerParams = {} for (let param of params) { handlerParams[param.name] = param.value - - if (param.value.startsWith("context")) { - const [_, contextKey] = param.value.split("."); - - handlerParams[param.name] = { - "##bbstate": contextKey, - "##bbsource": "context", - "##bbstatefallback": "balls to that", - } - console.log("Param starts with context", param.value); - }; - - if (param.value.startsWith("event")) { - const [_, eventKey] = param.value.split("."); - handlerParams[param.name] = { - "##bbstate": eventKey, - "##bbsource": "event", - "##bbstatefallback": "balls to that", - } - }; - } - console.log(type, params, handlerParams); - const updatedHandler = { [EVENT_TYPE_MEMBER_NAME]: type, parameters: handlerParams, @@ -96,9 +73,9 @@ } const onParameterChanged = index => e => { - const value = e.target.value + const value = e.target ? e.target.value : e const newParams = [...parameters] - newParams[index].value = e.target.value + newParams[index].value = value handlerChanged(handlerType, newParams) } @@ -116,7 +93,7 @@ {#if parameters} {#each parameters as parameter, idx} - + {/each} {/if} diff --git a/packages/builder/src/userInterface/EventsEditor/StateBindingCascader.svelte b/packages/builder/src/userInterface/EventsEditor/StateBindingCascader.svelte index 37996fd373..15539f7b21 100644 --- a/packages/builder/src/userInterface/EventsEditor/StateBindingCascader.svelte +++ b/packages/builder/src/userInterface/EventsEditor/StateBindingCascader.svelte @@ -11,20 +11,61 @@ allHandlers, } from "../../common/eventHandlers" import { store } from "../../builderStore" + import StateBindingOptions from "../PropertyCascader/StateBindingOptions.svelte" + import { ArrowDownIcon } from "../../common/Icons/" export let parameter + export let onChange + + let isOpen = false
{parameter.name} - +
+ + + {#if isOpen} + { + onChange(option) + isOpen = false + }} /> + {/if} +
diff --git a/packages/builder/src/userInterface/PropertyCascader/StateBindingOptions.svelte b/packages/builder/src/userInterface/PropertyCascader/StateBindingOptions.svelte new file mode 100644 index 0000000000..bd35366929 --- /dev/null +++ b/packages/builder/src/userInterface/PropertyCascader/StateBindingOptions.svelte @@ -0,0 +1,63 @@ + + +
    + {#each options as option} +
  • onSelect(`${option.name}.`)}> + {option.name} + {option.description} +
  • + {/each} +
+ + diff --git a/packages/builder/src/userInterface/PropertyCascader/index.js b/packages/builder/src/userInterface/PropertyCascader/index.js new file mode 100644 index 0000000000..14b79c4e0c --- /dev/null +++ b/packages/builder/src/userInterface/PropertyCascader/index.js @@ -0,0 +1 @@ +export { default } from "./PropertyCascader.svelte" \ No newline at end of file diff --git a/packages/builder/src/userInterface/StateBindingControl.svelte b/packages/builder/src/userInterface/StateBindingControl.svelte index 6a5237051b..f96ae7fd08 100644 --- a/packages/builder/src/userInterface/StateBindingControl.svelte +++ b/packages/builder/src/userInterface/StateBindingControl.svelte @@ -1,7 +1,7 @@