From fce464434b980eb422628f61d05b7b050671b59a Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Sun, 12 Mar 2023 14:09:27 +0100 Subject: [PATCH] feat(frontend): working animations --- .../contextPanel/ComponentOutput.svelte | 96 ++++++++++++------- .../editor/contextPanel/ContextPanel.svelte | 4 +- 2 files changed, 65 insertions(+), 35 deletions(-) diff --git a/frontend/src/lib/components/apps/editor/contextPanel/ComponentOutput.svelte b/frontend/src/lib/components/apps/editor/contextPanel/ComponentOutput.svelte index 2646d30012..94eae0f4b6 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/ComponentOutput.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/ComponentOutput.svelte @@ -3,12 +3,15 @@ import { getContext } from 'svelte' import type { AppViewerContext, GridItem } from '../../types' import ComponentOutputViewer from './ComponentOutputViewer.svelte' - import { classNames, pluralize } from '$lib/utils' - import { ArrowDown, ArrowRight, ChevronDown, ChevronRight } from 'lucide-svelte' + import { classNames } from '$lib/utils' + import { ChevronDown, ChevronRight, Lock } from 'lucide-svelte' import { isIdInsideGriditem } from '../appUtils' + import { slide } from 'svelte/transition' export let gridItem: GridItem + export let first: boolean = false export let nested: boolean = false + export let parentId: string | undefined = undefined const { app, staticOutputs, selectedComponent } = getContext('AppViewerContext') const name = getComponentNameById(gridItem.id) @@ -40,47 +43,69 @@ return 'Pane' } } - $: x = isIdInsideGriditem($app, gridItem, $selectedComponent) - $: opened = manuallyOpened || x + $: insideGrid = isIdInsideGriditem($app, gridItem, $selectedComponent) + $: isSelected = $selectedComponent === gridItem.id + $: opened = insideGrid || isSelected || manuallyOpened + + function onHeaderClick() { + if (manuallyOpened) { + if (parentId) { + $selectedComponent = parentId + } else { + $selectedComponent = undefined + } + manuallyOpened = false + } else { + $selectedComponent = gridItem.id + manuallyOpened = true + } + } {#if $staticOutputs[gridItem.id] || gridItem.data.numberOfSubgrids > 1} -
+ +
-
- {gridItem.id} -
-
- {getComponentNameById(gridItem.id)} - {#if !opened} - - {:else} - - {/if} -
+ {gridItem.id}
- {#if x || opened} -
+
+ {getComponentNameById(gridItem.id)} + {#if !opened && !manuallyOpened} + + {:else if manuallyOpened} + + {:else} + + {/if} +
+
+ + {#if opened} +
+
-
+
{#each subGrids as subGridId, index} -
+
{#if subGrids.length > 1}
{getSubgridName(name)} @@ -89,10 +114,15 @@
{/if} {#if $app.subgrids && $app.subgrids[subGridId].length > 0} - {#each $app.subgrids[subGridId] as subGridItem} + {#each $app.subgrids[subGridId] as subGridItem, index} {#if subGridItem} -
- +
+
{/if} {/each} @@ -102,6 +132,6 @@
{/each}
- {/if} -
+
+ {/if} {/if} diff --git a/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte b/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte index 7ae08bdba4..ffa6082029 100644 --- a/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte +++ b/frontend/src/lib/components/apps/editor/contextPanel/ContextPanel.svelte @@ -77,8 +77,8 @@
- {#each $app.grid as gridItem} - + {#each $app.grid as gridItem, index} + {/each}