mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Navigation: Start creating new NavBarMenu component * Navigation: Apply new NavBarMenu to NavBarNext * Navigation: Remove everything to do with .sidemenu-open--xs * Navigation: Ensure search is passed to NavBarMenu * Navigation: Standardise NavBarMenuItem * This extra check isn't needed anymore * Navigation: Refactor <li> out of NavBarMenu * Navigation: Combine NavBarMenuItem with DropdownChild * use spread syntax since performance shouldn't be a concern for such small arrays * Improve active item logic * Ensure unique keys * Remove this duplicate code * Add unit tests for getActiveItem * Add tests for NavBarMenu * Rename mobileMenuOpen -> menuOpen in NavBarNext (since it can be used for mobile menu or megamenu) * just use index to key the items * Use exact versions of @react-aria packages * Navigation: Make the dropdown header a NavBarMenuItem * Navigation: Stop using dropdown-menu for styles * Navigation: Hide divider in NavBarMenu + tweak color on section header
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import React, { ReactNode } from 'react';
|
|
import { css, cx } from '@emotion/css';
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { useTheme2 } from '@grafana/ui';
|
|
import config from '../../config';
|
|
|
|
export interface Props {
|
|
children: ReactNode;
|
|
className?: string;
|
|
}
|
|
|
|
export function NavBarSection({ children, className }: Props) {
|
|
const newNavigationEnabled = config.featureToggles.newNavigation;
|
|
const theme = useTheme2();
|
|
const styles = getStyles(theme, newNavigationEnabled);
|
|
|
|
return (
|
|
<div data-testid="navbar-section" className={cx(styles.container, className)}>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const getStyles = (theme: GrafanaTheme2, newNavigationEnabled: boolean) => ({
|
|
container: css`
|
|
display: none;
|
|
|
|
${theme.breakpoints.up('md')} {
|
|
background-color: ${newNavigationEnabled ? theme.colors.background.primary : 'inherit'};
|
|
border: ${newNavigationEnabled ? `1px solid ${theme.components.panel.borderColor}` : 'none'};
|
|
border-radius: 2px;
|
|
display: flex;
|
|
flex-direction: inherit;
|
|
}
|
|
`,
|
|
});
|