grafana/public/app/core/components/QueryOperationRow/QueryOperationAction.tsx
Torkel Ödegaard 6cb7d95916
Components: IconButton (#23510)
* 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
2020-04-11 16:07:18 +02:00

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};
`,
};
});