From d83c98bafd92b7e8eb50de88713919b10ed2efe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Kov=C3=A1cs?= <43071496+adam-kov@users.noreply.github.com> Date: Wed, 8 Mar 2023 19:02:19 +0100 Subject: [PATCH] fix(frontend): Clean up app editor (#1267) * fix(frontend): Clean up app editor * fix(frontend): Add outputs search empty state * fix(frontend): Add remove button to icon input * label * fix(frontend): Iconed app button --- .../apps/components/buttons/AppButton.svelte | 4 +- .../apps/components/display/AppIcon.svelte | 10 +- .../components/apps/editor/AppEditor.svelte | 2 +- .../apps/editor/AppEditorHeader.svelte | 10 +- .../componentsPanel/ComponentList.svelte | 69 ++++--- .../editor/contextPanel/ContextPanel.svelte | 138 +++++++------ .../InlineScriptsPanelList.svelte | 183 +++++++++--------- .../apps/editor/settingsPanel/GridPane.svelte | 4 +- .../apps/editor/settingsPanel/GridTab.svelte | 4 +- .../inputEditor/IconSelectInput.svelte | 22 ++- .../lib/components/common/tabs/Tabs.svelte | 3 +- 11 files changed, 249 insertions(+), 200 deletions(-) diff --git a/frontend/src/lib/components/apps/components/buttons/AppButton.svelte b/frontend/src/lib/components/apps/components/buttons/AppButton.svelte index 757a4c3892..da67a9a738 100644 --- a/frontend/src/lib/components/apps/components/buttons/AppButton.svelte +++ b/frontend/src/lib/components/apps/components/buttons/AppButton.svelte @@ -166,11 +166,11 @@ {loading} > - {#if beforeIconComponent} + {#if beforeIcon && beforeIconComponent} {/if}
{labelValue}
- {#if afterIconComponent} + {#if afterIcon && afterIconComponent} {/if}
diff --git a/frontend/src/lib/components/apps/components/display/AppIcon.svelte b/frontend/src/lib/components/apps/components/display/AppIcon.svelte index 1680eb101b..b92b414706 100644 --- a/frontend/src/lib/components/apps/components/display/AppIcon.svelte +++ b/frontend/src/lib/components/apps/components/display/AppIcon.svelte @@ -22,12 +22,10 @@ let strokeWidth: number let iconComponent: any - $: icon && handleIcon() + $: handleIcon(icon) - async function handleIcon() { - if (icon) { - iconComponent = await loadIcon(icon) - } + async function handleIcon(i?: string) { + iconComponent = i ? await loadIcon(i) : undefined } $: css = concatCustomCss($app.css?.iconcomponent, customCss) @@ -45,7 +43,7 @@ class={css?.container?.class ?? ''} style={css?.container?.style ?? ''} > - {#if iconComponent} + {#if icon && iconComponent}
- +
diff --git a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte index db4a136a72..2617d25c7d 100644 --- a/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditorHeader.svelte @@ -471,13 +471,14 @@
-
+
+ {/each}
- - {/each} -
- {:else} -
- There are no components in this group yet -
- {/if} - - {/each} -{/if} + +
+ {/if} + {/each} +
+ {/if} + diff --git a/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte b/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte index 3910fb0f4f..0a041d09ef 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte @@ -2,6 +2,8 @@ import { classNames } from '$lib/utils' import { X } from 'lucide-svelte' import { getContext } from 'svelte' + import { flip } from 'svelte/animate' + import { fade } from 'svelte/transition' import type { AppEditorContext } from '../../types' import { findGridItem } from '../appUtils' import { components } from '../component' @@ -58,9 +60,7 @@ -
+
{/if}
- {#each filteredPanels as [componentId, outputs] (componentId)} - {#if outputs.length > 0 && $worldStore?.outputsById[componentId]} - {@const name = getComponentNameById(componentId)} -
-
- - - {name} - -
- - -
- {#key $selectedComponent} - {#key $connectingInput?.opened} - + {#each filteredPanels as [componentId, outputs] (componentId)} +
+ {#if outputs.length > 0 && $worldStore?.outputsById[componentId]} + {@const name = getComponentNameById(componentId)} +
+
+
+ + + {name} + +
+
+ {#key $selectedComponent} + {#key $connectingInput?.opened} + { + connectInput(componentId, detail) + }} + /> + {/key} + {/key} +
+
+ {/if}
- {/if} - {/each} + {:else} +
+ No outputs found +
+ {/each} +
diff --git a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte index 2eb3eaa413..8b57a012ab 100644 --- a/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte +++ b/frontend/src/lib/components/apps/editor/inlineScriptsPanel/InlineScriptsPanelList.svelte @@ -1,8 +1,8 @@ -
- Runnables -
-
- -
- {#if runnables.inline.length > 0} -
- {#each runnables.inline as { name, id }, index (index)} + +
+
+
Inline scripts
+
+ {#if runnables.inline.length > 0} +
+ {#each runnables.inline as { name, id }, index (index)} + + {/each} +
+ {/if} + {#if $app.unusedInlineScripts?.length > 0} +
+ {#each $app.unusedInlineScripts as unusedInlineScript, index (index)} + {@const id = `unused-${index}`} + + {/each} +
+ {/if} + {#if runnables.inline.length == 0 && $app.unusedInlineScripts?.length == 0} +
No inline scripts
+ {/if} +
+
+ +
+
Workspace/Hub
+
+ {#if runnables.imported.length > 0} + {#each runnables.imported as { name, id }, index (index)} {/each} -
- {/if} + {:else} +
No imported scripts/flows
+ {/if} +
+
- {#if $app.unusedInlineScripts?.length > 0} -
- {#each $app.unusedInlineScripts as unusedInlineScript, index (index)} - {@const id = `unused-${index}`} +
+
+
+ Background scripts + + Background scripts are triggered upon global refresh or when their input changes. The + result of a background script can be shared among many components. + +
+ +
+
+ {#if $app.hiddenInlineScripts?.length > 0} + {#each $app.hiddenInlineScripts as { name }, index (index)} + {@const id = `bg_${index}`} {/each} -
- {/if} - - {#if runnables.inline.length == 0 && $app.unusedInlineScripts?.length == 0} -
No inline scripts
- {/if} + {:else} +
No background scripts
+ {/if} +
-
- - -
- {#if runnables.imported.length > 0} - {#each runnables.imported as { name, id }, index (index)} - - {/each} - {:else} -
No imported scripts/flows
- {/if} -
-
- - - - - -
- {#if $app.hiddenInlineScripts?.length > 0} - {#each $app.hiddenInlineScripts as { name }, index (index)} - {@const id = `bg_${index}`} - - {/each} - {:else} -
No items
- {/if} -
-
-
+
+
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/GridPane.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/GridPane.svelte index c7328ef510..52f619c469 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/GridPane.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/GridPane.svelte @@ -53,9 +53,9 @@ {#if panes.length == 0} No panes {/if} -
+
{#each panes as value, index (index)} -
+
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte index c290f3af76..893982acfc 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/GridTab.svelte @@ -51,9 +51,9 @@ {#if tabs.length == 0} No Tabs {/if} -
+
{#each tabs as value, index (index)} -
+
diff --git a/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte b/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte index fbeabb5718..d8325508c1 100644 --- a/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte +++ b/frontend/src/lib/components/apps/editor/settingsPanel/inputEditor/IconSelectInput.svelte @@ -1,6 +1,6 @@ - +
+ + {#if componentInput.value} + + {/if} +
{#if anchor}
diff --git a/frontend/src/lib/components/common/tabs/Tabs.svelte b/frontend/src/lib/components/common/tabs/Tabs.svelte index 7bd88976f0..95a4427817 100644 --- a/frontend/src/lib/components/common/tabs/Tabs.svelte +++ b/frontend/src/lib/components/common/tabs/Tabs.svelte @@ -16,6 +16,7 @@ export let selected: string let c = '' export { c as class } + export let wrapperClass = '' export let style = '' $: selected && updateSelected() @@ -37,7 +38,7 @@ } -
+