1
+ import { styled } from '@stitches/react'
1
2
import Link from 'next/link'
3
+ import { relative } from 'path'
2
4
import { GithubLogo } from 'phosphor-react'
5
+ import { useState } from 'react'
6
+ import { Box } from './Box'
3
7
import { Flex } from './Flex'
4
8
import { IconButton } from './IconButton'
5
9
import Logo from './Logo'
10
+ import NavMenu from './NavMenu'
6
11
import SearchButton from './SearchButton'
7
12
import { Text } from './Text'
8
13
9
14
const GITHUB_URL = 'https://github.com/csesoc/learning-platform'
15
+ const navItems = [
16
+ {
17
+ 'path' : 'articles' ,
18
+ 'title' : 'Collection' ,
19
+ } ,
20
+ {
21
+ 'path' : 'creators' ,
22
+ 'title' : 'Contribute' ,
23
+ } ,
24
+ {
25
+ 'path' : '2521-revision-practical' ,
26
+ 'title' : 'COMP2521' ,
27
+ } ,
28
+ {
29
+ 'path' : 'opendev' ,
30
+ 'title' : 'Open Dev Series' ,
31
+ } ,
32
+
33
+
34
+ ]
35
+
36
+ const NavContainer = styled ( 'div' , {
37
+ display : 'block' ,
38
+ flexFlow : 'column nowrap' ,
39
+ position : "fixed" ,
40
+ left : "100vw" ,
41
+ right : "inherit" ,
42
+ top : 0 ,
43
+ transform : "translateX(100vw)" ,
44
+ variants : {
45
+ isOpen : {
46
+ true : {
47
+ // transform: "translateX(30vw)",
48
+ left : "inherit" ,
49
+ right : "100vw" ,
50
+ }
51
+ }
52
+ } ,
53
+ backgroundColor : '#e8ebed' ,
54
+ boxShadow : "0px 0px 31px -19px rgba(0,0,0,0.54)" ,
55
+ width : '100vw' ,
56
+ maxWidth : '548px' ,
57
+ height : '100vh' ,
58
+ zIndex : 5 ,
59
+ padding : "4rem" ,
60
+ fontSize : "2.4rem" ,
61
+ lineHeight : "4.4rem" ,
62
+ "@media screen and (min-width: 768px)" : {
63
+ display : "flex" ,
64
+ fontSize : "1rem" ,
65
+ lineHeight : "inherit" ,
66
+ flexFlow : "row nowrap" ,
67
+ gap : '2.25rem' ,
68
+ justifyContent : 'center' ,
69
+ position : "relative" ,
70
+ left : "inherit" ,
71
+ right : "inherit" ,
72
+ transform : "none" ,
73
+ backgroundColor : 'transparent' ,
74
+ padding : "0" ,
75
+ width : 'auto' ,
76
+ height : "inherit" ,
77
+ } ,
78
+ } )
79
+
80
+ const Layer = styled ( 'div' , {
81
+ display : "block" ,
82
+ content : "" ,
83
+ backgroundColor : 'black' ,
84
+ width : "100%" ,
85
+ height : '3px' ,
86
+ variants : {
87
+ isOpen : {
88
+ true : {
89
+ backgroundColor : "CornflowerBlue"
90
+ }
91
+ }
92
+ }
93
+
94
+ } )
95
+
96
+ const TopBun = styled ( Layer , {
97
+
98
+ } )
99
+
100
+ const Filling = styled ( Layer , {
101
+
102
+ } )
103
+
104
+ const BottomBun = styled ( Layer , {
105
+
106
+ } )
107
+
108
+ const Burger = styled ( 'div' , {
109
+ display : "flex" ,
110
+ flexFlow : "column nowrap" ,
111
+ justifyContent : "space-between" ,
112
+ width : "22px" ,
113
+ height : '16px' ,
114
+ cursor : "pointer" ,
115
+ "@media screen and (min-width: 768px)" : {
116
+ display : "none" ,
117
+ } ,
118
+ zIndex : 10 ,
119
+ } )
10
120
11
121
export default function Navbar ( ) {
122
+ const [ isOpen , setIsOpen ] = useState ( false ) ;
123
+
12
124
return (
13
125
< Flex
14
126
as = "header"
15
127
css = { {
16
128
py : '$4' ,
17
129
px : '$6' ,
18
130
alignItems : 'center' ,
19
- zIndex : '1'
131
+ zIndex : '1' ,
132
+ position : 'fixed' ,
133
+ width : "100%" ,
134
+ background : "linear-gradient(180deg, rgba(244,244,244,1) 0%, rgba(244,244,244,1) 90%, rgba(244,244,244,0.8084599921043882) 96%, rgba(244,244,244,0) 100%)" ,
20
135
} } >
21
136
< Flex css = { { flex : 1 , justifyContent : 'flex-start' } } >
22
137
< Link href = "/" >
@@ -31,54 +146,21 @@ export default function Navbar() {
31
146
</ button >
32
147
</ Link >
33
148
</ Flex >
34
- < Flex
35
- css = { {
36
- flex : 1 ,
37
- gap : '2.25rem' ,
38
- justifyContent : 'center'
39
- } } >
40
- < Link href = "/articles" >
41
- < Text
42
- as = "a"
43
- size = "label-lg"
44
- css = { { color : '$slate12' , cursor : 'pointer' } } >
45
- Collection
46
- </ Text >
47
- </ Link >
48
- < Link href = "/creators" >
49
- < Text
50
- as = "a"
51
- size = "label-lg"
52
- css = { {
53
- color : '$slate12' ,
54
- cursor : 'pointer'
55
- } } >
56
- Creators
57
- </ Text >
58
- </ Link >
59
- < Link href = "/opendev" >
60
- < Text
61
- as = "a"
62
- size = "label-lg"
63
- css = { {
64
- color : '$slate12' ,
65
- cursor : 'pointer'
66
- } } >
67
- Open Dev
68
- </ Text >
69
- </ Link >
70
- < Link href = "/2521-revision-practical" >
71
- < Text
72
- as = "a"
73
- size = "label-lg"
74
- css = { {
75
- color : '$slate12' ,
76
- cursor : 'pointer'
77
- } } >
78
- COMP2521
79
- </ Text >
80
- </ Link >
81
- < Text
149
+ < NavContainer isOpen = { isOpen } >
150
+ { navItems . map ( ( navItem , idx ) => (
151
+ < Link key = { idx } href = { `/${ navItem . path } ` } >
152
+ < Text
153
+ as = "a"
154
+ css = { { color : '$slate12' , cursor : 'pointer' } }
155
+ onClick = { ( ) => { setIsOpen ( false ) ; console . log ( 'hi' ) } } >
156
+ { navItem . title }
157
+
158
+ </ Text >
159
+ </ Link >
160
+
161
+ )
162
+ ) }
163
+ { /* <Text
82
164
as="a"
83
165
size="label-lg"
84
166
css={{
@@ -87,21 +169,38 @@ export default function Navbar() {
87
169
cursor: 'not-allowed'
88
170
}}>
89
171
About
90
- </ Text >
91
- </ Flex >
92
- < Flex
172
+ </Text> */ }
173
+ </ NavContainer >
174
+ < Box css = { {
175
+ display : isOpen ? "block" : "none" ,
176
+ position : "absolute" ,
177
+ left : "0" ,
178
+ top : "0" ,
179
+ background : "rgb(0,0,0,0.3)" ,
180
+ width : "100vw" ,
181
+ height : "100vh" ,
182
+ zIndex : 3 ,
183
+
184
+ } } > </ Box >
185
+ < Burger onClick = { ( ) => setIsOpen ( ( val ) => ! val ) } >
186
+ < TopBun isOpen = { isOpen } > </ TopBun >
187
+ < Filling isOpen = { isOpen } > </ Filling >
188
+ < BottomBun isOpen = { isOpen } > </ BottomBun >
189
+ </ Burger >
190
+ { /* <Flex
93
191
css={{
94
192
flex: 1,
95
193
gap: '$3',
96
194
justifyContent: 'flex-end'
97
195
}}>
98
- { /* <SearchButton /> */ }
196
+ <SearchButton />
99
197
<IconButton aria-label="GitHub repository for CSESoc Learn">
100
198
<a href={GITHUB_URL} target="_blank" rel="noreferrer">
101
199
<GithubLogo weight="fill" />
102
200
</a>
103
201
</IconButton>
104
- </ Flex >
202
+ </Flex> */ }
105
203
</ Flex >
204
+
106
205
)
107
206
}
0 commit comments