the cart hover only when possible
Some checks failed
CI / Check Style (push) Has been cancelled
CI / Run Clippy (push) Has been cancelled
CI / Run Tests (push) Has been cancelled

This commit is contained in:
Priec
2026-06-20 12:22:31 +02:00
parent 0310f2d2f4
commit 3da840c0c9

View File

@@ -48,6 +48,12 @@
if (!v) return 0;
return v.split(',').reduce(function (s, e) { return s + (parseInt(e.split(':')[1]) || 0) }, 0);
}
// True while any other navbar menu (profile / settings / mobile / category
// toggle) is open — those triggers expose aria-expanded="true". Used to
// suppress the cart hover preview so menus don't stack/overlap.
function anyMenuOpen() {
return !!document.querySelector('header [aria-expanded="true"]');
}
// Show a floating toast notification. Usage: toast('Saved').
// Bridges to the vendored Penguin UI toast component, which listens for a
// `notify` event with { variant, title, message }.
@@ -113,7 +119,7 @@
x-on:keydown.esc.window="isOpen = false"
class="relative">
<a href="/cart" data-nav="/cart" hx-boost="false"
x-on:mouseenter="isOpen = true"
x-on:mouseenter="if (!anyMenuOpen()) isOpen = true"
x-data="{ count: 0 }"
x-init="count = cartCount(); ['htmx:afterSwap', 'htmx:afterRequest'].forEach(function (e) { window.addEventListener(e, function () { count = cartCount() }) })"
hx-get="/partials/cart" hx-trigger="mouseenter delay:150ms" hx-target="#cart-preview-body" hx-swap="innerHTML"