1
+ import { useOuterClick } from '../../hooks/useOuterClick' ;
2
+ import NavbarLink from './NavbarLink' ;
3
+ import { useEffect , useState } from 'react' ;
4
+ import NavbarMenuItem from './NavbarMenuItem' ;
5
+
6
+ export default function NavbarMenu ( { show, pages, close } ) {
7
+ const innerRef = useOuterClick ( ( ) => ! show || close ( ) ) ;
8
+ const [ rendering , setRendering ] = useState ( true ) ;
9
+ useEffect ( ( ) => setRendering ( false ) )
10
+
11
+ const menuStyle = {
12
+ position : 'fixed' ,
13
+ top : 0 ,
14
+ right : 0 ,
15
+ zIndex : 100 ,
16
+ width : '400px' ,
17
+ maxWidth : '80%' ,
18
+ height : '100%' ,
19
+ transform : `translateX(${ show ? '0' : '100vw' } )` ,
20
+ transition : 'transform 0.3s ease' ,
21
+ background : 'linear-gradient(to top, #900202, #d13c06)' ,
22
+ display : 'flex' ,
23
+ flexDirection : 'column' ,
24
+ gap : '8px' ,
25
+ boxShadow : '0 0 10px 0 rgba(0, 0, 0, 0.5)' ,
26
+ } ;
27
+
28
+ const circleDecorationStyle = {
29
+ position : 'absolute' ,
30
+ bottom : '-400px' ,
31
+ left : '100px' ,
32
+ width : 'calc(100% - 40px)' ,
33
+ borderRadius : '50%' ,
34
+ height : '700px' ,
35
+ width : '700px' ,
36
+ background : 'black' ,
37
+ opacity : 0.3 ,
38
+ border : '120px dashed #d13c06' ,
39
+ }
40
+
41
+ const backgroundDarkenerStyle = {
42
+ position : 'fixed' ,
43
+ top : 0 ,
44
+ left : 0 ,
45
+ zIndex : 99 ,
46
+ width : '100%' ,
47
+ height : '100%' ,
48
+ background : show ? 'rgba(0, 0, 0, 0.5)' : 'transparent' ,
49
+ pointerEvents : show ? 'auto' : 'none' ,
50
+ transition : 'background 0.3s ease' ,
51
+ }
52
+
53
+ const menuTitleStyle = {
54
+ color : 'white' ,
55
+ fontSize : '30px' ,
56
+ fontWeight : '700' ,
57
+ }
58
+
59
+ return rendering || (
60
+ < >
61
+ < div
62
+ className = "p-3"
63
+ ref = { innerRef }
64
+ onClick = { close }
65
+ style = { menuStyle }
66
+ >
67
+
68
+ < div style = { circleDecorationStyle } > </ div >
69
+
70
+ < h1 style = { menuTitleStyle } >
71
+ Browse BUILD
72
+ </ h1 >
73
+
74
+ { pages . map ( ( page , i ) => (
75
+ < NavbarLink
76
+ page = { page }
77
+ key = { i }
78
+ linkDisplay = { < NavbarMenuItem page = { page } /> }
79
+ > </ NavbarLink >
80
+ ) ) }
81
+
82
+ </ div >
83
+
84
+ < div
85
+ style = { backgroundDarkenerStyle }
86
+ onClick = { close }
87
+ > </ div >
88
+ </ >
89
+ ) ;
90
+ }
0 commit comments