mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* IconButton: New component to share pointer, size & hover style for icon buttons * Progress * IconButton: new component * Think I am done * Updated snapshots * Do not like the black button reverting that, and not the plus-circle changed to plus * fixed test * fixed e2e test * Fixed ts issue
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { IconName, IconButton, stylesFactory, useTheme } from '@grafana/ui';
|
|
import React from 'react';
|
|
import { css } from 'emotion';
|
|
import { GrafanaTheme } from '@grafana/data';
|
|
|
|
interface QueryOperationActionProps {
|
|
icon: IconName;
|
|
title?: string;
|
|
onClick: (e: React.MouseEvent) => void;
|
|
disabled?: boolean;
|
|
}
|
|
|
|
export const QueryOperationAction: React.FC<QueryOperationActionProps> = ({ icon, disabled, title, ...otherProps }) => {
|
|
const theme = useTheme();
|
|
const styles = getStyles(theme);
|
|
|
|
const onClick = (e: React.MouseEvent) => {
|
|
if (!disabled) {
|
|
otherProps.onClick(e);
|
|
}
|
|
};
|
|
return (
|
|
<div title={title}>
|
|
<IconButton
|
|
name={icon}
|
|
className={styles.icon}
|
|
disabled={!!disabled}
|
|
onClick={onClick}
|
|
aria-label={`${title} query operation action`}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
QueryOperationAction.displayName = 'QueryOperationAction';
|
|
|
|
const getStyles = stylesFactory((theme: GrafanaTheme) => {
|
|
return {
|
|
icon: css`
|
|
color: ${theme.colors.textWeak};
|
|
`,
|
|
};
|
|
});
|