From 9c979056cd5d40645a204b651868e085c9a68288 Mon Sep 17 00:00:00 2001 From: Denise Li Date: Wed, 21 Aug 2024 13:43:57 -0400 Subject: [PATCH 1/2] smooth resizing of panels editor height cleanup --- frontend/src/components/CodeEditor.tsx | 12 +++++++-- .../components/ResizeableVerticalPanels.tsx | 14 ++++++----- frontend/src/features/verbs/VerbFormInput.tsx | 4 +-- .../src/features/verbs/VerbRequestForm.tsx | 25 ++++++++++++------- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/frontend/src/components/CodeEditor.tsx b/frontend/src/components/CodeEditor.tsx index 3d3c53d0a0..5e35805775 100644 --- a/frontend/src/components/CodeEditor.tsx +++ b/frontend/src/components/CodeEditor.tsx @@ -78,7 +78,15 @@ export const CodeEditor = ({ initialState, onTextChanged }: { initialState: Init const state = EditorState.create({ doc: initialState.initialText, - extensions: [commonExtensions, isDarkMode ? atomone : githubLight, json5(), editingExtensions], + extensions: [ + ...commonExtensions, + isDarkMode ? atomone : githubLight, + json5(), + editingExtensions, + EditorView.theme({ + '&': { height: '100%' }, + }), + ], }) const view = new EditorView({ @@ -94,5 +102,5 @@ export const CodeEditor = ({ initialState, onTextChanged }: { initialState: Init } }, [initialState, isDarkMode]) - return
+ return
} diff --git a/frontend/src/components/ResizeableVerticalPanels.tsx b/frontend/src/components/ResizeableVerticalPanels.tsx index 10661ef39e..7861378b05 100644 --- a/frontend/src/components/ResizeableVerticalPanels.tsx +++ b/frontend/src/components/ResizeableVerticalPanels.tsx @@ -44,12 +44,14 @@ export const ResizableVerticalPanels: React.FC = ( } const onDrag = (e: React.MouseEvent) => { - if (isDragging) { - const newHeight = e.clientY - const maxHeight = window.innerHeight - minBottomPanelHeight - if (newHeight >= minTopPanelHeight && newHeight <= maxHeight) { - setTopPanelHeight(newHeight - 44) - } + if (!isDragging || !containerRef.current) { + return + } + const containerDims = containerRef.current.getBoundingClientRect() + const newHeight = e.clientY - containerDims.top + const maxHeight = containerDims.height - minBottomPanelHeight + if (newHeight >= minTopPanelHeight && newHeight <= maxHeight) { + setTopPanelHeight(newHeight) } } diff --git a/frontend/src/features/verbs/VerbFormInput.tsx b/frontend/src/features/verbs/VerbFormInput.tsx index f96c597223..23488ee58e 100644 --- a/frontend/src/features/verbs/VerbFormInput.tsx +++ b/frontend/src/features/verbs/VerbFormInput.tsx @@ -27,7 +27,7 @@ export const VerbFormInput = ({ return (
- {requestType} + {requestType} setPath(event.target.value)} /> -
diff --git a/frontend/src/features/verbs/VerbRequestForm.tsx b/frontend/src/features/verbs/VerbRequestForm.tsx index b81d2b9e6a..983d0b09b8 100644 --- a/frontend/src/features/verbs/VerbRequestForm.tsx +++ b/frontend/src/features/verbs/VerbRequestForm.tsx @@ -1,5 +1,6 @@ import { useEffect, useState } from 'react' import { CodeEditor, type InitialState } from '../../components/CodeEditor' +import { ResizableVerticalPanels } from '../../components/ResizeableVerticalPanels' import { useClient } from '../../hooks/use-client' import type { Module, Verb } from '../../protos/xyz/block/ftl/v1/console/console_pb' import { VerbService } from '../../protos/xyz/block/ftl/v1/ftl_connect' @@ -101,8 +102,19 @@ export const VerbRequestForm = ({ module, verb }: { module?: Module; verb?: Verb const bottomText = response ?? error ?? '' + const bodyEditor = + + const bodyPanels = bottomText === '' ? bodyEditor : + } + /> + return ( -
+
-
-
- {activeTabId === 'body' && } +
+ {activeTabId === 'body' && bodyPanels} {activeTabId === 'verbschema' && } {activeTabId === 'jsonschema' && } {activeTabId === 'headers' && }
- -
-
- -
) From b398655203f6df12b9954442063e7ba56ffa6c22 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 21 Aug 2024 18:17:41 +0000 Subject: [PATCH 2/2] chore(autofmt): Automated formatting --- .../src/features/verbs/VerbRequestForm.tsx | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/features/verbs/VerbRequestForm.tsx b/frontend/src/features/verbs/VerbRequestForm.tsx index 983d0b09b8..7ed2d80bbb 100644 --- a/frontend/src/features/verbs/VerbRequestForm.tsx +++ b/frontend/src/features/verbs/VerbRequestForm.tsx @@ -102,16 +102,16 @@ export const VerbRequestForm = ({ module, verb }: { module?: Module; verb?: Verb const bottomText = response ?? error ?? '' - const bodyEditor = - - const bodyPanels = bottomText === '' ? bodyEditor : - } - /> + const bodyEditor = + const bodyPanels = + bottomText === '' ? ( + bodyEditor + ) : ( + } + /> + ) return (