grafana/public/app/core/components/NavBar/NavBarSection.tsx
Ashley Harrison 727a4bd9e4
Navigation: New NavBar designs behind feature toggle (#41045)
* Navigation: Remove plus button behind feature toggle

* Navigation: Add home button behind feature toggle

* Navigation: Move settings/admin to bottom section behind feature toggle

* Navigation: Refactor grafana logo to be a NavBarItem

* Navigation: Create new PluginSection and styling changes to support new sections

* Navigation: Hack to use mobile menu as a mega menu for now

* Navigation: Only render plugin section if there are items

* Navigation: mobile menu is always 100% width if toggle is off

* Navigation: Reset width back to 48 and fix broken css property

* Navigation: Create generic NavBarSection component to reduce repetition

* Navigation: Don't show sublinks for core items

* Navigation: Comments from UX review

* Navigation: Remove mobile menu hack

* Navigation: Unit tests for enrichConfigItems and other minor review comments

* Navigation: Move section logic to backend

* Navigation: Refactor alerting links out into a separate function

* Navigation: More tests for isLinkActive

* Linting...

* Navigation: Create new NavBar component for when feature toggle is enabled
2021-11-02 11:19:18 +00:00

43 lines
1.2 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;
}
.sidemenu-open--xs & {
display: flex;
flex-direction: column;
gap: ${theme.spacing(1)};
}
`,
});