@@ -16,6 +16,7 @@ import { ApplicationMenuProps } from "./application-menu.types";
1616import { useStyles } from "./application.styles" ;
1717import { defaultMySystemsAppData , isMySystemsAppId } from "./applications" ;
1818import { TranslationFn , useTranslation } from "./translation-context" ;
19+ import { ApplicationArea } from "./top-bar.types" ;
1920
2021const ApplicationIcon = bundleIcon ( BoxFilled , BoxRegular ) ;
2122
@@ -26,19 +27,22 @@ function appLabel(t: TranslationFn, id: string): string {
2627 return id ;
2728}
2829
29- function appIcon ( id : string ) : JSX . Element {
30+ function appIcon ( id : string , filled = false ) : JSX . Element {
3031 if ( isMySystemsAppId ( id ) ) {
31- return defaultMySystemsAppData [ id ] . icon ;
32+ return filled
33+ ? defaultMySystemsAppData [ id ] . filledIcon
34+ : defaultMySystemsAppData [ id ] . icon ;
3235 }
33- return < ApplicationIcon /> ;
36+ return < ApplicationIcon filled = { filled } /> ;
3437}
3538
3639export const ApplicationMenu = ( {
3740 customContent,
3841 options,
3942 value,
4043 onChange,
41- } : ApplicationMenuProps ) => {
44+ applicationArea,
45+ } : ApplicationMenuProps & { applicationArea ?: ApplicationArea } ) => {
4246 const { t } = useTranslation ( ) ;
4347 const styles = useStyles ( ) ;
4448
@@ -48,68 +52,95 @@ export const ApplicationMenu = ({
4852 const onlyCustomContent = ! options ?. length && ! ! customContent ;
4953
5054 return (
51- < Menu >
52- < MenuTrigger >
53- < MenuButton
54- appearance = "subtle"
55+ < >
56+ < div
57+ className = { mergeClasses (
58+ styles . menuRectangle ,
59+ applicationArea === "mySystems"
60+ && styles . mySystemsMenuRectangle ,
61+ applicationArea === "myAxis" && styles . myAxisMenuRectangle ,
62+ applicationArea === "myBusiness" && styles . myBusinessMenuRectangle ,
63+ applicationArea === "myPartners" && styles . myPartnersMenuRectangle
64+ ) }
65+ >
66+ < div
5567 className = { mergeClasses (
56- isStandalone && styles . standalone ,
57- styles . singleLine
68+ styles . currentIcon ,
69+ applicationArea !== undefined && styles . applicationAreaIcon
5870 ) }
59- icon = { currentSelection
60- ? currentSelection . icon ?? appIcon ( currentSelection . id )
61- : undefined }
62- data-testid = "application-menu-trigger"
63- menuIcon = { isStandalone ? null : undefined }
6471 >
65- < span className = { styles . applicationLabel } >
66- { currentSelection
67- ? currentSelection . label ?? appLabel ( t , currentSelection . id )
68- // FIXME: use translateable placeholder
69- : "" }
70- { currentSelection ?. beta && < BetaBadge /> }
71- </ span >
72- </ MenuButton >
73- </ MenuTrigger >
74- < MenuPopover >
75- < MenuList >
76- { customContent !== undefined && (
77- < >
78- { customContent }
79- { ! onlyCustomContent && < MenuDivider /> }
80- </ >
81- ) }
82- { options ?. map ( ( { id, icon, label, beta } ) => (
83- < MenuItem
84- data-testid = { `application-menu-item-${ id } ` }
85- icon = {
86- < div
87- className = { mergeClasses ( id === value && styles . selectedApp ) }
88- >
89- { icon ?? appIcon ( id ) }
90- </ div >
91- }
92- key = { id }
93- // eslint-disable-next-line react/jsx-no-bind
94- onClick = { ( ) => {
95- if ( currentSelection ?. id !== id ) {
96- onChange ?.( id ) ;
72+ { currentSelection
73+ ? currentSelection . icon
74+ ?? appIcon ( currentSelection . id , applicationArea !== undefined )
75+ : undefined }
76+ </ div >
77+ </ div >
78+ < Menu
79+ positioning = { {
80+ offset : applicationArea !== undefined
81+ ? { mainAxis : 2 , crossAxis : 36 }
82+ : undefined ,
83+ } }
84+ >
85+ < MenuTrigger >
86+ < MenuButton
87+ appearance = "subtle"
88+ className = { mergeClasses (
89+ isStandalone && styles . standalone ,
90+ styles . singleLine
91+ ) }
92+ data-testid = "application-menu-trigger"
93+ menuIcon = { isStandalone ? null : undefined }
94+ >
95+ < span className = { styles . applicationLabel } >
96+ { currentSelection
97+ ? currentSelection . label ?? appLabel ( t , currentSelection . id )
98+ // FIXME: use translateable placeholder
99+ : "" }
100+ { currentSelection ?. beta && < BetaBadge /> }
101+ </ span >
102+ </ MenuButton >
103+ </ MenuTrigger >
104+ < MenuPopover className = { styles . menuPopover } >
105+ < MenuList >
106+ { customContent !== undefined && (
107+ < >
108+ { customContent }
109+ { ! onlyCustomContent && < MenuDivider /> }
110+ </ >
111+ ) }
112+ { options ?. map ( ( { id, icon, label, beta } ) => (
113+ < MenuItem
114+ data-testid = { `application-menu-item-${ id } ` }
115+ icon = {
116+ < div
117+ className = { mergeClasses ( id === value && styles . selectedApp ) }
118+ >
119+ { icon ?? appIcon ( id ) }
120+ </ div >
97121 }
98- } }
99- >
100- < Text
101- className = { mergeClasses (
102- id === value && styles . selectedAppLabel
103- ) }
122+ key = { id }
123+ // eslint-disable-next-line react/jsx-no-bind
124+ onClick = { ( ) => {
125+ if ( currentSelection ?. id !== id ) {
126+ onChange ?.( id ) ;
127+ }
128+ } }
104129 >
105- { label ?? appLabel ( t , id ) }
106- </ Text >
107- { beta && < BetaBadge /> }
108- </ MenuItem >
109- ) ) }
110- </ MenuList >
111- </ MenuPopover >
112- </ Menu >
130+ < Text
131+ className = { mergeClasses (
132+ id === value && styles . selectedAppLabel
133+ ) }
134+ >
135+ { label ?? appLabel ( t , id ) }
136+ </ Text >
137+ { beta && < BetaBadge /> }
138+ </ MenuItem >
139+ ) ) }
140+ </ MenuList >
141+ </ MenuPopover >
142+ </ Menu >
143+ </ >
113144 ) ;
114145} ;
115146
0 commit comments