fix(mobile-menu): move store to head and use explicit state transitions to prevent re-opening
All checks were successful
Deploy Theme / deploy (push) Successful in 14s
All checks were successful
Deploy Theme / deploy (push) Successful in 14s
This commit is contained in:
15
default.hbs
15
default.hbs
@@ -12,7 +12,6 @@
|
||||
}
|
||||
}"
|
||||
:data-theme="theme"
|
||||
@htmx:before-request.window="$store.mobileMenu.close()"
|
||||
class="hidden">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@@ -24,6 +23,20 @@
|
||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.0"></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('alpine:init', () => {
|
||||
Alpine.store('mobileMenu', {
|
||||
open: false,
|
||||
close() { this.open = false; },
|
||||
openMenu() { this.open = true; }
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('htmx:beforeRequest', () => {
|
||||
if (window.Alpine) Alpine.store('mobileMenu').close();
|
||||
});
|
||||
</script>
|
||||
|
||||
{{ghost_head}}
|
||||
</head>
|
||||
<body class="{{body_class}} font-sans antialiased" hx-boost="true">
|
||||
|
||||
Reference in New Issue
Block a user