Skip to content

Commit 3d752d6

Browse files
authored
feat(ui): Restyle top navigation bar and banner (#309)
feat(ui): Restyle top navigation bar and banner - Add banner close functionality with 24-hour persistence <img width="1727" height="1038" alt="Screenshot 2025-07-16 at 6 22 40 PM" src="https://github.com/user-attachments/assets/818cc0f4-0b20-4fb9-9db9-55bab54ffe66" /> --------- Signed-off-by: Daniel Phillips <phiro56@gmail.com>
1 parent 9f230f0 commit 3d752d6

File tree

4 files changed

+77
-5
lines changed

4 files changed

+77
-5
lines changed

sass/_valkey.scss

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,16 +1426,37 @@ pre table {
14261426
}
14271427
}
14281428
}
1429+
1430+
html.banner-hidden .banner {
1431+
display: none;
1432+
}
14291433

14301434
.banner {
1435+
position: relative;
1436+
background-color: #2D2471;
1437+
color: white;
1438+
14311439
.width-limiter {
14321440
padding-bottom: 10px;
14331441
}
14341442

1435-
background-color: $grey-lt-300;
1436-
color: $text;
1437-
1438-
border-top: 1px solid $grey-dk-100;
1443+
a {
1444+
color: white;
1445+
text-decoration: underline;
1446+
1447+
&:hover {
1448+
opacity: 0.75;
1449+
}
1450+
}
1451+
1452+
.close-banner {
1453+
position: absolute;
1454+
top: 50%;
1455+
right: 2rem;
1456+
margin-top: -12px;
1457+
width: 24px;
1458+
height: 24px;
1459+
}
14391460
}
14401461

14411462
.client-list {

static/assets/js/nav.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ window.toggleHeaderMenu = function() {
66
}
77
};
88

9+
// Banner close functionality
10+
function initBannerClose() {
11+
const banner = document.querySelector('.banner');
12+
const closeButton = document.querySelector('.close-banner');
13+
14+
if (!banner || !closeButton) return;
15+
16+
// Add click event to close button
17+
closeButton.addEventListener('click', function(e) {
18+
e.preventDefault(); // Prevent navigation to home page
19+
document.documentElement.classList.add('banner-hidden');
20+
localStorage.setItem('bannerClosedTime', Date.now().toString());
21+
});
22+
}
23+
924
// Set active menu item based on current URL
1025
function setActiveMenuItem() {
1126
const nav = document.querySelector('.header nav');
@@ -30,7 +45,10 @@ function setActiveMenuItem() {
3045
}
3146

3247
// Run when DOM is loaded
33-
document.addEventListener('DOMContentLoaded', setActiveMenuItem);
48+
document.addEventListener('DOMContentLoaded', function() {
49+
setActiveMenuItem();
50+
initBannerClose();
51+
});
3452

3553
// Class detection function that checks if an element with a given class name exists
3654
// This provides backwards compatibility for older browsers (IE6-8) that don't support getElementsByClassName

static/img/icon-outline-close.svg

Lines changed: 13 additions & 0 deletions
Loading

templates/default.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
{%- block head -%}{%- endblock -%}<!DOCTYPE html>
22
<html lang="{{ page.lang | default(value=config.default_language) }}">
33
{% include "includes/head.html" %}
4+
<script>
5+
// Banner state management: Check localStorage before DOM renders to prevent layout shift
6+
// and ensure banner visibility state is consistent with user's previous interactions.
7+
(function() {
8+
const bannerClosedTime = localStorage.getItem('bannerClosedTime');
9+
if (bannerClosedTime) {
10+
const closedTime = parseInt(bannerClosedTime, 10);
11+
const twentyFourHours = 24 * 60 * 60 * 1000; // 24 hours in ms
12+
if (Date.now() - closedTime < twentyFourHours) {
13+
document.documentElement.classList.add('banner-hidden');
14+
} else {
15+
// Clear expired timestamp
16+
localStorage.removeItem('bannerClosedTime');
17+
}
18+
}
19+
})();
20+
</script>
421
<body
522
{%- if page.extra.sectionid -%} id="{{ page.extra.sectionid }}"{%- endif -%}
623
{% if page.extra.body_class %} class="{{ page.extra.body_class }}"{% endif %}
@@ -11,6 +28,9 @@
1128
<div class="width-limiter">
1229
{{ config.extra.banner | markdown | safe}}
1330
</div>
31+
<a href="/" class="close-banner">
32+
<img src="/img/icon-outline-close.svg" alt="Icon Close" width="16" height="16"/>
33+
</a>
1434
</div>
1535
{%- endif -%}
1636
<div class="header">

0 commit comments

Comments
 (0)