Skip to content

Commit fe0f33b

Browse files
committed
add resizable panel
Signed-off-by: Aayush Kumar <[email protected]>
1 parent 633e5df commit fe0f33b

File tree

1 file changed

+115
-5
lines changed

1 file changed

+115
-5
lines changed

scanpipe/templates/scanpipe/resource_tree.html

Lines changed: 115 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,64 @@
1111
.chevron.rotated {
1212
transform: rotate(90deg);
1313
}
14+
15+
.resizable-container {
16+
display: flex;
17+
height: calc(100vh - 140px);
18+
margin: 0;
19+
}
20+
21+
.left-pane {
22+
min-width: 0;
23+
max-width: 100%;
24+
border-right: 1px solid #ccc;
25+
overflow-y: auto;
26+
overflow-x: hidden;
27+
flex-basis: 33.333%;
28+
transition: opacity 0.2s ease;
29+
}
30+
31+
.left-pane.collapsed {
32+
opacity: 0;
33+
pointer-events: none;
34+
}
35+
36+
.resizer {
37+
width: 5px;
38+
background: #ddd;
39+
cursor: col-resize;
40+
position: relative;
41+
flex-shrink: 0;
42+
}
43+
44+
.resizer:hover {
45+
background: #bbb;
46+
}
47+
48+
.resizer::before {
49+
content: '';
50+
position: absolute;
51+
top: 50%;
52+
left: 1px;
53+
transform: translateY(-50%);
54+
width: 3px;
55+
height: 30px;
56+
background: #999;
57+
border-radius: 2px;
58+
}
59+
60+
.right-pane {
61+
flex: 1;
62+
overflow-y: auto;
63+
overflow-x: hidden;
64+
min-width: 0;
65+
transition: opacity 0.2s ease;
66+
}
67+
68+
.right-pane.collapsed {
69+
opacity: 0;
70+
pointer-events: none;
71+
}
1472
</style>
1573
{% endblock %}
1674

@@ -24,14 +82,15 @@
2482
</section>
2583
</div>
2684

27-
<div class="columns is-gapless is-mobile" style="height: calc(100vh - 140px); margin: 0;">
28-
<div class="column is-one-third" style="border-right: 1px solid #ccc; overflow-y: auto; overflow-x: hidden;">
85+
<div class="resizable-container">
86+
<div class="left-pane" id="left-pane">
2987
<div id="resource-tree" class="p-4">
3088
{% include "scanpipe/panels/codebase_tree_panel.html" with children=children path=path %}
3189
</div>
3290
</div>
33-
<div class="column" style="overflow-y: auto; overflow-x: hidden;">
34-
<div id="right-pane" class="p-4">
91+
<div class="resizer" id="resizer"></div>
92+
<div class="right-pane" id="right-pane">
93+
<div class="p-4">
3594
{% include "scanpipe/panels/resource_table_panel.html" %}
3695
</div>
3796
</div>
@@ -40,6 +99,7 @@
4099

41100
{% block scripts %}
42101
<script>
102+
// Tree functionality
43103
document.addEventListener("click", async function (e) {
44104
const chevron = e.target.closest("[data-chevron]");
45105
if (chevron) {
@@ -63,8 +123,58 @@
63123
e.stopPropagation();
64124
return;
65125
}
66-
67126
});
68127

128+
document.addEventListener("DOMContentLoaded", function() {
129+
const resizer = document.getElementById('resizer');
130+
const leftPane = document.getElementById('left-pane');
131+
const rightPane = document.getElementById('right-pane');
132+
let isResizing = false;
133+
134+
resizer.addEventListener('mousedown', function(e) {
135+
isResizing = true;
136+
document.body.style.cursor = 'col-resize';
137+
document.body.style.userSelect = 'none';
138+
e.preventDefault();
139+
});
140+
141+
document.addEventListener('mousemove', function(e) {
142+
if (!isResizing) return;
143+
144+
const container = document.querySelector('.resizable-container');
145+
const containerRect = container.getBoundingClientRect();
146+
const newLeftWidth = e.clientX - containerRect.left;
147+
const containerWidth = containerRect.width;
148+
const resizerWidth = 5;
149+
150+
const leftPercent = (newLeftWidth / containerWidth) * 100;
151+
const rightPercent = ((containerWidth - newLeftWidth - resizerWidth) / containerWidth) * 100;
152+
153+
if (leftPercent <= 2) {
154+
leftPane.style.flexBasis = '0%';
155+
rightPane.style.flexBasis = '100%';
156+
leftPane.classList.add('collapsed');
157+
rightPane.classList.remove('collapsed');
158+
} else if (rightPercent <= 2) {
159+
leftPane.style.flexBasis = '100%';
160+
rightPane.style.flexBasis = '0%';
161+
leftPane.classList.remove('collapsed');
162+
rightPane.classList.add('collapsed');
163+
} else {
164+
leftPane.style.flexBasis = leftPercent + '%';
165+
rightPane.style.flexBasis = rightPercent + '%';
166+
leftPane.classList.remove('collapsed');
167+
rightPane.classList.remove('collapsed');
168+
}
169+
});
170+
171+
document.addEventListener('mouseup', function() {
172+
if (isResizing) {
173+
isResizing = false;
174+
document.body.style.cursor = '';
175+
document.body.style.userSelect = '';
176+
}
177+
});
178+
});
69179
</script>
70180
{% endblock %}

0 commit comments

Comments
 (0)