Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts / expand-navbar.js
blob: 4cea31cc3e22b9c5363f99141794107941dfd093 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const expandBtn = document.getElementById('expandNavbarBtn');
const sidebarElem = document.getElementById('sidebar');

if (localStorage.getItem('navbar') === 'hidden' || window.innerWidth <= 610 || window.innerHeight <= 610) {
	expandBtn.innerText = '\u25BC';
	sidebarElem.classList.add('sidebar-hidden');
}

expandBtn.onclick = function() {
	sidebarElem.classList.toggle('sidebar-hidden');

	if (!sidebarElem.classList.contains('sidebar-hidden')) {
		expandBtn.innerText = '\u25B2'; // triangle pointing up
		if (window.innerWidth > 610) localStorage.setItem('navbar', 'norm');
	}
	else {
		expandBtn.innerText = '\u25BC'; // triangle pointing down
		if (window.innerWidth > 610) localStorage.setItem('navbar', 'hidden');
	}
}