mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): updated boards resizable panel logic
This commit is contained in:
parent
2e7a95998c
commit
fea1ec9085
@ -3,12 +3,17 @@ import { useAppSelector } from 'app/store/storeHooks';
|
|||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
import { useBoardName } from 'services/api/hooks/useBoardName';
|
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 selectedBoardId = useAppSelector((s) => s.gallery.selectedBoardId);
|
||||||
const boardName = useBoardName(selectedBoardId);
|
const boardName = useBoardName(selectedBoardId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
|
onClick={props.onClick}
|
||||||
as="button"
|
as="button"
|
||||||
h="full"
|
h="full"
|
||||||
w="full"
|
w="full"
|
||||||
|
@ -5,7 +5,11 @@ import { memo } from 'react';
|
|||||||
|
|
||||||
import GalleryBoardName from './GalleryBoardName';
|
import GalleryBoardName from './GalleryBoardName';
|
||||||
|
|
||||||
const GalleryHeader = () => {
|
type Props = {
|
||||||
|
onClickBoardName: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const GalleryHeader = memo((props: Props) => {
|
||||||
const projectName = useStore($projectName);
|
const projectName = useStore($projectName);
|
||||||
const projectUrl = useStore($projectUrl);
|
const projectUrl = useStore($projectUrl);
|
||||||
|
|
||||||
@ -15,16 +19,16 @@ const GalleryHeader = () => {
|
|||||||
<Text fontSize="md" fontWeight="semibold" noOfLines={1} w="full" textAlign="center">
|
<Text fontSize="md" fontWeight="semibold" noOfLines={1} w="full" textAlign="center">
|
||||||
<Link href={projectUrl}>{projectName}</Link>
|
<Link href={projectUrl}>{projectName}</Link>
|
||||||
</Text>
|
</Text>
|
||||||
<GalleryBoardName />
|
<GalleryBoardName onClick={props.onClickBoardName} />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex w="full" pe={2}>
|
<Flex w="full" pe={2}>
|
||||||
<GalleryBoardName />
|
<GalleryBoardName onClick={props.onClickBoardName} />
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
export default memo(GalleryHeader);
|
GalleryHeader.displayName = 'GalleryHeader';
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import type { ChakraProps } from '@invoke-ai/ui-library';
|
import type { ChakraProps } from '@invoke-ai/ui-library';
|
||||||
import { Box, Collapse, Flex, IconButton, Spacer, Tab, TabList, Tabs, useDisclosure } 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 { 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 { galleryViewChanged } from 'features/gallery/store/gallerySlice';
|
||||||
import ResizeHandle from 'features/ui/components/tabs/ResizeHandle';
|
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 { useTranslation } from 'react-i18next';
|
||||||
import { PiMagnifyingGlassBold } from 'react-icons/pi';
|
import { PiMagnifyingGlassBold } from 'react-icons/pi';
|
||||||
|
import type { ImperativePanelGroupHandle } from 'react-resizable-panels';
|
||||||
import { Panel, PanelGroup } from 'react-resizable-panels';
|
import { Panel, PanelGroup } from 'react-resizable-panels';
|
||||||
|
|
||||||
import BoardsList from './Boards/BoardsList/BoardsList';
|
import BoardsList from './Boards/BoardsList/BoardsList';
|
||||||
@ -36,6 +38,20 @@ const ImageGalleryContent = () => {
|
|||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const searchDisclosure = useDisclosure({ defaultIsOpen: false });
|
const searchDisclosure = useDisclosure({ defaultIsOpen: false });
|
||||||
const boardSearchDisclosure = useDisclosure({ defaultIsOpen: false });
|
const boardSearchDisclosure = useDisclosure({ defaultIsOpen: false });
|
||||||
|
const panelGroupRef = useRef<ImperativePanelGroupHandle>(null);
|
||||||
|
|
||||||
|
const boardsListPanelOptions = useMemo<UsePanelOptions>(
|
||||||
|
() => ({
|
||||||
|
unit: 'pixels',
|
||||||
|
minSize: 128,
|
||||||
|
defaultSize: 256,
|
||||||
|
fallbackMinSizePct: 20,
|
||||||
|
panelGroupRef,
|
||||||
|
panelGroupDirection: 'vertical',
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
const boardsListPanel = usePanel(boardsListPanelOptions);
|
||||||
|
|
||||||
const handleClickImages = useCallback(() => {
|
const handleClickImages = useCallback(() => {
|
||||||
dispatch(galleryViewChanged('images'));
|
dispatch(galleryViewChanged('images'));
|
||||||
@ -45,12 +61,10 @@ const ImageGalleryContent = () => {
|
|||||||
dispatch(galleryViewChanged('assets'));
|
dispatch(galleryViewChanged('assets'));
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
const panelGroupRef = useRef(null);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex position="relative" flexDirection="column" h="full" w="full" pt={2}>
|
<Flex position="relative" flexDirection="column" h="full" w="full" pt={2}>
|
||||||
<Flex alignItems="center" gap={2}>
|
<Flex alignItems="center" gap={2}>
|
||||||
<GalleryHeader />
|
<GalleryHeader onClickBoardName={boardsListPanel.toggle} />
|
||||||
<GallerySettingsPopover />
|
<GallerySettingsPopover />
|
||||||
<Box position="relative" h="full">
|
<Box position="relative" h="full">
|
||||||
<IconButton
|
<IconButton
|
||||||
@ -76,14 +90,26 @@ const ImageGalleryContent = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
<PanelGroup ref={panelGroupRef} direction="vertical">
|
<PanelGroup ref={panelGroupRef} direction="vertical">
|
||||||
<Panel>
|
<Panel
|
||||||
|
id="boards-list-panel"
|
||||||
|
ref={boardsListPanel.ref}
|
||||||
|
defaultSize={boardsListPanel.defaultSize}
|
||||||
|
minSize={boardsListPanel.minSize}
|
||||||
|
onCollapse={boardsListPanel.onCollapse}
|
||||||
|
onExpand={boardsListPanel.onExpand}
|
||||||
|
collapsible
|
||||||
|
>
|
||||||
<Collapse in={boardSearchDisclosure.isOpen}>
|
<Collapse in={boardSearchDisclosure.isOpen}>
|
||||||
<BoardsSearch />
|
<BoardsSearch />
|
||||||
</Collapse>
|
</Collapse>
|
||||||
<BoardsList />
|
<BoardsList />
|
||||||
</Panel>
|
</Panel>
|
||||||
<ResizeHandle orientation="horizontal" />
|
<ResizeHandle
|
||||||
<Panel>
|
id="gallery-panel-handle"
|
||||||
|
orientation="horizontal"
|
||||||
|
onDoubleClick={boardsListPanel.onDoubleClickHandle}
|
||||||
|
/>
|
||||||
|
<Panel id="gallery-wrapper-panel" minSize={20}>
|
||||||
<Flex flexDirection="column" alignItems="center" justifyContent="space-between" h="full" w="full">
|
<Flex flexDirection="column" alignItems="center" justifyContent="space-between" h="full" w="full">
|
||||||
<Tabs index={galleryView === 'images' ? 0 : 1} variant="enclosed" display="flex" flexDir="column" w="full">
|
<Tabs index={galleryView === 'images' ? 0 : 1} variant="enclosed" display="flex" flexDir="column" w="full">
|
||||||
<TabList gap={2} fontSize="sm" borderColor="base.800">
|
<TabList gap={2} fontSize="sm" borderColor="base.800">
|
||||||
|
Loading…
Reference in New Issue
Block a user