grafana/public/app/core/components/Indent/Indent.tsx
Ashley Harrison 18b237879d
DockedMegaMenu: Refactor and rename to simplify (#75872)
* tidy up some styles

* remove NavBarMenuItemWrapper + consolidate components

* lots of renaming

* use object syntax in FeatureHighlight

* fix a couple of missing find+replace

* adjust li positioning

* fix text truncation

* bit more tidy up

* refactor indent into it's own component

* memoize styles in Indent
2023-10-03 13:03:27 +01:00

27 lines
840 B
TypeScript

import { css } from '@emotion/css';
import React from 'react';
import { GrafanaTheme2, ThemeSpacingTokens } from '@grafana/data';
import { useStyles2 } from '@grafana/ui';
import { getResponsiveStyle, ResponsiveProp } from '@grafana/ui/src/components/Layout/utils/responsiveness';
interface IndentProps {
children?: React.ReactNode;
level: number;
spacing: ResponsiveProp<ThemeSpacingTokens>;
}
export function Indent({ children, spacing, level }: IndentProps) {
const styles = useStyles2(getStyles, spacing, level);
return <span className={css(styles.indentor)}>{children}</span>;
}
const getStyles = (theme: GrafanaTheme2, spacing: IndentProps['spacing'], level: IndentProps['level']) => ({
indentor: css(
getResponsiveStyle(theme, spacing, (val) => ({
paddingLeft: theme.spacing(val * level),
}))
),
});