From 7e724e8d8bd60f99978b23ec57ba523edd1f1440 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 11 Mar 2024 11:45:11 +0000 Subject: [PATCH] Update binding side panel to show readable bindings and real values --- .../common/bindings/BindingPanel.svelte | 2 +- .../common/bindings/BindingSidePanel.svelte | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/common/bindings/BindingPanel.svelte b/packages/builder/src/components/common/bindings/BindingPanel.svelte index b40ce1aa6a..e8ad96ea69 100644 --- a/packages/builder/src/components/common/bindings/BindingPanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingPanel.svelte @@ -279,7 +279,7 @@ {context} addHelper={onSelectHelper} addBinding={onSelectBinding} - mode={editorMode} + js={editorMode === EditorModes.JS} /> {:else if sidePanel === SidePanels.Evaluation} { + let code = binding.valueHTML if (!context || !binding.value || binding.value === "") { - return + code = null } stopHidingPopover() popoverAnchor = target hoverTarget = { helper: false, - code: binding.valueHTML, + code, + binding: binding.readableBinding, } popover.show() } @@ -92,7 +94,7 @@ hoverTarget = { helper: true, description: helper.description, - code: getHelperExample(helper, mode.name === "javascript"), + code: getHelperExample(helper, js), } popover.show() } @@ -112,6 +114,15 @@ hideTimeout = null } } + + const getReadableBindingLabel = readableBinding => { + console.log(js) + if (js) { + return `$("${readableBinding}")` + } else { + return `{{ ${readableBinding} }}` + } + }
+ {#if hoverTarget.binding} +
{getReadableBindingLabel(hoverTarget.binding)}
+ {/if} {#if hoverTarget.description}
@@ -246,7 +260,7 @@ class="binding" on:mouseenter={e => showHelperPopover(helper, e.target)} on:mouseleave={hidePopover} - on:click={() => addHelper(helper, mode.name === "javascript")} + on:click={() => addHelper(helper, js)} > {helper.displayText} @@ -404,7 +418,8 @@ text-overflow: ellipsis; overflow: hidden; } - .binding-popover.helper pre { + .binding-popover.helper pre, + .binding-popover pre.binding { color: var(--spectrum-global-color-blue-700); } .binding-popover pre :global(span) {