Skip to content

Commit 72b0209

Browse files
authored
fix: more fluid, bigger minimum size (#2789)
Signed-off-by: LE SAULNIER Kevin <[email protected]>
1 parent 27bc489 commit 72b0209

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

src/components/graph/menus/network-modifications/network-modifications-table.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ const NetworkModificationsTable: React.FC<NetworkModificationsTableProps> = ({
125125
cellRendererParams: {
126126
setModifications: setModifications,
127127
},
128-
maxWidth: 60,
129128
width: 60,
130129
},
131130
];
@@ -142,8 +141,7 @@ const NetworkModificationsTable: React.FC<NetworkModificationsTableProps> = ({
142141
},
143142
cellStyle: { textAlign: 'center' },
144143
headerStyle: { padding: 0 },
145-
maxWidth: 72,
146-
minWidth: 72,
144+
width: 72,
147145
headerComponent: () =>
148146
isCurrentRootNetwork && (
149147
<Box

src/components/network-modification-tree-pane-panels.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,25 @@ export const NetworkModificationTreePanePanels = ({
3030
rightComponent,
3131
showRightPanel = true,
3232
}: NetworkModificationTreePanePanelsProps) => {
33+
const MINIMUM_RIGHT_PANEL_SIZE = 380;
34+
const PADDING_BY_ROOT_NETWORK = 72;
35+
3336
// necessary to get container size in order to calculate % sizes from px
3437
const containerRef = useRef<HTMLDivElement>(null);
3538
// necessary to programatically resize layout
3639
const panelGroupRef = useRef<ImperativePanelGroupHandle>(null);
3740
const rootNetworks = useSelector((state: AppState) => state.rootNetworks);
3841

39-
const rightComponentDefaultSizePixel = 320 + rootNetworks.length * 80;
42+
const rightComponentDefaultSizePixel =
43+
MINIMUM_RIGHT_PANEL_SIZE - PADDING_BY_ROOT_NETWORK / 2 + rootNetworks.length * PADDING_BY_ROOT_NETWORK;
4044

4145
// we want to set sizes in pixel, but Panel only deals with sizes in %
4246
// this makes the conversion, and handle the resizing when the layout is updated
4347
const { rightPanelPercentSize, rightComponentMinSizePercentage, onDragging } = usePanelsSize({
4448
containerRef: containerRef,
4549
panelGroupRef: panelGroupRef,
4650
rightComponentDefaultSizePixel: rightComponentDefaultSizePixel,
47-
rightComponentMinSizePixel: 350,
51+
rightComponentMinSizePixel: MINIMUM_RIGHT_PANEL_SIZE,
4852
showRightPanel: showRightPanel,
4953
});
5054

src/components/network-modification-tree-pane.jsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import { useCallback, useEffect, useRef, useState } from 'react';
8+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
99
import {
1010
networkModificationTreeNodeAdded,
1111
networkModificationTreeNodeMoved,
@@ -545,24 +545,34 @@ export const NetworkModificationTreePane = ({ studyUuid, studyMapTreeDisplay, cu
545545
[studyUuid, dispatch, snackError]
546546
);
547547

548+
const networkModificationTreeComponent = useMemo(
549+
() => (
550+
<NetworkModificationTree
551+
onNodeContextMenu={onNodeContextMenu}
552+
studyUuid={studyUuid}
553+
studyMapTreeDisplay={studyMapTreeDisplay}
554+
isStudyDrawerOpen={isStudyDrawerOpen}
555+
prevTreeDisplay={prevTreeDisplay}
556+
/>
557+
),
558+
[studyUuid, onNodeContextMenu, studyMapTreeDisplay, isStudyDrawerOpen, prevTreeDisplay]
559+
);
560+
561+
const networkModificationPanelComponent = useMemo(
562+
() => (
563+
<>
564+
{isModificationsDrawerOpen && <NodeEditor />}
565+
{isEventScenarioDrawerOpen && <ScenarioEditor />}
566+
</>
567+
),
568+
[isModificationsDrawerOpen, isEventScenarioDrawerOpen]
569+
);
570+
548571
return (
549572
<>
550573
<NetworkModificationTreePanePanels
551-
leftComponent={
552-
<NetworkModificationTree
553-
onNodeContextMenu={onNodeContextMenu}
554-
studyUuid={studyUuid}
555-
studyMapTreeDisplay={studyMapTreeDisplay}
556-
isStudyDrawerOpen={isStudyDrawerOpen}
557-
prevTreeDisplay={prevTreeDisplay}
558-
/>
559-
}
560-
rightComponent={
561-
<>
562-
{isModificationsDrawerOpen && <NodeEditor />}
563-
{isEventScenarioDrawerOpen && <ScenarioEditor />}
564-
</>
565-
}
574+
leftComponent={networkModificationTreeComponent}
575+
rightComponent={networkModificationPanelComponent}
566576
showRightPanel={isModificationsDrawerOpen || isEventScenarioDrawerOpen}
567577
/>
568578
{createNodeMenu.display && (

0 commit comments

Comments
 (0)