@@ -3,7 +3,7 @@ import classNames from 'classnames';
33import React , { PropsWithChildren } from 'react' ;
44
55import { GrafanaTheme2 , PageLayoutType } from '@grafana/data' ;
6- import { useStyles2 , LinkButton } from '@grafana/ui' ;
6+ import { useStyles2 , LinkButton , useTheme2 } from '@grafana/ui' ;
77import config from 'app/core/config' ;
88import { useGrafana } from 'app/core/context/GrafanaContext' ;
99import { CommandPalette } from 'app/features/commandPalette/CommandPalette' ;
@@ -23,6 +23,7 @@ export function AppChrome({ children }: Props) {
2323 const { chrome } = useGrafana ( ) ;
2424 const state = chrome . useState ( ) ;
2525 const searchBarHidden = state . searchBarHidden || state . kioskMode === KioskMode . TV ;
26+ const theme = useTheme2 ( ) ;
2627 const styles = useStyles2 ( getStyles ) ;
2728
2829 const contentClass = cx ( {
@@ -31,6 +32,23 @@ export function AppChrome({ children }: Props) {
3132 [ styles . contentChromeless ] : state . chromeless ,
3233 } ) ;
3334
35+ const handleMegaMenu = ( ) => {
36+ switch ( state . megaMenu ) {
37+ case 'closed' :
38+ chrome . setMegaMenu ( 'open' ) ;
39+ break ;
40+ case 'open' :
41+ chrome . setMegaMenu ( 'closed' ) ;
42+ break ;
43+ case 'docked' :
44+ // on desktop, clicking the button when the menu is docked should close the menu
45+ // on mobile, the docked menu is hidden, so clicking the button should open the menu
46+ const isDesktop = window . innerWidth > theme . breakpoints . values . md ;
47+ isDesktop ? chrome . setMegaMenu ( 'closed' ) : chrome . setMegaMenu ( 'open' ) ;
48+ break ;
49+ }
50+ } ;
51+
3452 // Chromeless routes are without topNav, mega menu, search & command palette
3553 // We check chromeless twice here instead of having a separate path so {children}
3654 // doesn't get re-mounted when chromeless goes from true to false.
@@ -54,7 +72,7 @@ export function AppChrome({ children }: Props) {
5472 pageNav = { state . pageNav }
5573 actions = { state . actions }
5674 onToggleSearchBar = { chrome . onToggleSearchBar }
57- onToggleMegaMenu = { ( ) => chrome . setMegaMenu ( state . megaMenu === 'closed' ? 'open' : 'closed' ) }
75+ onToggleMegaMenu = { handleMegaMenu }
5876 onToggleKioskMode = { chrome . onToggleKioskMode }
5977 />
6078 </ div >
@@ -110,7 +128,12 @@ const getStyles = (theme: GrafanaTheme2) => {
110128 background : theme . colors . background . primary ,
111129 borderRight : `1px solid ${ theme . colors . border . weak } ` ,
112130 borderTop : `1px solid ${ theme . colors . border . weak } ` ,
131+ display : 'none' ,
113132 zIndex : theme . zIndex . navbarFixed ,
133+
134+ [ theme . breakpoints . up ( 'md' ) ] : {
135+ display : 'block' ,
136+ } ,
114137 } ) ,
115138 topNav : css ( {
116139 display : 'flex' ,
0 commit comments