Skip to content

Commit 0451915

Browse files
author
Zehee
committed
fix: add expand button to sidebar rail when collapsed
- Show a ▶ expand button at the bottom of the rail when sidebar is collapsed - Keep the collapse button inside the sidebar when expanded
1 parent 1d68978 commit 0451915

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎src/vis/static/app.js‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159

160160
function renderRail() {
161161
const currentSection = sectionFor(state.currentView);
162-
$('#rail').innerHTML = sections
162+
const railItems = sections
163163
.map(
164164
(s) => `
165165
<div class="rail-item ${s.id === currentSection ? 'active' : ''}" data-section="${escapeHtml(
@@ -172,7 +172,15 @@
172172
)
173173
.join('');
174174

175-
$('#rail').querySelectorAll('.rail-item').forEach((el) => {
175+
const expandItem = state.sidebarCollapsed
176+
? `<div class="rail-item rail-expand" id="railExpandBtn" title="Expand sidebar"><span class="rail-icon">▶</span><span class="rail-label">Expand</span></div>`
177+
: '';
178+
179+
$('#rail').innerHTML = railItems + expandItem;
180+
181+
$('#railExpandBtn')?.addEventListener('click', toggleSidebar);
182+
183+
$('#rail').querySelectorAll('.rail-item[data-section]').forEach((el) => {
176184
el.addEventListener('click', () => {
177185
const section = el.dataset.section;
178186
const view = section === 'themes' && state.currentTheme ? `themes/${state.currentTheme}` : section;

‎src/vis/static/style.css‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ body {
103103
line-height: 1;
104104
}
105105

106+
.rail-expand {
107+
margin-top: auto;
108+
color: var(--blue);
109+
}
110+
111+
.rail-expand:hover {
112+
color: var(--blue2);
113+
}
114+
106115
.rail-label {
107116
position: absolute;
108117
left: 44px;

0 commit comments

Comments
 (0)