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

[Backport 2.5] Add shadow to version selector panel when left nav is scrolled #6172

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</a>
</div>
<nav role="navigation" aria-label="Main" id="site-nav" class="site-nav">
<div class="version-wrapper">
<div class="version-wrapper" id="version-panel">
{% if page.section == "opensearch" %}
<a href="{{site.url}}{{site.baseurl}}/about/" class="site-category">{{ page.section-name }}</a>
{% else %}
Expand Down
4 changes: 4 additions & 0 deletions _sass/custom/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ code {
margin-right: 0.5rem;
}

.nav-shadow {
box-shadow: 0 6px 4px -4px $grey-lt-300;
}

.main-content {
ol {
> li {
Expand Down
11 changes: 10 additions & 1 deletion assets/js/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const numCharsLabel = document.getElementById('num-chars');
const sendButton = document.getElementById('send');
const commentTextArea = document.getElementById('comment');
const thankYouText = document.getElementById('thank-you');

const nav = document.getElementById('site-nav');
const versionPanel = document.getElementById('version-panel');
document.addEventListener('DOMContentLoaded', updateTextArea);

document.addEventListener('click', function(event) {
Expand Down Expand Up @@ -32,6 +33,14 @@ document.addEventListener('click', function(event) {
}
});

nav.addEventListener('scroll',(e)=>{
if(nav.scrollTop > 0){
versionPanel.classList.add("nav-shadow");
}else{
versionPanel.classList.remove("nav-shadow");
}
});

commentTextArea.addEventListener('input', updateTextArea);

function updateTextArea() {
Expand Down
Loading