-
-
Notifications
You must be signed in to change notification settings - Fork 67
"Updated Sidebar Design and Responsiveness" #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2d4e3a1
Updated sidebar responsiveness
ONKARBH 9a1085e
Updated Sidebar Design and Responsiveness
ONKARBH 644876e
Update Sidebar Styling and Apply Color Modifications
ONKARBH bc390c7
Merge changes from onkar/209
ONKARBH 2a1eeef
Corrected all code issues accidentally left during GitHub merge
ONKARBH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,57 +1,45 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
// Make tables responsive | ||
document.querySelectorAll("table.docutils").forEach((table) => { | ||
table.outerHTML = `<div class="responsive-table__container">${table.outerHTML}</div>`; | ||
}); | ||
|
||
// Make tables responsive by wrapping them in a div and making them scrollable | ||
const tables = document.querySelectorAll("table.docutils") | ||
tables.forEach(function(table){ | ||
table.outerHTML = '<div class="responsive-table__container">' + table.outerHTML + "</div>" | ||
}) | ||
const togglerInput = document.querySelector(".toggler__input"); | ||
const togglerLabel = document.querySelector(".toggler__label"); | ||
const sideMenu = document.querySelector(".menu-wrapper"); | ||
const body = document.body; | ||
|
||
const togglerInput = document.querySelector(".toggler__input") | ||
const togglerLabel = document.querySelector(".toggler__label") | ||
const sideMenu = document.querySelector(".menu-wrapper") | ||
const menuItems = document.querySelectorAll(".menu") | ||
const doc = document.querySelector(".document") | ||
const body = document.querySelector("body") | ||
const closeMenu = () => { | ||
togglerInput.checked = false; | ||
sideMenu.setAttribute("aria-expanded", "false"); | ||
sideMenu.setAttribute("aria-hidden", "true"); | ||
togglerLabel.setAttribute("aria-pressed", "false"); | ||
body.style.overflow = "visible"; | ||
}; | ||
|
||
function closeMenu() { | ||
togglerInput.checked = false | ||
sideMenu.setAttribute("aria-expanded", "false") | ||
sideMenu.setAttribute("aria-hidden", "true") | ||
togglerLabel.setAttribute("aria-pressed", "false") | ||
body.style.overflow = "visible" | ||
} | ||
function openMenu() { | ||
togglerInput.checked = true | ||
sideMenu.setAttribute("aria-expanded", "true") | ||
sideMenu.setAttribute("aria-hidden", "false") | ||
togglerLabel.setAttribute("aria-pressed", "true") | ||
body.style.overflow = "hidden" | ||
} | ||
const openMenu = () => { | ||
togglerInput.checked = true; | ||
sideMenu.setAttribute("aria-expanded", "true"); | ||
sideMenu.setAttribute("aria-hidden", "false"); | ||
togglerLabel.setAttribute("aria-pressed", "true"); | ||
body.style.overflow = "hidden"; | ||
}; | ||
|
||
// Close menu when link on the sideMenu is clicked | ||
sideMenu.addEventListener("click", function (event) { | ||
let target = event.target | ||
if (target.tagName.toLowerCase() !== "a") { | ||
return | ||
} | ||
closeMenu() | ||
}) | ||
// Add accessibility data when sideMenu is opened/closed | ||
togglerInput.addEventListener("change", function (_event) { | ||
togglerInput.checked ? openMenu() : closeMenu() | ||
}) | ||
// Make sideMenu links tabbable only when visible | ||
for(let menuItem of menuItems) { | ||
if(togglerInput.checked) { | ||
menuItem.setAttribute("tabindex", "0") | ||
} else { | ||
menuItem.setAttribute("tabindex", "-1") | ||
} | ||
} | ||
// Close sideMenu when document body is clicked | ||
doc.addEventListener("click", function () { | ||
if (togglerInput.checked) { | ||
closeMenu() | ||
} | ||
}) | ||
}) | ||
// Toggle menu accessibility attributes | ||
togglerInput.addEventListener("change", () => { | ||
togglerInput.checked ? openMenu() : closeMenu(); | ||
sideMenu.querySelectorAll(".menu").forEach((menuItem) => { | ||
menuItem.setAttribute("tabindex", togglerInput.checked ? "0" : "-1"); | ||
}); | ||
}); | ||
|
||
// Close menu when a link inside the sideMenu is clicked | ||
sideMenu.addEventListener("click", (event) => { | ||
if (event.target.closest("a")) closeMenu(); | ||
}); | ||
|
||
// Close menu when the document body is clicked | ||
document.querySelector(".document").addEventListener("click", () => { | ||
if (togglerInput.checked) closeMenu(); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain which of the changes in this file are relevant? As far as I can tell, they are all stylistic.