mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 12:02:18 +08:00

* refactor: tooltip is required * refactor: add tooltips * refactor: add tooltips * refactor: add tooltips * refactor: add tooltips * refactor: add tooltips * refactor: add tooltips * refactor: adjust tests * refactor: apply changes from code review * refactor: adjust component for e2e test * refactor: adjust fallback * refactor: apply changes from code review * refactor: apply changes from code review * refactor: set IconButton default as type=button and remove from use cases * refactor: remove aria-labels when duplicated and type=button from use cases * refactor: clean up * refactor: fix tests * refactor: fix type errors * refactor: remove changes in order in order to add them to a separate PR * refactor: set IconButton default as type=button * refactor: remove tooltip * refactor: apply changes requested in review
33 lines
726 B
TypeScript
33 lines
726 B
TypeScript
import { css } from '@emotion/css';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { IconButton, useStyles2 } from '@grafana/ui';
|
|
|
|
type Props = {
|
|
onClick: () => void;
|
|
'aria-label'?: string;
|
|
style?: React.CSSProperties;
|
|
};
|
|
|
|
export const CloseButton = ({ onClick, 'aria-label': ariaLabel, style }: Props) => {
|
|
const styles = useStyles2(getStyles);
|
|
return (
|
|
<IconButton
|
|
aria-label={ariaLabel ?? 'Close'}
|
|
className={styles}
|
|
name="times"
|
|
onClick={onClick}
|
|
style={style}
|
|
tooltip="Close"
|
|
/>
|
|
);
|
|
};
|
|
|
|
const getStyles = (theme: GrafanaTheme2) =>
|
|
css`
|
|
position: absolute;
|
|
right: ${theme.spacing(0.5)};
|
|
top: ${theme.spacing(1)};
|
|
`;
|