- Notifications
You must be signed in to change notification settings - Fork328
Dan doc nav no scroll#1388
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
22 changes: 13 additions & 9 deletionspgml-dashboard/src/components/cms/index_link/template.html
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
2 changes: 1 addition & 1 deletionpgml-dashboard/src/components/layouts/head/template.html
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
86 changes: 86 additions & 0 deletionspgml-dashboard/src/components/navigation/left_nav/docs/docs_controller.js
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
export default class extends Controller { | ||
static targets = [ | ||
"level1Container", | ||
"level1Link", | ||
"highLevels" | ||
]; | ||
// After page update we reset scroll position of nave back to where it was | ||
connect() { | ||
let nav = document.getElementsByClassName("doc-leftnav") | ||
if (nav.length > 0) { | ||
let position = nav[0].getAttribute("data-scroll") | ||
nav[0].scrollTop = position | ||
} | ||
} | ||
// trubo-frame permanent breakes bootstrap data attribute collapse for aria | ||
// so we manually controll collapse | ||
expand(e) { | ||
let aria = e.currentTarget.getAttribute("aria-expanded") | ||
let id = e.currentTarget.getAttribute("aria-controls") | ||
let bsCollapse = bootstrap.Collapse.getOrCreateInstance(document.getElementById(id)) | ||
if (aria === "true") { | ||
bsCollapse.hide() | ||
e.currentTarget.setAttribute("aria-expanded", "false") | ||
} else { | ||
bsCollapse.show() | ||
e.currentTarget.setAttribute("aria-expanded", "true") | ||
} | ||
} | ||
// Activly manage nav state for level 1 links | ||
onNavigateManageLevel1(e) { | ||
this.removeAllActive() | ||
let container = e.currentTarget.closest("div") | ||
container.classList.add("active") | ||
e.currentTarget.classList.add("active") | ||
this.preventScrollOnNav() | ||
} | ||
// Activly manage nav state for high level links | ||
onNavigateManageHighLevels(e) { | ||
this.removeAllActive() | ||
let container = e.currentTarget.closest('div[data-level="1"]') | ||
let menu = container.querySelector(".menu-item") | ||
let link = menu.querySelector(".doc-left-nav-level1-link-container") | ||
link.classList.add("active") | ||
e.currentTarget.classList.add("purple") | ||
this.preventScrollOnNav() | ||
} | ||
// trubo-frame permanent scrolles nav to top on navigation so we capture the scrroll position prior | ||
// to updating the page so after we can set the scroll position back to where it was | ||
preventScrollOnNav() { | ||
let nav = document.getElementsByClassName("doc-leftnav") | ||
if (nav.length > 0) { | ||
let position = nav[0].scrollTop; | ||
nav[0].setAttribute("data-scroll", position) | ||
} | ||
} | ||
// Helper function to quickly remove all state styling | ||
removeAllActive() { | ||
for(let i = 0; i < this.highLevelsTargets.length; i++) { | ||
this.highLevelsTargets[i].classList.remove("purple") | ||
} | ||
for (let i = 0; i < this.level1ContainerTargets.length; i++) { | ||
this.level1ContainerTargets[i].classList.remove("active") | ||
} | ||
for (let i = 0; i < this.level1LinkTargets.length; i++) { | ||
this.level1LinkTargets[i].classList.remove("active") | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletionspgml-dashboard/src/components/navigation/left_nav/docs/template.html
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
24 changes: 24 additions & 0 deletionspgml-dashboard/static/js/libs/turbo-7.3.0.custom.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
24 changes: 0 additions & 24 deletionspgml-dashboard/static/js/libs/turbo-7.3.0.min.js
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.