Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BhavyaT-135
Copy link

Fixes #164

@BhavyaT-135
Copy link
Author

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 navigation.html partial that takes care of the scroll position and modifies the components accordingly.

@jwflory jwflory added T: improvement Improves on something that already exists C: design thinking Planning and creative thinking about design elements in new features or improvements labels Nov 25, 2022
@jwflory jwflory self-assigned this Nov 25, 2022
@jwflory
Copy link
Member

jwflory commented Nov 25, 2022

Hey @BhavyaT-135, thanks for your patience all this time. I'll add a review here soon.

@BhavyaT-135
Copy link
Author

No problem @jwflory, take your time! 😊

Copy link
Member

@jwflory jwflory left a 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. 🙌🏻

{{ $logo:= site.Params.logo }}
{{ $orgName:= site.Params.brand.parent_org_name }}
{{ $orgUrl:= site.Params.brand.parent_org_url }}
<div>
Copy link
Member

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.

Comment on lines 78 to 79
</nav>
<nav id="breadcrumbNav">
Copy link
Member

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.

Comment on lines 102 to 129
<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>
Copy link
Member

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.

@BhavyaT-135
Copy link
Author

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. 😊

@BhavyaT-135
Copy link
Author

Hey @jwflory, I hope this resolves the issue of the multiple nav tags used in the DOM. Looking forward to getting this PR merged. Kindly let me know if anything else needs an amendment. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: design thinking Planning and creative thinking about design elements in new features or improvements T: improvement Improves on something that already exists
Projects
Status: In progress
2 participants