Sticky header, dim overlay on card navigation, fix sticky stacking

Make header sticky so search button stays visible on scroll. Section
headers stick below it using a JS-measured --header-height variable.
Add dim overlay behind highlighted cards for better focus effect.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-25 02:55:23 +03:00
parent 83800e71fa
commit 2b6bc22fc8
5 changed files with 46 additions and 5 deletions

View File

@@ -2,10 +2,11 @@ header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 8px 0 6px; padding: 8px 0 12px;
margin-bottom: 6px; position: sticky;
position: relative; top: 0;
z-index: 100; z-index: 100;
background: var(--bg-color);
} }
.header-title { .header-title {

View File

@@ -74,7 +74,7 @@
@keyframes cardHighlight { @keyframes cardHighlight {
0%, 100% { box-shadow: none; } 0%, 100% { box-shadow: none; }
25%, 75% { box-shadow: 0 0 0 3px var(--primary-color); } 25%, 75% { box-shadow: 0 0 0 3px var(--primary-color), 0 0 20px rgba(var(--primary-rgb, 59, 130, 246), 0.3); }
} }
.card-highlight, .card-highlight,
@@ -84,6 +84,21 @@
z-index: 11; z-index: 11;
} }
/* Dim overlay behind highlighted card */
.nav-dim-overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.4);
z-index: 10;
pointer-events: none;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
.nav-dim-overlay.active {
opacity: 1;
}
/* Key Colors target styles */ /* Key Colors target styles */
.kc-rect-list { .kc-rect-list {
display: flex; display: flex;

View File

@@ -644,7 +644,7 @@
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
position: sticky; position: sticky;
top: 0; top: var(--header-height, 0px);
z-index: 10; z-index: 10;
background: var(--bg-color); background: var(--bg-color);
padding: 8px 0; padding: 8px 0;

View File

@@ -427,6 +427,18 @@ document.addEventListener('DOMContentLoaded', async () => {
// Show content now that translations are loaded and tabs are set // Show content now that translations are loaded and tabs are set
document.body.style.visibility = 'visible'; document.body.style.visibility = 'visible';
// Set CSS variable for sticky header height so section headers stack below it
const headerEl = document.querySelector('header');
if (headerEl) {
const updateHeaderHeight = () => {
document.documentElement.style.setProperty(
'--header-height', headerEl.offsetHeight + 'px'
);
};
updateHeaderHeight();
window.addEventListener('resize', updateHeaderHeight);
}
// Initialize command palette // Initialize command palette
initCommandPalette(); initCommandPalette();

View File

@@ -46,11 +46,24 @@ export function navigateToCard(tab, subTab, sectionKey, cardAttr, cardValue) {
if (!card) return; if (!card) return;
card.scrollIntoView({ behavior: 'smooth', block: 'center' }); card.scrollIntoView({ behavior: 'smooth', block: 'center' });
card.classList.add('card-highlight'); card.classList.add('card-highlight');
_showDimOverlay(2000);
setTimeout(() => card.classList.remove('card-highlight'), 2000); setTimeout(() => card.classList.remove('card-highlight'), 2000);
}); });
}); });
} }
function _showDimOverlay(duration) {
let overlay = document.getElementById('nav-dim-overlay');
if (!overlay) {
overlay = document.createElement('div');
overlay.id = 'nav-dim-overlay';
overlay.className = 'nav-dim-overlay';
document.body.appendChild(overlay);
}
overlay.classList.add('active');
setTimeout(() => overlay.classList.remove('active'), duration);
}
function _waitForCard(cardAttr, cardValue, timeout) { function _waitForCard(cardAttr, cardValue, timeout) {
return new Promise(resolve => { return new Promise(resolve => {
const card = document.querySelector(`[${cardAttr}="${cardValue}"]`); const card = document.querySelector(`[${cardAttr}="${cardValue}"]`);