Skip to content

Commit

Permalink
Update sidebar.js
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaBarget authored Feb 7, 2025
1 parent 0917806 commit 26ea081
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions assets/js/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
document.addEventListener("DOMContentLoaded", function () {
const sidebar = document.querySelector(".sidebar");
const toggleButton = document.getElementById("toggle-sidebar");
const content = document.querySelector(".content");

toggleButton.addEventListener("click", function () {
sidebar.classList.toggle("closed");

// Ensure content has proper margin when sidebar is hidden
if (sidebar.classList.contains("closed")) {
content.style.marginLeft = "40px"; /* Moves text away from the left edge */
} else {
content.style.marginLeft = "270px"; /* Restores default spacing */
}
});
});

0 comments on commit 26ea081

Please sign in to comment.