the cart hover only when possible
This commit is contained in:
@@ -48,6 +48,12 @@
|
|||||||
if (!v) return 0;
|
if (!v) return 0;
|
||||||
return v.split(',').reduce(function (s, e) { return s + (parseInt(e.split(':')[1]) || 0) }, 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').
|
// Show a floating toast notification. Usage: toast('Saved').
|
||||||
// Bridges to the vendored Penguin UI toast component, which listens for a
|
// Bridges to the vendored Penguin UI toast component, which listens for a
|
||||||
// `notify` event with { variant, title, message }.
|
// `notify` event with { variant, title, message }.
|
||||||
@@ -113,7 +119,7 @@
|
|||||||
x-on:keydown.esc.window="isOpen = false"
|
x-on:keydown.esc.window="isOpen = false"
|
||||||
class="relative">
|
class="relative">
|
||||||
<a href="/cart" data-nav="/cart" hx-boost="false"
|
<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-data="{ count: 0 }"
|
||||||
x-init="count = cartCount(); ['htmx:afterSwap', 'htmx:afterRequest'].forEach(function (e) { window.addEventListener(e, function () { count = cartCount() }) })"
|
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"
|
hx-get="/partials/cart" hx-trigger="mouseenter delay:150ms" hx-target="#cart-preview-body" hx-swap="innerHTML"
|
||||||
|
|||||||
Reference in New Issue
Block a user