From 44af872a494aed7fd6401eceefbb84ea025e87a8 Mon Sep 17 00:00:00 2001 From: Josh Corbett Date: Fri, 25 Oct 2024 22:51:14 -0600 Subject: [PATCH 1/2] feat(regions): :sparkles: highlight some focused regions --- .../components/CanvasLayersPanelContent.tsx | 18 +++++++++++++++--- .../components/CanvasMainPanelContent.tsx | 6 +++++- .../gallery/components/GalleryPanelContent.tsx | 17 +++++++++++++++-- .../components/ImageViewer/ImageViewer.tsx | 5 ++++- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/invokeai/frontend/web/src/features/controlLayers/components/CanvasLayersPanelContent.tsx b/invokeai/frontend/web/src/features/controlLayers/components/CanvasLayersPanelContent.tsx index 20e27c75601..c5b65fc3158 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/CanvasLayersPanelContent.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/CanvasLayersPanelContent.tsx @@ -1,6 +1,6 @@ import { Divider, Flex } from '@invoke-ai/ui-library'; import { useAppSelector } from 'app/store/storeHooks'; -import { useFocusRegion } from 'common/hooks/focus'; +import { useFocusRegion, useIsRegionFocused } from 'common/hooks/focus'; import { CanvasAddEntityButtons } from 'features/controlLayers/components/CanvasAddEntityButtons'; import { CanvasEntityList } from 'features/controlLayers/components/CanvasEntityList/CanvasEntityList'; import { EntityListSelectedEntityActionBar } from 'features/controlLayers/components/CanvasEntityList/EntityListSelectedEntityActionBar'; @@ -11,11 +11,23 @@ export const CanvasLayersPanelContent = memo(() => { const hasEntities = useAppSelector(selectHasEntities); const layersPanelFocusRef = useRef(null); useFocusRegion('layers', layersPanelFocusRef); + const isRegionFocused = useIsRegionFocused('layers'); return ( - + - + {!hasEntities && } {hasEntities && } diff --git a/invokeai/frontend/web/src/features/controlLayers/components/CanvasMainPanelContent.tsx b/invokeai/frontend/web/src/features/controlLayers/components/CanvasMainPanelContent.tsx index b66c0d8367c..d07cc826bad 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/CanvasMainPanelContent.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/CanvasMainPanelContent.tsx @@ -1,6 +1,6 @@ import { ContextMenu, Flex, IconButton, Menu, MenuButton, MenuList } from '@invoke-ai/ui-library'; import { useAppSelector } from 'app/store/storeHooks'; -import { useFocusRegion } from 'common/hooks/focus'; +import { useFocusRegion, useIsRegionFocused } from 'common/hooks/focus'; import { CanvasAlertsPreserveMask } from 'features/controlLayers/components/CanvasAlerts/CanvasAlertsPreserveMask'; import { CanvasAlertsSelectedEntityStatus } from 'features/controlLayers/components/CanvasAlerts/CanvasAlertsSelectedEntityStatus'; import { CanvasAlertsSendingToGallery } from 'features/controlLayers/components/CanvasAlerts/CanvasAlertsSendingTo'; @@ -42,6 +42,7 @@ export const CanvasMainPanelContent = memo(() => { }, []); useFocusRegion('canvas', ref); + const isRegionFocused = useIsRegionFocused('canvas'); return ( { gap={2} alignItems="center" justifyContent="center" + borderWidth={1} + p={1} + borderColor={isRegionFocused ? 'blue.300' : 'transparent'} > diff --git a/invokeai/frontend/web/src/features/gallery/components/GalleryPanelContent.tsx b/invokeai/frontend/web/src/features/gallery/components/GalleryPanelContent.tsx index 66a03606446..a5c9d2a8aa5 100644 --- a/invokeai/frontend/web/src/features/gallery/components/GalleryPanelContent.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/GalleryPanelContent.tsx @@ -1,6 +1,6 @@ import { Box, Button, Collapse, Divider, Flex, IconButton, useDisclosure } from '@invoke-ai/ui-library'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; -import { useFocusRegion } from 'common/hooks/focus'; +import { useFocusRegion, useIsRegionFocused } from 'common/hooks/focus'; import { GalleryHeader } from 'features/gallery/components/GalleryHeader'; import { selectBoardSearchText } from 'features/gallery/store/gallerySelectors'; import { boardSearchTextChanged } from 'features/gallery/store/gallerySlice'; @@ -28,6 +28,7 @@ const GalleryPanelContent = () => { const imperativePanelGroupRef = useRef(null); const galleryPanelFocusRef = useRef(null); useFocusRegion('gallery', galleryPanelFocusRef); + const isRegionFocused = useIsRegionFocused('gallery'); const boardsListPanelOptions = useMemo( () => ({ @@ -50,7 +51,19 @@ const GalleryPanelContent = () => { }, [boardSearchText.length, boardSearchDisclosure, boardsListPanel, dispatch]); return ( - +