Skip to content

Commit 8b9b64d

Browse files
feat(ui): improved resize handle styles
Simplify the handle component and use the provided data attributes to style the handles correctly. Fixes a styling issue where you if you hover at the T-junction between two handles, only one brightens up.
1 parent 417ef36 commit 8b9b64d

File tree

5 files changed

+46
-51
lines changed

5 files changed

+46
-51
lines changed

invokeai/frontend/web/src/features/gallery/components/GalleryPanelContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const GalleryPanelContent = () => {
9292
<BoardsListWrapper />
9393
</Flex>
9494
</Panel>
95-
<ResizeHandle id="gallery-panel-handle" orientation="horizontal" {...boardsListPanel.resizeHandleProps} />
95+
<ResizeHandle id="gallery-panel-handle" {...boardsListPanel.resizeHandleProps} />
9696
<Panel id="gallery-wrapper-panel" minSize={20}>
9797
<Gallery />
9898
</Panel>

invokeai/frontend/web/src/features/gallery/components/ImageViewer/ImageComparisonSideBySide.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ export const ImageComparisonSideBySide = memo(({ firstImage, secondImage }: Comp
4242
</Flex>
4343
</Flex>
4444
</Panel>
45-
<ResizeHandle
46-
id="image-comparison-side-by-side-handle"
47-
onDoubleClick={onDoubleClickHandle}
48-
orientation="vertical"
49-
/>
45+
<ResizeHandle id="image-comparison-side-by-side-handle" onDoubleClick={onDoubleClickHandle} />
5046

5147
<Panel minSize={20}>
5248
<Flex position="relative" w="full" h="full" alignItems="center" justifyContent="center">

invokeai/frontend/web/src/features/nodes/components/sidePanel/NodeEditorPanelGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const NodeEditorPanelGroup = () => {
5151
<Panel id="workflow" collapsible minSize={25}>
5252
<WorkflowPanel />
5353
</Panel>
54-
<ResizeHandle orientation="horizontal" onDoubleClick={handleDoubleClickHandle} />
54+
<ResizeHandle onDoubleClick={handleDoubleClickHandle} />
5555
<Panel id="inspector" collapsible minSize={25}>
5656
<InspectorPanel />
5757
</Panel>

invokeai/frontend/web/src/features/ui/components/AppContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ export const AppContent = memo(() => {
139139
</Box>
140140
</Flex>
141141
</Panel>
142-
<ResizeHandle id="left-main-handle" orientation="vertical" {...leftPanel.resizeHandleProps} />
142+
<ResizeHandle id="left-main-handle" {...leftPanel.resizeHandleProps} />
143143
</>
144144
)}
145145
<Panel id="main-panel" order={1} minSize={20} style={panelStyles}>
146146
<MainPanelContent />
147147
</Panel>
148148
{withRightPanel && (
149149
<>
150-
<ResizeHandle id="main-right-handle" orientation="vertical" {...rightPanel.resizeHandleProps} />
150+
<ResizeHandle id="main-right-handle" {...rightPanel.resizeHandleProps} />
151151
<Panel order={2} style={panelStyles} collapsible {...rightPanel.panelProps}>
152152
<RightPanelContent />
153153
</Panel>
Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
11
import type { SystemStyleObject } from '@invoke-ai/ui-library';
2-
import { Box, chakra, Flex } from '@invoke-ai/ui-library';
2+
import { chakra } from '@invoke-ai/ui-library';
33
import { memo } from 'react';
44
import type { PanelResizeHandleProps } from 'react-resizable-panels';
55
import { PanelResizeHandle } from 'react-resizable-panels';
66

7-
type ResizeHandleProps = PanelResizeHandleProps & {
8-
orientation: 'horizontal' | 'vertical';
9-
};
10-
117
const ChakraPanelResizeHandle = chakra(PanelResizeHandle);
128

13-
const ResizeHandle = (props: ResizeHandleProps) => {
14-
const { orientation, ...rest } = props;
15-
16-
return (
17-
<ChakraPanelResizeHandle {...rest}>
18-
<Flex sx={sx} data-orientation={orientation}>
19-
<Box className="resize-handle-inner" data-orientation={orientation} />
20-
</Flex>
21-
</ChakraPanelResizeHandle>
22-
);
9+
const ResizeHandle = (props: Omit<PanelResizeHandleProps, 'style'>) => {
10+
return <ChakraPanelResizeHandle {...props} sx={sx} />;
2311
};
2412

2513
export default memo(ResizeHandle);
2614

2715
const sx: SystemStyleObject = {
28-
display: 'flex',
29-
pos: 'relative',
30-
'&[data-orientation="horizontal"]': {
31-
w: 'full',
32-
h: 5,
33-
},
34-
'&[data-orientation="vertical"]': { w: 5, h: 'full' },
35-
alignItems: 'center',
36-
justifyContent: 'center',
37-
div: {
38-
bg: 'base.800',
16+
'&[data-resize-handle-state="hover"]': {
17+
_before: {
18+
background: 'base.600 !important',
19+
},
3920
},
40-
_hover: {
41-
div: { bg: 'base.700' },
21+
'&[data-resize-handle-state="drag"]': {
22+
_before: {
23+
background: 'base.500 !important',
24+
},
4225
},
43-
_active: {
44-
div: { bg: 'base.600' },
26+
'&[data-panel-group-direction="horizontal"]': {
27+
w: 4,
28+
h: 'full',
29+
position: 'relative',
30+
_before: {
31+
transitionProperty: 'background',
32+
transitionDuration: 'normal',
33+
content: '""',
34+
w: '2px',
35+
h: 'full',
36+
background: 'base.800',
37+
position: 'absolute',
38+
left: '50%',
39+
top: 0,
40+
transform: 'translateX(-50%)',
41+
},
4542
},
46-
transitionProperty: 'common',
47-
transitionDuration: 'normal',
48-
'.resize-handle-inner': {
49-
'&[data-orientation="horizontal"]': {
50-
w: '100%',
43+
'&[data-panel-group-direction="vertical"]': {
44+
h: 4,
45+
w: 'full',
46+
position: 'relative',
47+
_before: {
48+
transitionProperty: 'background',
49+
transitionDuration: 'normal',
50+
content: '""',
51+
w: 'full',
5152
h: '2px',
53+
background: 'base.800',
54+
position: 'absolute',
55+
top: '50%',
56+
left: 0,
57+
transform: 'translateY(-50%)',
5258
},
53-
'&[data-orientation="vertical"]': {
54-
w: '2px',
55-
h: '100%',
56-
},
57-
borderRadius: 'base',
58-
transitionProperty: 'inherit',
59-
transitionDuration: 'inherit',
6059
},
6160
};

0 commit comments

Comments
 (0)