Skip to content

Scrolling breadcrumb bar #181

Open
BhavyaT-135 wants to merge 2 commits into
unicef:mainfrom
BhavyaT-135:breadcrumb-refactor
Open

Scrolling breadcrumb bar #181
BhavyaT-135 wants to merge 2 commits into
unicef:mainfrom
BhavyaT-135:breadcrumb-refactor

Conversation

@BhavyaT-135

Copy link
Copy Markdown

Fixes #164

@BhavyaT-135

Copy link
Copy Markdown
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.

@justwheel justwheel 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
@justwheel justwheel self-assigned this Nov 25, 2022
@justwheel

Copy link
Copy Markdown
Member

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

@BhavyaT-135

Copy link
Copy Markdown
Author

No problem @jwflory, take your time! 😊

@justwheel justwheel left a comment

Copy link
Copy Markdown
Member

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. 🙌🏻

Comment thread layouts/partials/navigation.html Outdated
{{ $logo:= site.Params.logo }}
{{ $orgName:= site.Params.brand.parent_org_name }}
{{ $orgUrl:= site.Params.brand.parent_org_url }}
<div>

Copy link
Copy Markdown
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 thread layouts/partials/navigation.html Outdated
Comment on lines +78 to +79
</nav>
<nav id="breadcrumbNav">

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

As a reader, I want the top navigation to be tighter so that there is less noise when scrolling in an article/page.

2 participants