From 4586fa850ccf20cfe4abd9113475a3436f2716c2 Mon Sep 17 00:00:00 2001 From: Ryan Martin <51780559+rmrt1n@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:46:32 +0700 Subject: [PATCH] fix: use fixed height for bottom bar (#23) Closes: WORLD-1013 ## Overview Inconsistent bottom bar UI when collapsed in different screens. This is caused by react-resizable-panels using only percentage values instead of pixels. Screenshots: **Before**: ![image](https://github.com/Argus-Labs/cardinal-editor/assets/51780559/d124bd6e-66ed-4eb2-b74a-8238cc36ea2f) **After**: ![image](https://github.com/Argus-Labs/cardinal-editor/assets/51780559/28b8050c-f15c-4f22-a3eb-097ada818c42) ## Brief Changelog - Show fixed height "bar" when panel is collapsed. This element is separate from the original panel contents. ## Testing and Verifying manually tested/verified --- src/components/bottom-bar.tsx | 111 +++++++++++++++++++++------------- src/components/ui/toaster.tsx | 2 +- 2 files changed, 70 insertions(+), 43 deletions(-) diff --git a/src/components/bottom-bar.tsx b/src/components/bottom-bar.tsx index b3c356b..27c4593 100644 --- a/src/components/bottom-bar.tsx +++ b/src/components/bottom-bar.tsx @@ -21,60 +21,87 @@ export function BottomBar() { const handleExpand = () => { const panel = ref.current if (panel) { - setCollapsed(panel.getSize() <= 3) + console.log(panel.getSize()) + if (panel.getSize() <= 5) { + panel.collapse() + } + setCollapsed(panel.getSize() === 0) } } const expandBottomBar = () => { const panel = ref.current if (panel) { - panel.resize(panel.getSize() > 3 ? 3 : 65) + panel.isCollapsed() ? panel.resize(65) : panel.collapse() + setCollapsed(panel.isCollapsed()) } } return ( - -
-

Results

- -
-
- {isError ? ( -
- -
-

- Error fetching data. -
- {error.message} -

+ <> + {collapsed && ( +
+

Results

+ +
+ )} + + {!collapsed && ( +
+
+

Results

+
-
- ) : !data ? ( -
- -
-

- No results. -
- You can send messages and queries from the sidebar. -

+
+ {isError ? ( +
+ +
+

+ Error fetching data. +
+ {error.message} +

+
+
+ ) : !data ? ( +
+ +
+

+ No results. +
+ You can send messages and queries from the sidebar. +

+
+
+ ) : ( +
+ {JSON.stringify(data, null, 2)} +
+ )}
- ) : ( -
- {JSON.stringify(data, null, 2)} -
)} -
-
+ + ) } diff --git a/src/components/ui/toaster.tsx b/src/components/ui/toaster.tsx index 0b8559a..9f8af0d 100644 --- a/src/components/ui/toaster.tsx +++ b/src/components/ui/toaster.tsx @@ -13,7 +13,7 @@ export function Toaster() { return ( - {toasts.map(function({ id, title, description, action, ...props }) { + {toasts.map(function ({ id, title, description, action, ...props }) { return (