Skip to content

Commit ff742ec

Browse files
committed
feat(pages): improve left sidebar resize handles
1 parent de0d259 commit ff742ec

File tree

3 files changed

+81
-31
lines changed

3 files changed

+81
-31
lines changed

apps/client/src/layouts/PagesLayout/LeftSidebar/CurrentPath.vue

+32-11
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,9 @@
6161
style="position: relative"
6262
>
6363
<div
64-
style="
65-
position: absolute;
66-
left: 0;
67-
top: -12px;
68-
right: 0;
69-
bottom: -12px;
70-
cursor: ns-resize;
71-
z-index: 2147483647;
72-
"
73-
@pointerdown="resizeSection"
64+
class="resize-handle"
65+
@pointerdown="resizeHandlePointerDown"
66+
@dblclick="resizeHandleDoubleClick"
7467
></div>
7568
</div>
7669

@@ -83,7 +76,7 @@ import type { ComponentPublicInstance } from 'vue';
8376
8477
const listRef = ref<ComponentPublicInstance>();
8578
86-
function resizeSection(downEvent: PointerEvent) {
79+
function resizeHandlePointerDown(downEvent: PointerEvent) {
8780
listenPointerEvents(downEvent, {
8881
move(moveEvent) {
8982
const clientRect = listRef.value!.$el.getBoundingClientRect();
@@ -105,4 +98,32 @@ function resizeSection(downEvent: PointerEvent) {
10598
},
10699
});
107100
}
101+
102+
function resizeHandleDoubleClick() {
103+
const avgWeight =
104+
(uiStore().currentPathWeight + uiStore().recentPagesWeight) / 2;
105+
106+
uiStore().currentPathWeight = avgWeight;
107+
uiStore().recentPagesWeight = avgWeight;
108+
}
108109
</script>
110+
111+
<style scoped lang="scss">
112+
.resize-handle {
113+
position: absolute;
114+
left: 0;
115+
top: -6px;
116+
right: 0;
117+
bottom: -6px;
118+
cursor: ns-resize;
119+
z-index: 2147483647;
120+
121+
opacity: 0;
122+
background-color: white;
123+
124+
transition: opacity 0.2s;
125+
}
126+
.resize-handle:hover {
127+
opacity: 0.4;
128+
}
129+
</style>

apps/client/src/layouts/PagesLayout/LeftSidebar/LeftSidebar.vue

+19-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@
1111
style="display: flex; flex-direction: column; background-color: #212121"
1212
>
1313
<div
14-
style="
15-
position: absolute;
16-
top: 0;
17-
bottom: 0;
18-
right: -12px;
19-
width: 12px;
20-
cursor: ew-resize;
21-
z-index: 2147483647;
22-
"
14+
class="resize-handle"
2315
@pointerdown="resizeLeftSidebar"
2416
@dblclick="() => uiStore().resetLeftSidebarWidth()"
2517
></div>
@@ -54,4 +46,22 @@ function resizeLeftSidebar(event: PointerEvent) {
5446
border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
5547
}
5648
}
49+
50+
.resize-handle {
51+
position: absolute;
52+
top: 0;
53+
bottom: 0;
54+
right: -10px;
55+
left: calc(100% + 1px);
56+
cursor: ew-resize;
57+
z-index: 2147483647;
58+
59+
opacity: 0;
60+
background-color: white;
61+
62+
transition: opacity 0.2s;
63+
}
64+
.resize-handle:hover {
65+
opacity: 0.4;
66+
}
5767
</style>

apps/client/src/layouts/PagesLayout/LeftSidebar/RecentPages.vue

+30-11
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,9 @@
7272
v-if="uiStore().recentPagesExpanded && uiStore().selectedPagesExpanded"
7373
>
7474
<div
75-
style="
76-
position: absolute;
77-
left: 0;
78-
top: -12px;
79-
right: 0;
80-
bottom: -12px;
81-
cursor: ns-resize;
82-
z-index: 2147483647;
83-
"
84-
@pointerdown="resizeSection"
75+
class="resize-handle"
76+
@pointerdown="resizeHandlePointerDown"
77+
@dblclick="resizeHandleDoubleClick"
8578
></div>
8679
</div>
8780

@@ -96,7 +89,7 @@ import type { ComponentPublicInstance } from 'vue';
9689
9790
const listRef = ref<ComponentPublicInstance>();
9891
99-
function resizeSection(downEvent: PointerEvent) {
92+
function resizeHandlePointerDown(downEvent: PointerEvent) {
10093
listenPointerEvents(downEvent, {
10194
move(moveEvent) {
10295
const clientRect = listRef.value!.$el.getBoundingClientRect();
@@ -133,6 +126,14 @@ async function removeRecentPage(pageId: string) {
133126
handleError(error);
134127
}
135128
}
129+
130+
function resizeHandleDoubleClick() {
131+
const avgWeight =
132+
(uiStore().recentPagesWeight + uiStore().selectedPagesWeight) / 2;
133+
134+
uiStore().recentPagesWeight = avgWeight;
135+
uiStore().selectedPagesWeight = avgWeight;
136+
}
136137
</script>
137138

138139
<style scoped lang="scss">
@@ -160,4 +161,22 @@ async function removeRecentPage(pageId: string) {
160161
.recent-page:hover > .remove-btn {
161162
opacity: 1;
162163
}
164+
165+
.resize-handle {
166+
position: absolute;
167+
left: 0;
168+
top: -6px;
169+
right: 0;
170+
bottom: -6px;
171+
cursor: ns-resize;
172+
z-index: 2147483647;
173+
174+
opacity: 0;
175+
background-color: white;
176+
177+
transition: opacity 0.2s;
178+
}
179+
.resize-handle:hover {
180+
opacity: 0.4;
181+
}
163182
</style>

0 commit comments

Comments
 (0)