@@ -60,13 +60,15 @@ const InputBox = ({ addToNewProfile, editName, newName }: InputBoxProps) => {
60
60
} ;
61
61
62
62
interface AddProfileProps {
63
- address : string | undefined
63
+ address : string | undefined ;
64
64
showName : boolean | undefined ;
65
65
setShowName : React . Dispatch < React . SetStateAction < boolean | undefined > > ;
66
- handleClose : ( ) => void
66
+ handleClose : ( ) => void ;
67
+ closeParentMenu : ( ) => void
68
+ extensionMode : boolean ;
67
69
}
68
70
69
- const AddMenu = ( { address, handleClose, setShowName, showName } : AddProfileProps ) => {
71
+ const AddMenu = ( { address, closeParentMenu , extensionMode , handleClose, setShowName, showName } : AddProfileProps ) => {
70
72
const theme = useTheme ( ) ;
71
73
const { t } = useTranslation ( ) ;
72
74
const { userDefinedProfiles } = useProfiles ( ) ;
@@ -103,18 +105,20 @@ const AddMenu = ({ address, handleClose, setShowName, showName }: AddProfileProp
103
105
updateMeta ( String ( address ) , metaData )
104
106
. then ( ( ) => {
105
107
handleClose ( ) ;
108
+ closeParentMenu ( ) ;
106
109
} ) . catch ( console . error ) ;
107
- } , [ account , address , handleClose ] ) ;
110
+ } , [ account , address , closeParentMenu , handleClose ] ) ;
108
111
109
112
return (
110
- < Grid alignItems = 'flex-start' container display = 'block' item sx = { { borderRadius : '10px' , minWidth : '300px' , p : '10px' } } >
113
+ < Grid alignItems = 'flex-start' container display = 'block' item sx = { { borderRadius : '10px' , minWidth : '300px' , p : extensionMode ? '5px' : '10px' } } >
111
114
{ showName
112
115
? < InputBox
113
116
addToNewProfile = { addToNewProfile }
114
117
editName = { editName }
115
118
newName = { newName }
116
119
/>
117
120
: < MenuItem
121
+ fontSize = { extensionMode ? '16px' : undefined }
118
122
iconComponent = {
119
123
< VaadinIcon icon = 'vaadin:plus' style = { { color : theme . palette . text . primary , height : '20px' } } />
120
124
}
@@ -123,10 +127,11 @@ const AddMenu = ({ address, handleClose, setShowName, showName }: AddProfileProp
123
127
withHoverEffect
124
128
/>
125
129
}
126
- < Divider sx = { { bgcolor : 'divider' , height : '1px' , my : '6px' } } />
130
+ < Divider sx = { { bgcolor : 'divider' , height : '1px' , my : extensionMode ? '3px' : '6px' } } />
127
131
{ userDefinedProfiles . length > 0
128
132
? userDefinedProfiles . map ( ( profile ) => (
129
133
< MenuItem
134
+ fontSize = { extensionMode ? '16px' : undefined }
130
135
iconComponent = {
131
136
< VaadinIcon icon = 'vaadin:folder-open-o' style = { { color : theme . palette . text . primary , height : '20px' } } />
132
137
}
@@ -139,6 +144,7 @@ const AddMenu = ({ address, handleClose, setShowName, showName }: AddProfileProp
139
144
) )
140
145
: < MenuItem
141
146
disabled
147
+ fontSize = { extensionMode ? '16px' : undefined }
142
148
iconComponent = {
143
149
< VaadinIcon icon = 'vaadin:minus' style = { { color : `${ theme . palette . text . disabled } ` , height : '20px' } } />
144
150
}
@@ -153,18 +159,20 @@ const AddMenu = ({ address, handleClose, setShowName, showName }: AddProfileProp
153
159
interface RemoveProfileProps {
154
160
profileNames : string [ ] | undefined ;
155
161
onRemove : ( profile : string ) => void ;
162
+ extensionMode : boolean ;
156
163
}
157
164
158
- const RemoveMenu = ( { onRemove, profileNames } : RemoveProfileProps ) => {
165
+ const RemoveMenu = ( { extensionMode , onRemove, profileNames } : RemoveProfileProps ) => {
159
166
const theme = useTheme ( ) ;
160
167
const { t } = useTranslation ( ) ;
161
168
162
169
return (
163
- < Grid alignItems = 'flex-start' container display = 'block' item sx = { { borderRadius : '10px' , minWidth : '300px' , p : '10px' } } >
170
+ < Grid alignItems = 'flex-start' container display = 'block' item sx = { { borderRadius : '10px' , minWidth : '300px' , p : extensionMode ? '5px' : '10px' } } >
164
171
{ profileNames ?. map ( ( profileName ) => (
165
172
// eslint-disable-next-line react/jsx-no-bind
166
173
< Grid component = 'button' container item key = { profileName } onClick = { ( ) => onRemove ( profileName ) } sx = { { '> div div:last-child p' : { maxWidth : '220px' , overflow : 'hidden' , textOverflow : 'ellipsis' , whiteSpace : 'nowrap' } , bgcolor : 'transparent' , border : 'none' , color : theme . palette . text . primary , height : 'fit-content' , p : 0 , width : 'inherit' } } >
167
174
< MenuItem
175
+ fontSize = { extensionMode ? '16px' : undefined }
168
176
iconComponent = {
169
177
< VaadinIcon icon = 'vaadin:folder-remove' style = { { color : theme . palette . text . primary , height : '20px' } } />
170
178
}
@@ -206,8 +214,7 @@ function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<P
206
214
const handleClose = useCallback ( ( ) => {
207
215
setAnchorEl ( null ) ;
208
216
setShowName ( false ) ;
209
- closeParentMenu ( ) ;
210
- } , [ closeParentMenu ] ) ;
217
+ } , [ ] ) ;
211
218
212
219
const onAddClick = useCallback ( ( event : React . MouseEvent < HTMLButtonElement | HTMLDivElement > ) => {
213
220
setAnchorEl ( event . currentTarget ) ;
@@ -240,14 +247,18 @@ function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<P
240
247
241
248
if ( isLastAccountWithTheProfile && currentProfile === profileToBeRemoved ) {
242
249
setStorage ( 'profile' , PROFILE_TAGS . ALL )
243
- . then ( handleClose )
250
+ . then ( ( ) => {
251
+ handleClose ( ) ;
252
+ closeParentMenu ( ) ;
253
+ } )
244
254
. catch ( console . error ) ;
245
255
} else {
246
256
handleClose ( ) ;
257
+ closeParentMenu ( ) ;
247
258
}
248
259
} )
249
260
. catch ( console . error ) ;
250
- } , [ profileNames , accounts , address , currentProfile , handleClose ] ) ;
261
+ } , [ address , profileNames , accounts , currentProfile , handleClose , closeParentMenu ] ) ;
251
262
252
263
const open = Boolean ( anchorEl ) ;
253
264
const id = open ? 'simple-popover 2' : undefined ;
@@ -256,6 +267,7 @@ function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<P
256
267
< >
257
268
< Grid aria-describedby = { id } component = 'button' container item onClick = { onAddClick } sx = { { bgcolor : 'transparent' , border : 'none' , color : theme . palette . text . primary , height : 'fit-content' , p : 0 , width : 'inherit' } } >
258
269
< MenuItem
270
+ fontSize = { isExtensionMode ? '16px' : undefined }
259
271
iconComponent = {
260
272
< VaadinIcon icon = 'vaadin:folder-add' style = { { color : `${ theme . palette . text . primary } ` , height : '20px' } } />
261
273
}
@@ -284,6 +296,7 @@ function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<P
284
296
{ isExtensionMode && profileNames && profileNames . length > 0 &&
285
297
< Grid aria-describedby = { id } component = 'button' container item onClick = { onRemoveMenuClick } sx = { { bgcolor : 'transparent' , border : 'none' , color : theme . palette . text . primary , height : 'fit-content' , p : 0 , width : 'inherit' } } >
286
298
< MenuItem
299
+ fontSize = '16px'
287
300
iconComponent = {
288
301
< VaadinIcon icon = 'vaadin:folder-remove' style = { { color : theme . palette . text . primary , height : '20px' } } />
289
302
}
@@ -293,7 +306,6 @@ function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<P
293
306
/>
294
307
</ Grid >
295
308
}
296
- { isExtensionMode && < Divider sx = { { bgcolor : 'divider' , height : '1px' , my : '6px' , width : '100%' } } /> }
297
309
< Popover
298
310
PaperProps = { {
299
311
sx : {
@@ -322,12 +334,15 @@ function ProfileMenu ({ address, closeParentMenu }: Props): React.ReactElement<P
322
334
{ status === STATUS . SHOW_ADD &&
323
335
< AddMenu
324
336
address = { address }
337
+ closeParentMenu = { closeParentMenu }
338
+ extensionMode = { isExtensionMode }
325
339
handleClose = { handleClose }
326
340
setShowName = { setShowName }
327
341
showName = { showName }
328
342
/> }
329
343
{ status === STATUS . SHOW_REMOVE &&
330
344
< RemoveMenu
345
+ extensionMode = { isExtensionMode }
331
346
onRemove = { onRemove }
332
347
profileNames = { profileNames }
333
348
/>
0 commit comments