Skip to content

Commit a191873

Browse files
committed
Make the sidebar resizable, closes #1842
1 parent b25bf28 commit a191873

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

assets/css/layout.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ body {
77

88
body {
99
--sidebarWidth: 300px;
10+
--sidebarMinWidth: 300px;
1011
--sidebarTransitionDuration: 0.3s;
1112
background-color: var(--background);
1213
color: var(--textBody);
@@ -23,19 +24,20 @@ body {
2324

2425
.main {
2526
display: flex;
26-
justify-content: flex-end;
2727
height: 100%;
2828
}
2929

3030
.sidebar {
3131
display: flex;
3232
flex-direction: column;
3333
width: var(--sidebarWidth);
34+
min-width: var(--sidebarMinWidth);
3435
height: 100%;
3536
position: fixed;
3637
top: 0;
3738
left: 0;
3839
z-index: 100;
40+
resize: horizontal;
3941
}
4042

4143
.sidebar-button {

assets/css/search-bar.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
height: 57px;
129129
left: 56px;
130130
right: 20px;
131-
transition: top 0.3s;
131+
transition: top var(--sidebarTransitionDuration) ease-in-out;
132132
z-index: 99;
133133
}
134134

@@ -139,7 +139,7 @@
139139
right: 0;
140140
height: 70px;
141141
background-color: var(--background);
142-
transition: top 0.3s;
142+
transition: all var(--sidebarTransitionDuration) ease-in-out;
143143
z-index: 98;
144144
}
145145

assets/js/sidebar/sidebar-drawer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,11 @@ function setPreference () {
204204
: (state.sidebarPreference = userPref.CLOSED)
205205
}
206206
}
207+
208+
const resizeObserver = new ResizeObserver((entries) => {
209+
for (const entry of entries) {
210+
document.body.style.setProperty('--sidebarWidth', `${entry.contentRect.width}px`);
211+
}
212+
});
213+
214+
resizeObserver.observe(document.getElementById('sidebar'));

0 commit comments

Comments
 (0)