GeomapOverlay.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { css } from '@emotion/css';
  2. import React, { CSSProperties, PureComponent } from 'react';
  3. import { GrafanaTheme } from '@grafana/data';
  4. import { config } from '@grafana/runtime';
  5. import { stylesFactory } from '@grafana/ui';
  6. export interface OverlayProps {
  7. topRight?: React.ReactNode[];
  8. bottomLeft?: React.ReactNode[];
  9. blStyle?: CSSProperties;
  10. }
  11. export class GeomapOverlay extends PureComponent<OverlayProps> {
  12. style = getStyles(config.theme);
  13. constructor(props: OverlayProps) {
  14. super(props);
  15. }
  16. render() {
  17. const { topRight, bottomLeft } = this.props;
  18. return (
  19. <div className={this.style.overlay}>
  20. {Boolean(topRight?.length) && <div className={this.style.TR}>{topRight}</div>}
  21. {Boolean(bottomLeft?.length) && (
  22. <div className={this.style.BL} style={this.props.blStyle}>
  23. {bottomLeft}
  24. </div>
  25. )}
  26. </div>
  27. );
  28. }
  29. }
  30. const getStyles = stylesFactory((theme: GrafanaTheme) => ({
  31. overlay: css`
  32. position: absolute;
  33. width: 100%;
  34. height: 100%;
  35. z-index: 500;
  36. pointer-events: none;
  37. `,
  38. TR: css`
  39. position: absolute;
  40. top: 8px;
  41. right: 8px;
  42. pointer-events: auto;
  43. `,
  44. BL: css`
  45. position: absolute;
  46. bottom: 8px;
  47. left: 8px;
  48. pointer-events: auto;
  49. `,
  50. }));