8
8
* SPDX-License-Identifier: EPL-2.0
9
9
********************************************************************************/
10
10
11
- import React , { FunctionComponent , useState , useRef , useContext } from 'react' ;
12
- import { Theme , Typography , Menu , MenuItem , Link , Button , Accordion , AccordionDetails , AccordionSummary , IconButton } from '@mui/material' ;
11
+ import React , { FunctionComponent , PropsWithChildren , useState , useRef } from 'react' ;
12
+ import { Theme , Typography , Menu , MenuItem , Link , Button , Accordion , AccordionDetails , AccordionSummary } from '@mui/material' ;
13
13
import { styled } from '@mui/material/styles' ;
14
14
import { Link as RouteLink } from 'react-router-dom' ;
15
15
import ExpandMoreIcon from '@mui/icons-material/ExpandMore' ;
@@ -22,41 +22,33 @@ import PublishIcon from '@mui/icons-material/Publish';
22
22
import GroupWorkIcon from '@mui/icons-material/GroupWork' ;
23
23
import PeopleAltIcon from '@mui/icons-material/PeopleAlt' ;
24
24
import HubIcon from '@mui/icons-material/Hub' ;
25
- import AccountBoxIcon from '@mui/icons-material/AccountBox' ;
26
25
import { UserSettingsRoutes } from 'openvsx-webui' ;
27
- import { MainContext } from 'openvsx-webui/lib/context' ;
28
- import { MobileMenuItem , itemIcon , MobileMenuItemText , MobileUserAvatar , headerItem , MenuLink , MenuRouteLink } from 'openvsx-webui/lib/default/menu-content'
29
- import { UserAvatar } from 'openvsx-webui/lib/pages/user/avatar' ;
30
26
31
27
//-------------------- Mobile View --------------------//
32
28
29
+ const MobileMenuItem = styled ( MenuItem ) ( {
30
+ cursor : 'auto' ,
31
+ '&>a' : {
32
+ textDecoration : 'none'
33
+ }
34
+ } ) ;
35
+
36
+ const itemIcon = {
37
+ mr : 1 ,
38
+ width : '16px' ,
39
+ height : '16px' ,
40
+ } ;
41
+
42
+ const MobileMenuItemText : FunctionComponent < PropsWithChildren > = ( { children } ) => {
43
+ return (
44
+ < Typography variant = 'body2' sx = { { color : 'text.primary' , display : 'flex' , alignItems : 'center' } } >
45
+ { children }
46
+ </ Typography >
47
+ ) ;
48
+ } ;
49
+
33
50
export const MobileMenuContent : FunctionComponent = ( ) => {
34
- const { service, user} = useContext ( MainContext )
35
51
return < >
36
- {
37
- user
38
- ? < MobileUserAvatar />
39
- : < MobileMenuItem >
40
- < Link href = { service . getLoginUrl ( ) } >
41
- < MobileMenuItemText >
42
- < AccountBoxIcon sx = { itemIcon } />
43
- Log In
44
- </ MobileMenuItemText >
45
- </ Link >
46
- </ MobileMenuItem >
47
- }
48
- {
49
- ! location . pathname . startsWith ( UserSettingsRoutes . ROOT )
50
- ? < MobileMenuItem >
51
- < RouteLink to = '/user-settings/extensions' >
52
- < MobileMenuItemText >
53
- < PublishIcon sx = { itemIcon } />
54
- Publish Extension
55
- </ MobileMenuItemText >
56
- </ RouteLink >
57
- </ MobileMenuItem >
58
- : null
59
- }
60
52
< MobileMenuItem >
61
53
< Link target = '_blank' href = 'https://github.com/eclipse/openvsx' >
62
54
< MobileMenuItemText >
@@ -127,17 +119,45 @@ export const MobileMenuContent: FunctionComponent = () => {
127
119
</ MobileMenuItemText >
128
120
</ RouteLink >
129
121
</ MobileMenuItem >
122
+ {
123
+ ! location . pathname . startsWith ( UserSettingsRoutes . ROOT )
124
+ ? < MobileMenuItem >
125
+ < RouteLink to = '/user-settings/extensions' >
126
+ < MobileMenuItemText >
127
+ < PublishIcon sx = { itemIcon } />
128
+ Publish Extension
129
+ </ MobileMenuItemText >
130
+ </ RouteLink >
131
+ </ MobileMenuItem >
132
+ : null
133
+ }
130
134
</ > ;
131
135
}
132
136
133
137
134
138
//-------------------- Default View --------------------//
135
139
140
+ const headerItem = ( { theme } : { theme : Theme } ) => ( {
141
+ margin : theme . spacing ( 2.5 ) ,
142
+ color : theme . palette . text . primary ,
143
+ textDecoration : 'none' ,
144
+ fontSize : '1.1rem' ,
145
+ fontFamily : theme . typography . fontFamily ,
146
+ fontWeight : theme . typography . fontWeightLight ,
147
+ letterSpacing : 1 ,
148
+ '&:hover' : {
149
+ color : theme . palette . secondary . main ,
150
+ textDecoration : 'none'
151
+ }
152
+ } ) ;
153
+
136
154
const headerTypography = ( { theme } : { theme : Theme } ) => ( {
137
155
...headerItem ( { theme} ) ,
138
156
cursor : 'pointer'
139
157
} ) ;
140
158
159
+ const MenuLink = styled ( Link ) ( headerItem ) ;
160
+ const MenuRouteLink = styled ( RouteLink ) ( headerItem ) ;
141
161
const MenuTypography = styled ( Typography ) ( headerTypography ) ;
142
162
143
163
const subMenuItem = ( { theme } : { theme : Theme } ) => ( {
@@ -156,14 +176,13 @@ const SubMenuLink = styled(Link)(subMenuLink);
156
176
157
177
158
178
export const DefaultMenuContent : FunctionComponent = ( ) => {
159
- const { service, user} = useContext ( MainContext )
160
179
const [ workingGroupMenuOpen , setWorkingGroupMenuOpen ] = useState ( false ) ;
161
180
const workingGroupMenuEl = useRef < HTMLButtonElement | null > ( null ) ;
162
181
const toggleWorkingGroupMenu = ( ) => setWorkingGroupMenuOpen ( ! workingGroupMenuOpen ) ;
163
182
const closeWorkingGroupMenu = ( ) => setWorkingGroupMenuOpen ( false ) ;
164
183
165
184
return < >
166
- < MenuLink href = 'https://github.com/EclipseFdn/open-vsx.org /wiki' >
185
+ < MenuLink href = 'https://github.com/eclipse/openvsx /wiki' >
167
186
Documentation
168
187
</ MenuLink >
169
188
< MenuLink href = 'https://status.open-vsx.org/' >
@@ -191,16 +210,5 @@ export const DefaultMenuContent: FunctionComponent = () => {
191
210
< Button variant = 'contained' color = 'secondary' href = '/user-settings/extensions' sx = { { mx : 2.5 } } >
192
211
Publish
193
212
</ Button >
194
- {
195
- user ?
196
- < UserAvatar />
197
- :
198
- < IconButton
199
- href = { service . getLoginUrl ( ) }
200
- title = 'Log In'
201
- aria-label = 'Log In' >
202
- < AccountBoxIcon />
203
- </ IconButton >
204
- }
205
213
</ > ;
206
214
}
0 commit comments