import React from 'react';
import { css } from '@emotion/css';
import { GrafanaTheme2 } from '@grafana/data';
import { Icon, IconName, Link, useTheme2 } from '@grafana/ui';
export interface Props {
isDivider?: boolean;
icon?: IconName;
onClick?: () => void;
target?: HTMLAnchorElement['target'];
text: string;
url?: string;
}
const DropdownChild = ({ isDivider = false, icon, onClick, target, text, url }: Props) => {
const theme = useTheme2();
const styles = getStyles(theme);
const linkContent = (
{icon && }
{text}
{target === '_blank' && (
)}
);
let element = (
);
if (url) {
element =
!target && url.startsWith('/') ? (
{linkContent}
) : (
{linkContent}
);
}
return isDivider ? : {element};
};
export default DropdownChild;
const getStyles = (theme: GrafanaTheme2) => ({
element: css`
background-color: transparent;
border: none;
display: flex;
width: 100%;
`,
externalLinkIcon: css`
color: ${theme.colors.text.secondary};
margin-left: ${theme.spacing(1)};
`,
icon: css`
margin-right: ${theme.spacing(1)};
`,
linkContent: css`
display: flex;
flex: 1;
flex-direction: row;
justify-content: space-between;
`,
});