AlertLabel.tsx 970 B

123456789101112131415161718192021222324252627282930313233
  1. import { css } from '@emotion/css';
  2. import React, { FC } from 'react';
  3. import { GrafanaTheme } from '@grafana/data';
  4. import { IconButton, useStyles } from '@grafana/ui';
  5. interface Props {
  6. labelKey: string;
  7. value: string;
  8. operator?: string;
  9. onRemoveLabel?: () => void;
  10. }
  11. export const AlertLabel: FC<Props> = ({ labelKey, value, operator = '=', onRemoveLabel }) => (
  12. <div className={useStyles(getStyles)}>
  13. {labelKey}
  14. {operator}
  15. {value}
  16. {!!onRemoveLabel && <IconButton name="times" size="xs" onClick={onRemoveLabel} />}
  17. </div>
  18. );
  19. export const getStyles = (theme: GrafanaTheme) => css`
  20. padding: ${theme.spacing.xs} ${theme.spacing.sm};
  21. border-radius: ${theme.border.radius.sm};
  22. border: solid 1px ${theme.colors.border2};
  23. font-size: ${theme.typography.size.sm};
  24. background-color: ${theme.colors.bg2};
  25. font-weight: ${theme.typography.weight.bold};
  26. color: ${theme.colors.formLabel};
  27. display: inline-block;
  28. line-height: 1.2;
  29. `;