From 6bb3c76d1d652b3901675e9a5912e7b2c718eee0 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 27 Feb 2024 12:51:53 +0000 Subject: [PATCH] Further improve code mirror styles and consistency --- .../common/CodeEditor/CodeEditor.svelte | 25 +++++++----- .../src/components/common/CodeEditor/index.js | 6 +-- .../common/bindings/BindingSidePanel.svelte | 40 +++++++++++-------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte index 9b3d01fbbc..58942e5091 100644 --- a/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte +++ b/packages/builder/src/components/common/CodeEditor/CodeEditor.svelte @@ -433,10 +433,19 @@ margin-top: -2px; } + /* Wrapper around helpers */ + .code-editor :global(.info-bubble) { + font-size: var(--font-size-s); + display: flex; + flex-direction: column; + gap: var(--spacing-m); + color: var(--spectrum-global-color-gray-800); + } + /* Live binding value / helper value */ .code-editor :global(.binding__description) { - color: var(--spectrum-global-color-gray-700); - font-size: var(--font-size-s); + color: var(--spectrum-alias-text-color); + font-size: var(--font-size-m); } .code-editor :global(.binding__example) { padding: 0; @@ -448,18 +457,12 @@ overflow: hidden; max-height: 480px; } + .code-editor :global(.binding__example.helper) { + color: var(--spectrum-global-color-blue-700); + } .code-editor :global(.binding__example span) { overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; } - - /* Wrapper around helpers */ - .code-editor :global(.info-bubble) { - font-size: var(--font-size-s); - display: grid; - grid-gap: var(--spacing-s); - grid-template-columns: 1fr; - color: var(--spectrum-global-color-gray-800); - } diff --git a/packages/builder/src/components/common/CodeEditor/index.js b/packages/builder/src/components/common/CodeEditor/index.js index c877907e9c..962e0bd393 100644 --- a/packages/builder/src/components/common/CodeEditor/index.js +++ b/packages/builder/src/components/common/CodeEditor/index.js @@ -32,17 +32,17 @@ export const buildHelperInfoNode = (completion, helper) => { ele.classList.add("info-bubble") const exampleNodeHtml = helper.example - ? `
${helper.example}
` + ? `
${helper.example}
` : "" const descriptionMarkup = sanitizeHtml(helper.description, { allowedTags: [], allowedAttributes: {}, }) - const descriptionNodeHtml = `
${descriptionMarkup}
` + const descriptionNodeHtml = `
${descriptionMarkup}
` ele.innerHTML = ` - ${exampleNodeHtml} ${descriptionNodeHtml} + ${exampleNodeHtml} ` return ele } diff --git a/packages/builder/src/components/common/bindings/BindingSidePanel.svelte b/packages/builder/src/components/common/bindings/BindingSidePanel.svelte index 40f9b65bc3..2c1880149f 100644 --- a/packages/builder/src/components/common/bindings/BindingSidePanel.svelte +++ b/packages/builder/src/components/common/bindings/BindingSidePanel.svelte @@ -75,6 +75,7 @@ stopHidingPopover() popoverAnchor = target hoverTarget = { + helper: false, code: binding.valueHTML, } popover.show() @@ -87,6 +88,7 @@ } popoverAnchor = target hoverTarget = { + helper: true, description: helper.description, code: getHelperExample(helper, mode.name === "javascript"), } @@ -121,19 +123,17 @@ on:mouseenter={stopHidingPopover} on:mouseleave={hidePopover} > -
- - {#if hoverTarget.description} -
- - {@html hoverTarget.description} -
- {/if} - {#if hoverTarget.code} +
+ {#if hoverTarget.description} +
-
{@html hoverTarget.code}
- {/if} - + {@html hoverTarget.description} +
+ {/if} + {#if hoverTarget.code} + +
{@html hoverTarget.code}
+ {/if}
@@ -380,14 +380,19 @@ .binding__label { text-transform: capitalize; } - .binding__type { font-family: var(--font-mono); font-size: 10px; color: var(--spectrum-global-color-gray-700); } - .helper pre { + .binding-popover { + display: flex; + flex-direction: column; + gap: var(--spacing-m); + padding: var(--spacing-m); + } + .binding-popover pre { padding: 0; margin: 0; font-size: 12px; @@ -395,12 +400,15 @@ text-overflow: ellipsis; overflow: hidden; } - .helper pre :global(span) { + .binding-popover.helper pre { + color: var(--spectrum-global-color-blue-700); + } + .binding-popover pre :global(span) { overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; } - .helper :global(p) { + .binding-popover :global(p) { padding: 0; margin: 0; }