Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Split Pane #798

Merged
merged 11 commits into from
Jul 30, 2024
Prev Previous commit
Next Next commit
created a new split pane reducer
the new split pane reducer takes a leaf pane and converts it into a split pane with two leaf pane childern with the same tabs as the original leaf pane before the split.
  • Loading branch information
michaelhelper committed Jul 26, 2024
commit 0b903e034b53a82232b737faa67915502ba6df6f
1 change: 1 addition & 0 deletions src/client/RunCodeWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const RunCodeWidget = ({
(event: React.MouseEvent) => {
event.stopPropagation();
// set the code editor width to half of its current width

},
[],
);
Expand Down
46 changes: 46 additions & 0 deletions src/client/vzReducer/splitPane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
PaneId,
LeafPane,
SplitPane,
Pane,
} from '../../types';

export const splitCurrentPane = ( {
pane,
activePaneId,
orientation,
}: {
pane: Pane;
activePaneId: PaneId;
orientation: 'vertical' | 'horizontal';
}): Pane => {
if (pane.type === 'leafPane') {
// convert the leafPane to a splitPane with two leafPane children
const newPaneId1 = activePaneId + 1;
const newLeafPane1: Pane = {
id: newPaneId1,
type: 'leafPane',
tabList: pane.tabList,
activeFileId: pane.activeFileId,
};
const newPaneId2 = activePaneId + 2;
const newLeafPane2: Pane = {
id: newPaneId2,
type: 'leafPane',
tabList: pane.tabList,
activeFileId: pane.activeFileId,
};
const newSplitPane: Pane = {
id: activePaneId,
type: 'splitPane',
orientation: orientation,
children: [newLeafPane1, newLeafPane2],
};
return newSplitPane;
}
else {
throw new Error('The pane is not a leafPane and cannot be split');
}

}