-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow admin sidebar to be collapsible
This will add extra space in smaller devices. We are setting a cookie via JS to remember user preferences throught users navigation. Co-authored-by: Michela Frecchiami <michela.frecchiami@gmail.com> Co-authored-by: Sean <seand7565@gmail.com> Co-authored-by: Thomas von Deyen <thomas@vondeyen.com> Co-authored-by: jacobherrington <jacobherringtondeveloper@gmail.com>
- Loading branch information
1 parent
a0e7066
commit b8e85fb
Showing
13 changed files
with
229 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
backend/app/assets/javascripts/spree/backend/components/admin_nav.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Spree.ready(function() { | ||
if (window.screen.width <= 1024 && !document.cookie.includes("admin_nav_hidden")) { | ||
// Set default nav to collapse on small screens - but don't override user preference | ||
document.body.classList.add("admin-nav-hidden"); | ||
document.cookie = "admin_nav_hidden=true; expires=Fri, 31 Dec 9999 23:59:59 GMT"; | ||
} | ||
|
||
var adminNavToggle = document.querySelector("#admin-nav-toggle"); | ||
|
||
if (adminNavToggle) { | ||
adminNavToggle.addEventListener("click", function(e) { | ||
e.preventDefault(); | ||
document.body.classList.toggle("admin-nav-hidden"); | ||
$(document.body).trigger("sticky_kit:recalc"); | ||
adminNavToggle.classList.toggle("fa-chevron-circle-left"); | ||
adminNavToggle.classList.toggle("fa-chevron-circle-right"); | ||
document.cookie = "admin_nav_hidden=" + document.body.classList.contains("admin-nav-hidden") + "; expires=Fri, 31 Dec 9999 23:59:59 GMT"; | ||
}); | ||
} | ||
|
||
if (document.body.classList.contains('admin-nav-hidden')) { | ||
$(adminNavToggle).removeClass('fa-chevron-circle-left').addClass('fa-chevron-circle-right'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
backend/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
backend/app/assets/stylesheets/spree/backend/shared/_header.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.