1
- import { createSignal } from "solid-js " ;
2
- import { A , useLocation } from "@solidjs/router" ;
1
+ import { useLocation } from "@solidjs/router " ;
2
+ import { A } from "@solidjs/router" ;
3
3
import {
4
4
BsHouseFill ,
5
5
BsPeopleFill ,
@@ -13,14 +13,17 @@ import { Logo } from "./Logo";
13
13
export default function MobileMenu ( ) {
14
14
const location = useLocation ( ) ;
15
15
const isActive = ( path ) => location . pathname === path ;
16
- const [ isOpen , setIsOpen ] = createSignal ( false ) ;
17
-
18
- const toggleMenu = ( ) => {
19
- setIsOpen ( ! isOpen ( ) ) ;
20
- } ;
21
16
22
17
return (
23
18
< div class = "fixed top-0 left-0 right-0 z-50 md:hidden" >
19
+ { /* Checkbox for the toggle - placed at the top level */ }
20
+ < input
21
+ type = "checkbox"
22
+ id = "mobile-menu-toggle"
23
+ class = "hidden peer"
24
+ aria-label = "Toggle menu"
25
+ />
26
+
24
27
{ /* Header with background */ }
25
28
< div class = "glass !rounded-none !px-4 !py-2 flex justify-between items-center" >
26
29
{ /* Logo on the left */ }
@@ -30,27 +33,26 @@ export default function MobileMenu() {
30
33
</ div >
31
34
</ A >
32
35
33
- { /* Burger Button on the right */ }
34
- < button
35
- onClick = { toggleMenu }
36
- class = "text-white p-2"
36
+ { /* Burger Button on the right - using checkbox hack */ }
37
+ < label
38
+ for = "mobile-menu-toggle"
39
+ class = "text-white p-2 cursor-pointer block "
37
40
aria-label = "Toggle menu"
38
41
>
39
- { isOpen ( ) ? < BsX size = { 30 } /> : < BsList size = { 30 } /> }
40
- </ button >
42
+ < BsList size = { 30 } class = "peer-checked:hidden" />
43
+ < BsX size = { 30 } class = "hidden peer-checked:block" />
44
+ </ label >
41
45
</ div >
42
46
43
- { /* Mobile Menu Dropdown */ }
44
- { isOpen ( ) && (
45
- < div class = "absolute top-full left-0 right-0 burger-menu" >
46
- < div class = "glass !p-4 !rounded-none" >
47
+ { /* Mobile Menu Dropdown - visible when checkbox is checked */ }
48
+ < div class = "absolute top-full left-0 right-0 burger-menu hidden peer-checked:block" >
49
+ < div class = "glass !p-4 !rounded-none" >
47
50
< nav class = "flex flex-col space-y-4" >
48
51
{ /* Home */ }
49
52
< A
50
53
href = "/"
51
54
class = { `text-white hover:text-white/80 transition-all duration-75 font-bold text-lg flex items-center justify-end gap-2 ${ isActive ( '/' ) ? 'underline' : '' } ` }
52
55
aria-label = "Home"
53
- onClick = { ( ) => setIsOpen ( false ) }
54
56
>
55
57
< BsHouseFill />
56
58
Home
@@ -61,7 +63,6 @@ export default function MobileMenu() {
61
63
href = "/sponsorship"
62
64
class = { `text-white hover:text-white/80 transition-all duration-75 font-bold text-lg flex items-center justify-end gap-2 ${ isActive ( '/sponsorship' ) ? 'underline' : '' } ` }
63
65
aria-label = "Sponsorship"
64
- onClick = { ( ) => setIsOpen ( false ) }
65
66
>
66
67
< BiSolidHeartCircle />
67
68
Sponsorship
@@ -72,7 +73,6 @@ export default function MobileMenu() {
72
73
href = "/hotels"
73
74
class = { `text-white hover:text-white/80 transition-all duration-75 font-bold text-lg flex items-center justify-end gap-2 ${ isActive ( '/hotels' ) ? 'underline' : '' } ` }
74
75
aria-label = "Hotels"
75
- onClick = { ( ) => setIsOpen ( false ) }
76
76
>
77
77
< FaSolidHotel />
78
78
Hotels
@@ -83,15 +83,13 @@ export default function MobileMenu() {
83
83
href = "/organizers"
84
84
class = { `text-white hover:text-white/80 transition-all duration-75 font-bold text-lg flex items-center justify-end gap-2 ${ isActive ( '/organizers' ) ? 'underline' : '' } ` }
85
85
aria-label = "Organizers"
86
- onClick = { ( ) => setIsOpen ( false ) }
87
86
>
88
87
< BsPeopleFill />
89
88
Organizers
90
89
</ A >
91
90
</ nav >
92
91
</ div >
93
92
</ div >
94
- ) }
95
93
</ div >
96
94
) ;
97
95
}
0 commit comments