diff --git a/frontend/src/lib/components/apps/editor/AppEditor.svelte b/frontend/src/lib/components/apps/editor/AppEditor.svelte index 72a83f02e1..716fcbfa91 100644 --- a/frontend/src/lib/components/apps/editor/AppEditor.svelte +++ b/frontend/src/lib/components/apps/editor/AppEditor.svelte @@ -28,12 +28,10 @@ import ComponentList from './componentsPanel/ComponentList.svelte' import ContextPanel from './contextPanel/ContextPanel.svelte' - import InlineScriptsPanel from './inlineScriptsPanel/InlineScriptsPanel.svelte' - import { page } from '$app/stores' import ItemPicker from '$lib/components/ItemPicker.svelte' import VariableEditor from '$lib/components/VariableEditor.svelte' - import { VariableService, type Policy } from '$lib/gen' + import { VariableService, type Job, type Policy } from '$lib/gen' import { initHistory } from '$lib/history' import { Component, Minus, Paintbrush, Plus, Smartphone } from 'lucide-svelte' import { findGridItem, findGridItemParentGrid } from './appUtils' @@ -56,6 +54,8 @@ import type DiffDrawer from '$lib/components/DiffDrawer.svelte' import RunnableJobPanel from './RunnableJobPanel.svelte' import { goto, replaceState } from '$app/navigation' + import HideButton from './settingsPanel/HideButton.svelte' + import AppEditorBottomPanel from './AppEditorBottomPanel.svelte' export let app: App export let path: string @@ -311,7 +311,7 @@ let gridPanelSize = 70 let leftPanelSize = 22 - let centerPanelSize = 63 + let centerPanelSize = 56 let rightPanelSize = 22 let tmpRunnablePanelSize = -1 @@ -540,11 +540,105 @@ let runnableJobEnterTimeout: NodeJS.Timeout | undefined = undefined let stillInJobEnter = false + let storedLeftPanelSize = 0 + let storedRightPanelSize = 0 + let storedBottomPanelSize = 0 + + let centerPanelWidth = 0 + + function hideLeftPanel() { + storedLeftPanelSize = leftPanelSize + leftPanelSize = 0 + centerPanelSize = centerPanelSize + storedLeftPanelSize + } + + function hideRightPanel() { + storedRightPanelSize = rightPanelSize + rightPanelSize = 0 + centerPanelSize = centerPanelSize + storedRightPanelSize + } + + function hideBottomPanel() { + storedBottomPanelSize = runnablePanelSize + gridPanelSize = 99 + runnablePanelSize = 0 + } + + function showLeftPanel() { + leftPanelSize = storedLeftPanelSize + centerPanelSize = centerPanelSize - storedLeftPanelSize + storedLeftPanelSize = 0 + } + + function showRightPanel() { + rightPanelSize = storedRightPanelSize + centerPanelSize = centerPanelSize - storedRightPanelSize + storedRightPanelSize = 0 + } + + function showBottomPanel() { + runnablePanelSize = storedBottomPanelSize + gridPanelSize = gridPanelSize - storedBottomPanelSize + storedBottomPanelSize = 0 + } + + function keydown(event: KeyboardEvent) { + let classes = event.target?.['className'] + if ( + (typeof classes === 'string' && classes.includes('inputarea')) || + ['INPUT', 'TEXTAREA'].includes(document.activeElement?.tagName!) + ) { + return + } + + switch (event.key) { + case 'b': { + if (event.ctrlKey || event.metaKey) { + event.preventDefault() + + if (leftPanelSize !== 0) { + hideLeftPanel() + } else { + showLeftPanel() + } + } + break + } + + case 'u': { + if (event.ctrlKey || event.metaKey) { + event.preventDefault() + + if (rightPanelSize !== 0) { + hideRightPanel() + } else { + showRightPanel() + } + } + break + } + + case 'l': { + if (event.ctrlKey || event.metaKey) { + event.preventDefault() + + if (runnablePanelSize !== 0) { + hideBottomPanel() + } else { + showBottomPanel() + } + } + break + } + } + } + let testJob: Job | undefined = undefined + let jobToWatch: { componentId: string; job: string } | undefined = undefined - + {#if !$userStore?.operator} {#if $appStore} @@ -556,6 +650,15 @@ {diffDrawer} bind:savedApp {version} + leftPanelHidden={leftPanelSize === 0} + rightPanelHidden={rightPanelSize === 0} + bottomPanelHidden={runnablePanelSize === 0} + on:showLeftPanel={() => showLeftPanel()} + on:showRightPanel={() => showRightPanel()} + on:hideLeftPanel={() => hideLeftPanel()} + on:hideRightPanel={() => hideRightPanel()} + on:hideBottomPanel={() => hideBottomPanel()} + on:showBottomPanel={() => showBottomPanel()} /> {#if $mode === 'preview'} @@ -601,7 +704,7 @@ - + hideLeftPanel()} /> @@ -618,7 +721,39 @@ 'wm-app-viewer h-full overflow-visible' )} style={$appStore.css?.['app']?.['viewer']?.style} + bind:clientWidth={centerPanelWidth} > + {#if leftPanelSize === 0} +
+ showLeftPanel()} + direction="right" + hidden + btnClasses="border bg-surface" + /> +
+ {/if} + {#if rightPanelSize === 0} +
+ showRightPanel()} + direction="left" + hidden + btnClasses="border bg-surface" + /> +
+ {/if} + {#if runnablePanelSize === 0} +
+ showBottomPanel()} + direction="bottom" + hidden + btnClasses="border bg-surface" + /> +
+ {/if} +