mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
feat(ui): support a min expanded size for collapsible panels
This commit is contained in:
@@ -24,9 +24,11 @@ export const LEFT_PANEL_MIN_SIZE_PX = 420;
|
||||
export const RIGHT_PANEL_MIN_SIZE_PX = 420;
|
||||
|
||||
export const BOARD_PANEL_MIN_HEIGHT_PX = 36;
|
||||
export const BOARD_PANEL_MIN_EXPANDED_HEIGHT_PX = 128;
|
||||
export const BOARD_PANEL_DEFAULT_HEIGHT_PX = 232;
|
||||
|
||||
export const GALLERY_PANEL_MIN_HEIGHT_PX = 36;
|
||||
export const GALLERY_PANEL_MIN_EXPANDED_HEIGHT_PX = 128;
|
||||
export const GALLERY_PANEL_DEFAULT_HEIGHT_PX = 232;
|
||||
|
||||
export const LAYERS_PANEL_MIN_HEIGHT_PX = 36;
|
||||
|
||||
@@ -21,7 +21,8 @@ export const useCollapsibleGridviewPanel = (
|
||||
panelId: string,
|
||||
orientation: 'horizontal' | 'vertical',
|
||||
defaultSize: number,
|
||||
collapsedSize?: number
|
||||
collapsedSize?: number,
|
||||
minExpandedSize?: number
|
||||
) => {
|
||||
const $isCollapsed = useState(() => atom(false))[0];
|
||||
const lastExpandedSizeRef = useRef<number>(0);
|
||||
@@ -46,12 +47,18 @@ export const useCollapsibleGridviewPanel = (
|
||||
if (!panel || !(panel instanceof GridviewPanel)) {
|
||||
return;
|
||||
}
|
||||
if (orientation === 'vertical') {
|
||||
panel.api.setSize({ height: lastExpandedSizeRef.current || defaultSize });
|
||||
} else {
|
||||
panel.api.setSize({ width: lastExpandedSizeRef.current || defaultSize });
|
||||
|
||||
let newSize = lastExpandedSizeRef.current || defaultSize;
|
||||
if (minExpandedSize && newSize < minExpandedSize) {
|
||||
newSize = minExpandedSize;
|
||||
}
|
||||
}, [defaultSize, orientation, panelId, tab]);
|
||||
|
||||
if (orientation === 'vertical') {
|
||||
panel.api.setSize({ height: newSize });
|
||||
} else {
|
||||
panel.api.setSize({ width: newSize });
|
||||
}
|
||||
}, [defaultSize, minExpandedSize, orientation, panelId, tab]);
|
||||
|
||||
const toggle = useCallback(() => {
|
||||
const panel = navigationApi.getPanel(tab, panelId);
|
||||
|
||||
Reference in New Issue
Block a user