mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Default sidebar to collapsed on mobile
On screens <= 768px, the sidebar now defaults to collapsed for first-time visitors. User preference is still saved and respected on subsequent visits. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1354,13 +1354,18 @@
|
||||
(function() {
|
||||
var toggle = document.getElementById('sidebar-toggle');
|
||||
var savedState = localStorage.getItem('sidebarExpanded');
|
||||
// If user has explicitly collapsed the sidebar, respect that
|
||||
var isMobile = window.innerWidth <= 768;
|
||||
|
||||
// If user has explicitly set a preference, respect that
|
||||
if (savedState === 'false') {
|
||||
toggle.checked = false;
|
||||
} else if (savedState === 'true') {
|
||||
toggle.checked = true;
|
||||
} else {
|
||||
// No saved state - default to collapsed on mobile, expanded on desktop
|
||||
toggle.checked = !isMobile;
|
||||
}
|
||||
// Default is checked (expanded) if no saved state
|
||||
|
||||
toggle.addEventListener('change', function() {
|
||||
localStorage.setItem('sidebarExpanded', toggle.checked ? 'true' : 'false');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user