From fea1ec9085a392c8db83d3c0c5106b639a9bf2cb Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Wed, 10 Jul 2024 18:28:01 +1000
Subject: [PATCH] feat(ui): updated boards resizable panel logic
---
.../gallery/components/GalleryBoardName.tsx | 7 +++-
.../gallery/components/GalleryHeader.tsx | 14 ++++---
.../components/ImageGalleryContent.tsx | 42 +++++++++++++++----
3 files changed, 49 insertions(+), 14 deletions(-)
diff --git a/invokeai/frontend/web/src/features/gallery/components/GalleryBoardName.tsx b/invokeai/frontend/web/src/features/gallery/components/GalleryBoardName.tsx
index a680d2b19a..8ede311f9e 100644
--- a/invokeai/frontend/web/src/features/gallery/components/GalleryBoardName.tsx
+++ b/invokeai/frontend/web/src/features/gallery/components/GalleryBoardName.tsx
@@ -3,12 +3,17 @@ import { useAppSelector } from 'app/store/storeHooks';
import { memo } from 'react';
import { useBoardName } from 'services/api/hooks/useBoardName';
-const GalleryBoardName = () => {
+type Props = {
+ onClick: () => void;
+};
+
+const GalleryBoardName = (props: Props) => {
const selectedBoardId = useAppSelector((s) => s.gallery.selectedBoardId);
const boardName = useBoardName(selectedBoardId);
return (
{
+type Props = {
+ onClickBoardName: () => void;
+};
+
+export const GalleryHeader = memo((props: Props) => {
const projectName = useStore($projectName);
const projectUrl = useStore($projectUrl);
@@ -15,16 +19,16 @@ const GalleryHeader = () => {
{projectName}
-
+
);
}
return (
-
+
);
-};
+});
-export default memo(GalleryHeader);
+GalleryHeader.displayName = 'GalleryHeader';
diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx
index 6e4a5bf735..ded0ad0056 100644
--- a/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx
+++ b/invokeai/frontend/web/src/features/gallery/components/ImageGalleryContent.tsx
@@ -1,12 +1,14 @@
import type { ChakraProps } from '@invoke-ai/ui-library';
import { Box, Collapse, Flex, IconButton, Spacer, Tab, TabList, Tabs, useDisclosure } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
-import GalleryHeader from 'features/gallery/components/GalleryHeader';
+import { GalleryHeader } from 'features/gallery/components/GalleryHeader';
import { galleryViewChanged } from 'features/gallery/store/gallerySlice';
import ResizeHandle from 'features/ui/components/tabs/ResizeHandle';
-import { memo, useCallback, useRef } from 'react';
+import { usePanel, type UsePanelOptions } from 'features/ui/hooks/usePanel';
+import { memo, useCallback, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { PiMagnifyingGlassBold } from 'react-icons/pi';
+import type { ImperativePanelGroupHandle } from 'react-resizable-panels';
import { Panel, PanelGroup } from 'react-resizable-panels';
import BoardsList from './Boards/BoardsList/BoardsList';
@@ -36,6 +38,20 @@ const ImageGalleryContent = () => {
const dispatch = useAppDispatch();
const searchDisclosure = useDisclosure({ defaultIsOpen: false });
const boardSearchDisclosure = useDisclosure({ defaultIsOpen: false });
+ const panelGroupRef = useRef(null);
+
+ const boardsListPanelOptions = useMemo(
+ () => ({
+ unit: 'pixels',
+ minSize: 128,
+ defaultSize: 256,
+ fallbackMinSizePct: 20,
+ panelGroupRef,
+ panelGroupDirection: 'vertical',
+ }),
+ []
+ );
+ const boardsListPanel = usePanel(boardsListPanelOptions);
const handleClickImages = useCallback(() => {
dispatch(galleryViewChanged('images'));
@@ -45,12 +61,10 @@ const ImageGalleryContent = () => {
dispatch(galleryViewChanged('assets'));
}, [dispatch]);
- const panelGroupRef = useRef(null);
-
return (
-
+
{
-
+
-
-
+
+