Skip to content

Commit 198d7cd

Browse files
committed
Allow center pane to be collapsed
1 parent df3cbf5 commit 198d7cd

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

etc/js/components/pages/entities/page.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
ref="pane_content"
2626
v-model:tab="appParams.entities.tab"
2727
v-model:scripts="appParams.scripts"
28-
@onCodeChange="onCodeChange">
28+
@onCodeChange="onCodeChange"
29+
v-show="!rootEl?.centerPaneHidden">
2930
</pane-content>
3031

3132
<splitter

etc/js/components/widgets/pane-container.vue

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const defaultLeftPaneWidth = 300;
2727
const defaultRightPaneWidth = 500;
2828
const minLeftPaneWidth = 180;
2929
const minRightPaneWidth = 320;
30-
const minCenterWidth = 200;
30+
const hideCenterThreshold = 100;
31+
32+
const containerWidth = ref(0);
3133
3234
const leftPaneWidth = ref(Number(localStorage.getItem(`${props.id}.leftPaneWidth`)) || defaultLeftPaneWidth);
3335
const rightPaneWidth = ref(Number(localStorage.getItem(`${props.id}.rightPaneWidth`)) || defaultRightPaneWidth);
@@ -36,18 +38,19 @@ let dragging = null; // 'sidebar' | 'inspector' | null
3638
let containerRect = null;
3739
3840
function clampLeftPane(width, totalInnerWidth) {
39-
const max = totalInnerWidth - (props.showRightPane ? (rightPaneWidth.value + minCenterWidth) : minCenterWidth);
41+
const max = totalInnerWidth - (props.showRightPane ? rightPaneWidth.value : 0);
4042
return Math.max(minLeftPaneWidth, Math.min(width, max));
4143
}
4244
4345
function clampRightPane(width, totalInnerWidth) {
44-
const max = totalInnerWidth - (props.showLeftPane ? (leftPaneWidth.value + minCenterWidth) : minCenterWidth);
46+
const max = totalInnerWidth - (props.showLeftPane ? leftPaneWidth.value : 0);
4547
return Math.max(minRightPaneWidth, Math.min(width, max));
4648
}
4749
4850
function onWindowMouseMove(e) {
4951
if (!dragging || !containerRect) return;
5052
const totalInnerWidth = containerRect.width; // grid area width
53+
containerWidth.value = totalInnerWidth;
5154
if (dragging === 'leftPane') {
5255
const newWidth = clampLeftPane(e.clientX - containerRect.left, totalInnerWidth);
5356
leftPaneWidth.value = Math.round(newWidth);
@@ -57,6 +60,7 @@ function onWindowMouseMove(e) {
5760
rightPaneWidth.value = Math.round(newWidth);
5861
localStorage.setItem(`${props.id}.rightPaneWidth`, String(rightPaneWidth.value));
5962
}
63+
updateCenterHidden(dragging === 'rightPane');
6064
// Notify canvas to resize while dragging
6165
window.dispatchEvent(new Event('resize'));
6266
}
@@ -96,6 +100,7 @@ function ensureWidthsFit() {
96100
if (!rootEl.value) return;
97101
const el = rootEl.value;
98102
const rect = el.getBoundingClientRect();
103+
containerWidth.value = rect.width;
99104
100105
const hasLeftPane = props.showLeftPane;
101106
const hasRightPane = props.showRightPane;
@@ -115,27 +120,55 @@ function ensureWidthsFit() {
115120
rightPaneWidth.value = Math.round(right);
116121
localStorage.setItem(`${props.id}.rightPaneWidth`, String(rightPaneWidth.value));
117122
}
123+
124+
updateCenterHidden(false);
125+
}
126+
127+
const centerPaneHidden = ref(false);
128+
129+
function getCenterAvailable() {
130+
let available = containerWidth.value;
131+
if (props.showLeftPane) available -= leftPaneWidth.value;
132+
if (props.showRightPane) available -= rightPaneWidth.value;
133+
return available;
134+
}
135+
136+
// Any source can collapse the center pane, but only the right pane
137+
// splitter can uncollapse it.
138+
function updateCenterHidden(canUncollapse) {
139+
if (getCenterAvailable() < hideCenterThreshold) {
140+
centerPaneHidden.value = true;
141+
} else if (canUncollapse) {
142+
centerPaneHidden.value = false;
143+
}
118144
}
119145
120146
const gridStyle = computed(() => {
121147
// Use split columns as the visual gaps/handles; container gap is 0
122148
const split = `var(--gap)`;
149+
const hideCenter = centerPaneHidden.value;
123150
if (props.showLeftPane && props.showRightPane) {
124151
const left = `${leftPaneWidth.value}px`;
152+
if (hideCenter) {
153+
return `grid-template-columns: ${left} ${split} 0px ${split} 1fr;`;
154+
}
125155
const right = `${rightPaneWidth.value}px`;
126156
return `grid-template-columns: ${left} ${split} 1fr ${split} ${right};`;
127157
} else if (props.showLeftPane && !props.showRightPane) {
128158
const left = `${leftPaneWidth.value}px`;
129159
return `grid-template-columns: ${left} ${split} 1fr;`;
130160
} else if (!props.showLeftPane && props.showRightPane) {
161+
if (hideCenter) {
162+
return `grid-template-columns: 0px ${split} 1fr;`;
163+
}
131164
const right = `${rightPaneWidth.value}px`;
132165
return `grid-template-columns: 1fr ${split} ${right};`;
133166
} else {
134167
return `grid-template-columns: 1fr;`;
135168
}
136169
});
137170
138-
defineExpose({startDragging});
171+
defineExpose({startDragging, centerPaneHidden});
139172
140173
</script>
141174

0 commit comments

Comments
 (0)