Summary Files Commits Branches @commit @diff @stats
path: root / src / scripts / expand-navbar.js
blob: c254ae55352fa09086572059a46376cd1c28e90d (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) {
	expandBtn.innerHTML = '&#x25BC;';
	sidebarElem.classList.add('sidebar-hidden');
}

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

	if (!sidebarElem.classList.contains('sidebar-hidden')) {
		expandBtn.innerHTML = '&#x25B2;';
		if (window.innerWidth > 610) localStorage.setItem('navbar', 'norm');
	}
	else {
		expandBtn.innerHTML = '&#x25BC;';
		if (window.innerWidth > 610) localStorage.setItem('navbar', 'hidden');
	}
}