From cc480b35e71d402a23d39f689242548c5b6b7996 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Tue, 18 Nov 2025 15:29:33 +0100 Subject: [PATCH] fix: make nested links clickable in recipe cards Use the card wrapper pattern with absolute positioned main link and elevated z-index for nested links. This maintains proper HTML semantics (no nested tags) while allowing category, icon, and tag links to be clickable. - Replace outer wrapper with
- Add invisible overlay link for main card click area (z-index: 1) - Elevate nested links (category, tags, icon) with z-index: 10 - Maintain all existing hover effects and accessibility - Keep semantic HTML structure without nesting tags --- src/lib/components/Card.svelte | 40 +++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/lib/components/Card.svelte b/src/lib/components/Card.svelte index c9ce3e3..09bb269 100644 --- a/src/lib/components/Card.svelte +++ b/src/lib/components/Card.svelte @@ -34,6 +34,25 @@ const img_name=recipe.short_name + ".webp?v=" + recipe.dateModified border-radius: 20px; cursor: pointer; display: inline-block; + text-decoration: none; + color: inherit; +} +.card-main-link { + position: absolute; + inset: 0; + z-index: 1; + text-decoration: none; +} +.card-main-link .visually-hidden { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0,0,0,0); + white-space: nowrap; + border: 0; } .card{ --card-width: 300px; @@ -73,7 +92,8 @@ const img_name=recipe.short_name + ".webp?v=" + recipe.dateModified font-size: 1.5em; box-shadow: 0em 0em 1em 0.1em rgba(0, 0, 0, 0.6); transition: 100ms; - z-index: 5; + z-index: 10; + text-decoration: none; } #image{ width: 300px; @@ -148,7 +168,7 @@ const img_name=recipe.short_name + ".webp?v=" + recipe.dateModified } .tag{ cursor: pointer; - text-decoration: unset; + text-decoration: none; background-color: var(--nord4); color: var(--nord0); border-radius: 100px; @@ -158,6 +178,9 @@ const img_name=recipe.short_name + ".webp?v=" + recipe.dateModified transition: 100ms; box-shadow: 0em 0em 0.2em 0.05em rgba(0, 0, 0, 0.3); border: none; + position: relative; + z-index: 10; + display: inline-block; } .tag:hover, .tag:focus-visible @@ -184,6 +207,8 @@ const img_name=recipe.short_name + ".webp?v=" + recipe.dateModified transition: 100ms; border: none; cursor: pointer; + z-index: 10; + display: inline-block; } .card_title .category:hover, .card_title .category:focus-within @@ -226,8 +251,11 @@ const img_name=recipe.short_name + ".webp?v=" + recipe.dateModified } -
window.location.href = `/rezepte/${recipe.short_name}`}> +
+ + View recipe: {recipe.name} +