|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
import { css, cx } from '@emotion/css'; |
|
|
|
|
import React, { PropsWithChildren, useState } from 'react'; |
|
|
|
|
import { useToggle } from 'react-use'; |
|
|
|
|
import React, { PropsWithChildren } from 'react'; |
|
|
|
|
|
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data'; |
|
|
|
|
import { config } from '@grafana/runtime'; |
|
|
|
@ -17,8 +16,6 @@ export interface Props extends PropsWithChildren<{}> {} |
|
|
|
|
|
|
|
|
|
export function AppChrome({ children }: Props) { |
|
|
|
|
const styles = useStyles2(getStyles); |
|
|
|
|
const [searchBarHidden, toggleSearchBar] = useToggle(false); // repace with local storage
|
|
|
|
|
const [megaMenuOpen, setMegaMenuOpen] = useState(false); |
|
|
|
|
const state = appChromeService.useState(); |
|
|
|
|
|
|
|
|
|
if (state.chromeless || !config.featureToggles.topnav) { |
|
|
|
@ -28,18 +25,20 @@ export function AppChrome({ children }: Props) { |
|
|
|
|
return ( |
|
|
|
|
<main className="main-view"> |
|
|
|
|
<div className={styles.topNav}> |
|
|
|
|
{!searchBarHidden && <TopSearchBar />} |
|
|
|
|
{!state.searchBarHidden && <TopSearchBar />} |
|
|
|
|
<NavToolbar |
|
|
|
|
searchBarHidden={searchBarHidden} |
|
|
|
|
searchBarHidden={state.searchBarHidden} |
|
|
|
|
sectionNav={state.sectionNav} |
|
|
|
|
pageNav={state.pageNav} |
|
|
|
|
actions={state.actions} |
|
|
|
|
onToggleSearchBar={toggleSearchBar} |
|
|
|
|
onToggleMegaMenu={() => setMegaMenuOpen(!megaMenuOpen)} |
|
|
|
|
onToggleSearchBar={appChromeService.toggleSearchBar} |
|
|
|
|
onToggleMegaMenu={appChromeService.toggleMegaMenu} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
<div className={cx(styles.content, searchBarHidden && styles.contentNoSearchBar)}>{children}</div> |
|
|
|
|
{megaMenuOpen && <MegaMenu searchBarHidden={searchBarHidden} onClose={() => setMegaMenuOpen(false)} />} |
|
|
|
|
<div className={cx(styles.content, state.searchBarHidden && styles.contentNoSearchBar)}>{children}</div> |
|
|
|
|
{state.megaMenuOpen && ( |
|
|
|
|
<MegaMenu searchBarHidden={state.searchBarHidden} onClose={appChromeService.toggleMegaMenu} /> |
|
|
|
|
)} |
|
|
|
|
</main> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|