From 2b76b470837103f58d453c725d5b8a07d7c73fc1 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sat, 27 Dec 2025 10:15:16 +0100 Subject: [PATCH] improve header navigation styling and active link highlighting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optimize header link spacing and add visual feedback for active pages: - Reduce link padding and gap for more compact navigation - Shorten German labels: "In Saison" to "Saison", "Stichwörter" to "Tags" - Remove "Tipps" section from navigation menu Add active page highlighting across all layouts: - Highlight current page links in red (matching hover color) - Desktop: animated red underline that smoothly slides between links - Mobile: static red underline for active links in hamburger menu - Underline aligns precisely with text width (excludes padding) Improve transitions: - Fix color transition to only animate color, not layout properties - Disable underline transition during window resize to prevent lag - Underline updates immediately on resize for perfect alignment --- src/lib/components/Header.svelte | 101 ++++++++++++++++-- .../[recipeLang=recipeLang]/+layout.svelte | 29 +++-- src/routes/cospend/+layout.svelte | 18 +++- src/routes/glaube/+layout.svelte | 13 ++- 4 files changed, 135 insertions(+), 26 deletions(-) diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index 9c6f909..342dafa 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,8 +1,13 @@ @@ -39,7 +94,7 @@ nav[hidden]{ :global(a.entry) { list-style-type:none; - transition: 100ms; + transition: color 100ms; color: white; user-select: none; } @@ -51,11 +106,12 @@ nav[hidden]{ font-size: 1.2rem; color: inherit; border-radius: 1000px; - padding: 0.5rem 1rem; + padding: 0.5rem 0.75rem; } :global(.site_header li:hover), :global(.site_header li:focus-within), +:global(.site_header li:has(a.active)), :global(.entry:hover), :global(.entry:focus-visible) { @@ -66,12 +122,27 @@ nav[hidden]{ padding-block: 1.5rem; display: flex; flex-direction: row; - gap: 1rem; + gap: 0.5rem; justify-content: space-evenly; max-width: 1000px; margin: 0; margin-inline: auto; } +.links-wrapper { + position: relative; + flex: 1; +} +.active-underline { + position: absolute; + bottom: 1.2rem; + height: 2px; + background-color: var(--red); + transition: left 300ms ease-out, width 300ms ease-out; + pointer-events: none; +} +.active-underline.no-transition { + transition: none; +} .nav_button{ display: none; } @@ -158,7 +229,7 @@ footer{ height: 100vh; /* dvh does not work, breaks because of transition and only being applied after scroll ends*/ margin-bottom: 50vh; width: min(95svw, 25em); - transition: 100ms; + transition: transform 100ms; z-index: 10; flex-direction: column; justify-content: flex-start !important; @@ -199,6 +270,15 @@ footer{ .language-selector-desktop{ display: none; } + .active-underline { + display: none; + } + :global(.nav_site .site_header a.active) { + text-decoration: underline; + text-decoration-color: var(--red); + text-decoration-thickness: 2px; + text-underline-offset: 0.3rem; + } }
@@ -213,7 +293,10 @@ footer{