Skip to content

feat(ui): Restyle top navigation bar and banner #309

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 21 additions & 4 deletions sass/_valkey.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1360,14 +1360,31 @@ pre table {
}

.banner {
position: relative;
background-color: #2D2471;
color: white;

.width-limiter {
padding-bottom: 10px;
}

background-color: $grey-lt-300;
color: $text;

border-top: 1px solid $grey-dk-100;
a {
color: white;
text-decoration: underline;

&:hover {
opacity: 0.75;
}
}

.close-banner {
position: absolute;
top: 50%;
right: 2rem;
margin-top: -12px;
width: 24px;
height: 24px;
}
}

.client-list {
Expand Down
34 changes: 33 additions & 1 deletion static/assets/js/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,35 @@ window.toggleHeaderMenu = function() {
}
};

// Banner close functionality
function initBannerClose() {
const banner = document.querySelector('.banner');
const closeButton = document.querySelector('.close-banner');

if (!banner || !closeButton) return;

// Check if banner was previously closed within 24s
const bannerClosedTime = localStorage.getItem('bannerClosedTime');
const now = Date.now();
if (bannerClosedTime) {
const closedTime = parseInt(bannerClosedTime, 10);
const twentyFourHours = 24 * 60* 60 *1000; // 24 hours in ms
if (now - closedTime < twentyFourHours) {
banner.style.display = 'none';
return;
} else {
// Clear expired timestamp
localStorage.removeItem('bannerClosedTime');
}
}
// Add click event to close button
closeButton.addEventListener('click', function(e) {
e.preventDefault(); // Prevent navigation to home page
banner.style.display = 'none';
localStorage.setItem('bannerClosedTime', Date.now().toString());
});
}

// Set active menu item based on current URL
function setActiveMenuItem() {
const nav = document.querySelector('.header nav');
Expand All @@ -30,7 +59,10 @@ function setActiveMenuItem() {
}

// Run when DOM is loaded
document.addEventListener('DOMContentLoaded', setActiveMenuItem);
document.addEventListener('DOMContentLoaded', function() {
setActiveMenuItem();
initBannerClose();
});

// Class detection function that checks if an element with a given class name exists
// This provides backwards compatibility for older browsers (IE6-8) that don't support getElementsByClassName
Expand Down
3 changes: 3 additions & 0 deletions templates/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<div class="width-limiter">
{{ config.extra.banner | markdown | safe}}
</div>
<a href="/" class="close-banner">
<img src="/img/icon-outline-close.svg" alt="Icon Close" width="24" height="24"/>
</a>
</div>
{%- endif -%}
<div class="header">
Expand Down