-
Notifications
You must be signed in to change notification settings - Fork 49
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
Scrolling breadcrumb bar #181
base: main
Are you sure you want to change the base?
Conversation
Hey @jwflory😊, I've refactored the breadcrumb bar such that now it hides while scrolling. The title on the navbar is thereafter replaced by the breadcrumb. For fixing the issue, I have added a script tag in the |
Hey @BhavyaT-135, thanks for your patience all this time. I'll add a review here soon. |
No problem @jwflory, take your time! 😊 |
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.
Hey @BhavyaT-135, nice work! I cloned this locally and the change worked great. There is room for smoother transitions and animations, but I think it can be addressed in a later PR. The design of this is ready to go.
However, there is invalid HTML because multiple <nav>
elements were used in the DOM when there can only be just one. We should follow HTML best practices and make sure that the <nav>
is only included once in the DOM. This helps other accessibility devices or scrappers understand the layout of the site more easily.
I left some other comments, but really this is the one thing blocking this from merging. Once it is cleaned up and retested, this should be ready to merge. Let me know if you have any questions! I appreciate your patience in working on this. 🙌🏻
layouts/partials/navigation.html
Outdated
{{ $logo:= site.Params.logo }} | ||
{{ $orgName:= site.Params.brand.parent_org_name }} | ||
{{ $orgUrl:= site.Params.brand.parent_org_url }} | ||
<div> |
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.
Was there a reason to add a <div>
tag outside of the the <nav>
section? This div wraps around the navigation element which feels awkward.
layouts/partials/navigation.html
Outdated
</nav> | ||
<nav id="breadcrumbNav"> |
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.
This is not valid HTML. There should only be one <nav>
tag in the DOM. Instead, keep a single <nav>
on the start and end of this file, and use <div>
tags to create the styling you need.
layouts/partials/navigation.html
Outdated
<script> | ||
var topPosition; | ||
|
||
breadcrumbNav = document.getElementById('breadcrumbNav'); | ||
|
||
navbarHeading = document.getElementById('navbarHeading'); | ||
|
||
navbarBreadcrumb = document.getElementById('navbarBreadcrumb'); | ||
|
||
topPosition = window.pageYOffset; | ||
|
||
window.addEventListener('scroll', function () { | ||
|
||
var scrollPosition = window.pageYOffset || document.documentElement.scrollTop; | ||
|
||
if (scrollPosition > topPosition) { | ||
breadcrumbNav.style.display = 'none'; | ||
navbarHeading.style.display = 'none'; | ||
navbarBreadcrumb.style.display = 'block'; | ||
} | ||
|
||
</div> | ||
{{ end }} | ||
</nav> | ||
else { | ||
breadcrumbNav.style.display = 'block'; | ||
navbarHeading.style.display = 'block'; | ||
navbarBreadcrumb.style.display = 'none'; | ||
} | ||
}); | ||
</script> |
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.
This is simple enough, but I wonder if it would help maintainability if this script were loaded in <head>
instead of here. This way, we could load all JavaScript bits consistently throughout the site, so there is less confusion about how to embed scripts into the DOM.
This change isn't required to merge, but I'd consider it a bonus if you have time to figure out a way to do this similar to other scripts loaded into the DOM.
Hey @jwflory, sorry for the late response. I've been a little busy with my university examinations. Will implement the changes as soon as I get some time. 😊 |
Hey @jwflory, I hope this resolves the issue of the multiple |
Fixes #164