4
4
id =" resizable-panels-root"
5
5
class =" flex"
6
6
:class =" {
7
- 'select-none': panel1IsDragging || panel2IsDragging,
7
+ 'select-none': panel1IsDragging || panel2IsDragging || panel4IsDragging ,
8
8
}"
9
9
@mouseup =" handleMouseup"
10
10
@mousemove =" handleMousemove"
14
14
v-show =" showPanel1"
15
15
data-cy =" specs-list-panel"
16
16
class =" h-full shrink-0 z-20 relative"
17
- :style =" {width: `${panel1Width}px`}"
17
+ :style =" { width: `${panel1Width}px` }"
18
18
>
19
19
<slot
20
20
name =" panel1"
32
32
v-show =" showPanel2"
33
33
data-cy =" reporter-panel"
34
34
class =" h-full shrink-0 z-10 relative"
35
- :style =" {width: `${panel2Width}px`}"
35
+ :style =" { width: `${panel2Width}px` }"
36
36
>
37
37
<slot name =" panel2" />
38
38
46
46
<div
47
47
data-cy =" aut-panel"
48
48
class =" grow h-full bg-gray-100 relative"
49
- :class =" {'pointer-events-none':panel2IsDragging}"
49
+ :class =" { 'pointer-events-none': panel2IsDragging || panel4IsDragging }"
50
50
:style =" { width: `${panel3width}px` }"
51
51
>
52
52
<slot
58
58
<div
59
59
v-show =" showPanel4"
60
60
data-cy =" panel-4"
61
- class =" h-full bg-gray-100 relative"
62
- :style =" {width: `${panel4Width}px`}"
61
+ class =" h-full shrink-0 z-10 bg-gray-100 relative"
62
+ :style =" { width: `${panel4Width}px` }"
63
63
>
64
- <slot
65
- name =" panel4"
66
- :width =" panel4Width"
64
+ <slot name =" panel4" />
65
+
66
+ <div
67
+ data-cy =" panel4ResizeHandle"
68
+ class =" cursor-ew-resize h-full top-0 left-[-6px] w-[10px] z-30 absolute"
69
+ @mousedown =" handleMousedown('panel4', $event)"
67
70
/>
68
71
</div >
69
72
</div >
@@ -86,9 +89,11 @@ const props = withDefaults(defineProps<{
86
89
showPanel4? : boolean // studio in runner
87
90
initialPanel1Width? : number
88
91
initialPanel2Width? : number
92
+ initialPanel4Width? : number
89
93
minPanel1Width? : number
90
94
minPanel2Width? : number
91
95
minPanel3Width? : number
96
+ minPanel4Width? : number
92
97
maxTotalWidth? : number // windowWidth in runner
93
98
offsetLeft? : number
94
99
}>(), {
@@ -97,23 +102,28 @@ const props = withDefaults(defineProps<{
97
102
showPanel4: false ,
98
103
initialPanel1Width: runnerConstants .defaultSpecListWidth ,
99
104
initialPanel2Width: runnerConstants .defaultReporterWidth ,
105
+ initialPanel4Width: runnerConstants .defaultStudioWidth ,
100
106
minPanel1Width: 200 ,
101
107
minPanel2Width: 220 ,
102
108
minPanel3Width: 100 ,
109
+ minPanel4Width: 340 ,
103
110
maxTotalWidth: window .innerWidth ,
104
111
offsetLeft: 0 ,
105
112
})
106
113
107
114
const emit = defineEmits <{
108
115
(e : ' resizeEnd' , value : DraggablePanel ): void
109
- (e : ' panelWidthUpdated' , value : {panel: DraggablePanel , width: number }): void
116
+ (e : ' panelWidthUpdated' , value : { panel: DraggablePanel , width: number }): void
110
117
}>()
111
118
112
119
const panel1HandleX = ref (props .initialPanel1Width )
113
120
const panel2HandleX = ref (props .initialPanel2Width + props .initialPanel1Width )
121
+ const panel4HandleX = ref (props .initialPanel2Width + props .initialPanel1Width + props .initialPanel4Width )
114
122
const panel1IsDragging = ref (false )
115
123
const panel2IsDragging = ref (false )
124
+ const panel4IsDragging = ref (false )
116
125
const cachedPanel1Width = ref <number >(props .initialPanel1Width ) // because panel 1 (the inline specs list) can be opened and closed in the UI, we cache the width
126
+ const cachedPanel4Width = ref (props .initialPanel4Width )
117
127
const panel2Width = ref (props .initialPanel2Width )
118
128
119
129
const handleMousedown = (panel : DraggablePanel , event : MouseEvent ) => {
@@ -122,10 +132,13 @@ const handleMousedown = (panel: DraggablePanel, event: MouseEvent) => {
122
132
} else if (panel === ' panel2' ) {
123
133
panel2IsDragging .value = true
124
134
panel2HandleX .value = event .clientX
135
+ } else if (panel === ' panel4' ) {
136
+ panel4IsDragging .value = true
137
+ panel4HandleX .value = event .clientX
125
138
}
126
139
}
127
140
const handleMousemove = (event : MouseEvent ) => {
128
- if (! panel1IsDragging .value && ! panel2IsDragging .value ) {
141
+ if (! panel1IsDragging .value && ! panel2IsDragging .value && ! panel4IsDragging . value ) {
129
142
// nothing is dragging, ignore mousemove
130
143
131
144
return
@@ -139,6 +152,15 @@ const handleMousemove = (event: MouseEvent) => {
139
152
panel2HandleX .value = event .clientX
140
153
panel2Width .value = event .clientX - props .offsetLeft - panel1Width .value
141
154
emit (' panelWidthUpdated' , { panel: ' panel2' , width: panel2Width .value })
155
+ } else if (panel4IsDragging .value && isNewWidthAllowed (event .clientX , ' panel4' )) {
156
+ panel4HandleX .value = event .clientX
157
+ // Calculate width from the right edge of the window
158
+ // so that when we drag the panel to the left, it grows
159
+ // and when we drag it to the right, it shrinks
160
+ const rightEdge = props .maxTotalWidth + props .offsetLeft
161
+
162
+ cachedPanel4Width .value = rightEdge - event .clientX
163
+ emit (' panelWidthUpdated' , { panel: ' panel4' , width: panel4Width .value })
142
164
}
143
165
}
144
166
const handleMouseup = () => {
@@ -149,30 +171,37 @@ const handleMouseup = () => {
149
171
return
150
172
}
151
173
152
- handleResizeEnd (' panel2' )
153
- panel2IsDragging .value = false
174
+ if (panel2IsDragging .value ) {
175
+ handleResizeEnd (' panel2' )
176
+ panel2IsDragging .value = false
177
+ }
178
+
179
+ if (panel4IsDragging .value ) {
180
+ handleResizeEnd (' panel4' )
181
+ panel4IsDragging .value = false
182
+ }
154
183
}
155
184
156
185
const maxPanel1Width = computed (() => {
157
- const unavailableWidth = panel2Width .value + props .minPanel3Width
186
+ const unavailableWidth = panel2Width .value + props .minPanel3Width + panel4Width . value
158
187
159
188
return props .maxTotalWidth - unavailableWidth
160
189
})
161
190
162
- const panel4Width = computed (() => {
163
- if (! props .showPanel4 ) {
191
+ const panel1Width = computed (() => {
192
+ if (! props .showPanel1 ) {
164
193
return 0
165
194
}
166
195
167
- return runnerConstants . defaultStudioWidth
196
+ return cachedPanel1Width . value
168
197
})
169
198
170
- const panel1Width = computed (() => {
171
- if (! props .showPanel1 ) {
199
+ const panel4Width = computed (() => {
200
+ if (! props .showPanel4 ) {
172
201
return 0
173
202
}
174
203
175
- return cachedPanel1Width .value
204
+ return cachedPanel4Width .value
176
205
})
177
206
178
207
const maxPanel2Width = computed (() => {
@@ -192,6 +221,12 @@ const panel3width = computed(() => {
192
221
return panel3SpaceAvailable < props .minPanel3Width ? minimumWithBuffer : panel3SpaceAvailable
193
222
})
194
223
224
+ const maxPanel4Width = computed (() => {
225
+ const unavailableWidth = panel1Width .value + panel2Width .value + props .minPanel3Width
226
+
227
+ return props .maxTotalWidth - unavailableWidth
228
+ })
229
+
195
230
function handleResizeEnd (panel : DraggablePanel ) {
196
231
emit (' resizeEnd' , panel )
197
232
}
@@ -212,15 +247,29 @@ function isNewWidthAllowed (mouseClientX: number, panel: DraggablePanel) {
212
247
return result
213
248
}
214
249
215
- const newWidth = mouseClientX - props .offsetLeft - panel1Width .value
250
+ if (panel === ' panel2' ) {
251
+ const newWidth = mouseClientX - props .offsetLeft - panel1Width .value
252
+
253
+ if (isMaxWidthSmall && newWidth > fallbackWidth ) {
254
+ return true
255
+ }
256
+
257
+ return panel2IsDragging .value && newWidth >= props .minPanel2Width && newWidth <= maxPanel2Width .value
258
+ }
259
+
260
+ if (panel === ' panel4' ) {
261
+ const rightEdge = props .maxTotalWidth + props .offsetLeft
262
+ const newWidth = rightEdge - mouseClientX
263
+
264
+ if (isMaxWidthSmall && newWidth >= props .minPanel4Width ) {
265
+ return true
266
+ }
216
267
217
- if (isMaxWidthSmall && newWidth > fallbackWidth ) {
218
- return true
268
+ return panel4IsDragging .value && newWidth >= props .minPanel4Width && newWidth <= maxPanel4Width .value
219
269
}
220
270
221
- return panel2IsDragging . value && newWidth >= props . minPanel2Width && newWidth <= maxPanel2Width . value
271
+ return false
222
272
}
223
-
224
273
watchEffect (() => {
225
274
if (! props .showPanel1 ) {
226
275
emit (' panelWidthUpdated' , { panel: ' panel1' , width: 0 })
@@ -231,7 +280,7 @@ watchEffect(() => {
231
280
if (! props .showPanel4 ) {
232
281
emit (' panelWidthUpdated' , { panel: ' panel4' , width: 0 })
233
282
} else if (props .showPanel4 ) {
234
- emit (' panelWidthUpdated' , { panel: ' panel4' , width: panel4Width .value })
283
+ emit (' panelWidthUpdated' , { panel: ' panel4' , width: cachedPanel4Width .value })
235
284
}
236
285
})
237
286
0 commit comments