OptionsPaneItemOverrides.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { css, CSSObject } from '@emotion/css';
  2. import React from 'react';
  3. import { GrafanaTheme2 } from '@grafana/data';
  4. import { Tooltip, useStyles2 } from '@grafana/ui';
  5. import { OptionPaneItemOverrideInfo } from './types';
  6. export interface Props {
  7. overrides: OptionPaneItemOverrideInfo[];
  8. }
  9. export function OptionsPaneItemOverrides({ overrides }: Props) {
  10. const styles = useStyles2(getStyles);
  11. return (
  12. <div className={styles.wrapper}>
  13. {overrides.map((override, index) => (
  14. <Tooltip content={override.tooltip} key={index.toString()} placement="top">
  15. <div aria-label={override.description} className={styles[override.type]} />
  16. </Tooltip>
  17. ))}
  18. </div>
  19. );
  20. }
  21. const getStyles = (theme: GrafanaTheme2) => {
  22. const common: CSSObject = {
  23. width: 8,
  24. height: 8,
  25. borderRadius: '50%',
  26. marginLeft: theme.spacing(1),
  27. position: 'relative',
  28. top: '-1px',
  29. };
  30. return {
  31. wrapper: css({
  32. display: 'flex',
  33. }),
  34. rule: css({
  35. ...common,
  36. backgroundColor: theme.colors.primary.main,
  37. }),
  38. data: css({
  39. ...common,
  40. backgroundColor: theme.colors.warning.main,
  41. }),
  42. };
  43. };