mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
// Libraries
|
|
import { css } from '@emotion/css';
|
|
import React, { FunctionComponent, MouseEvent } from 'react';
|
|
|
|
// Components
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
import { IconName, IconType, IconSize, IconButton, useTheme, stylesFactory } from '@grafana/ui';
|
|
|
|
interface Props {
|
|
icon?: IconName;
|
|
tooltip: string;
|
|
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
href?: string;
|
|
children?: React.ReactNode;
|
|
iconType?: IconType;
|
|
iconSize?: IconSize;
|
|
}
|
|
|
|
export const DashNavButton: FunctionComponent<Props> = ({ icon, iconType, iconSize, tooltip, onClick, children }) => {
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme);
|
|
|
|
return (
|
|
<div className={styles.noBorderContainer}>
|
|
{icon && (
|
|
<IconButton
|
|
name={icon}
|
|
size={iconSize}
|
|
iconType={iconType}
|
|
tooltip={tooltip}
|
|
tooltipPlacement="bottom"
|
|
onClick={onClick}
|
|
/>
|
|
)}
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => ({
|
|
noBorderContainer: css`
|
|
padding: 0 ${theme.spacing.xs};
|
|
display: flex;
|
|
`,
|
|
}));
|