diff --git a/public/app/core/components/NavBar/Next/NavBarMenu.tsx b/public/app/core/components/NavBar/Next/NavBarMenu.tsx
index 63232cc6596..e5c17517721 100644
--- a/public/app/core/components/NavBar/Next/NavBarMenu.tsx
+++ b/public/app/core/components/NavBar/Next/NavBarMenu.tsx
@@ -8,21 +8,23 @@ import { css, cx } from '@emotion/css';
import { NavBarMenuItem } from './NavBarMenuItem';
import { NavBarItemWithoutMenu } from './NavBarItemWithoutMenu';
import { isMatchOrChildMatch } from '../utils';
+import { NavBarToggle } from './NavBarToggle';
export interface Props {
activeItem?: NavModelItem;
+ isOpen: boolean;
navItems: NavModelItem[];
onClose: () => void;
}
-export function NavBarMenu({ activeItem, navItems, onClose }: Props) {
+export function NavBarMenu({ activeItem, isOpen, navItems, onClose }: Props) {
const styles = useStyles2(getStyles);
const ref = useRef(null);
const { dialogProps } = useDialog({}, ref);
const { overlayProps } = useOverlay(
{
isDismissable: true,
- isOpen: true,
+ isOpen,
onClose,
},
ref
@@ -32,6 +34,7 @@ export function NavBarMenu({ activeItem, navItems, onClose }: Props) {
+ setMenuOpen(!menuOpen)}
+ />
+
{
setMenuOpen(false)}
/>
- setMenuOpen(!menuOpen)}
- />
);
@@ -233,20 +235,11 @@ const getStyles = (theme: GrafanaTheme2) => ({
height: '100%',
zIndex: theme.zIndex.sidemenu,
}),
- menuToggle: css({
- backgroundColor: theme.colors.background.secondary,
- border: `1px solid ${theme.colors.border.weak}`,
+ menuExpandIcon: css({
position: 'absolute',
- marginRight: 0,
top: '43px',
right: '0px',
- zIndex: theme.zIndex.sidemenu,
- transform: `translateX(calc(${theme.spacing(7)} + 50%))`,
- borderRadius: '50%',
-
- [theme.breakpoints.down('md')]: {
- display: 'none',
- },
+ transform: `translateX(50%)`,
}),
});
@@ -267,34 +260,23 @@ const getAnimStyles = (theme: GrafanaTheme2) => {
width: theme.spacing(7),
};
- const buttonShift = {
- '& + button': {
- transform: 'translateX(0%)',
- },
- };
-
return {
enter: css({
...closedStyles,
- ...buttonShift,
}),
enterActive: css({
...transitionProps,
...openStyles,
- ...buttonShift,
}),
enterDone: css({
...openStyles,
- ...buttonShift,
}),
exit: css({
...openStyles,
- ...buttonShift,
}),
exitActive: css({
...transitionProps,
...closedStyles,
- ...buttonShift,
}),
};
};
diff --git a/public/app/core/components/NavBar/Next/NavBarToggle.tsx b/public/app/core/components/NavBar/Next/NavBarToggle.tsx
new file mode 100644
index 00000000000..fc830d0fe0f
--- /dev/null
+++ b/public/app/core/components/NavBar/Next/NavBarToggle.tsx
@@ -0,0 +1,41 @@
+import React from 'react';
+import { IconButton, useTheme2 } from '@grafana/ui';
+import { GrafanaTheme2 } from '@grafana/data';
+import { css } from '@emotion/css';
+import classnames from 'classnames';
+
+export interface Props {
+ className?: string;
+ isExpanded: boolean;
+ onClick: () => void;
+}
+
+export const NavBarToggle = ({ className, isExpanded, onClick }: Props) => {
+ const theme = useTheme2();
+ const styles = getStyles(theme);
+
+ return (
+
+ );
+};
+
+NavBarToggle.displayName = 'NavBarToggle';
+
+const getStyles = (theme: GrafanaTheme2) => ({
+ icon: css({
+ backgroundColor: theme.colors.background.secondary,
+ border: `1px solid ${theme.colors.border.weak}`,
+ borderRadius: '50%',
+ marginRight: 0,
+ zIndex: theme.zIndex.sidemenu,
+
+ [theme.breakpoints.down('md')]: {
+ display: 'none',
+ },
+ }),
+});