grafana/public/app/plugins/panel/geomap/GeomapOverlay.tsx
Drew Slobodnjak fe0f193189
Geomap: Add measuring tools (#51608)
* Geomap: add measuring tools

* Add measure type selection

* Add controls and state to measure overlay

* Override tooltip mouse events when menu active

* Move measure tools to top right

* Lay groundwork for units and consolidate measuring

* Create measure vector layer class

* Improve styling to match other overlay controls

* Consolidate styling and use theme2

* Update unit language and add km2

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
2022-08-03 16:19:30 -07:00

57 lines
1.4 KiB
TypeScript

import { css } from '@emotion/css';
import React, { CSSProperties } from 'react';
import { GrafanaTheme2 } from '@grafana/data';
import { useStyles2 } from '@grafana/ui';
export interface OverlayProps {
topRight1?: React.ReactNode[];
topRight2?: React.ReactNode[];
bottomLeft?: React.ReactNode[];
blStyle?: CSSProperties;
}
export const GeomapOverlay = ({ topRight1, topRight2, bottomLeft, blStyle }: OverlayProps) => {
const topRight1Exists = (topRight1 && topRight1.length > 0) ?? false;
const styles = useStyles2(getStyles(topRight1Exists));
return (
<div className={styles.overlay}>
{Boolean(topRight1?.length) && <div className={styles.TR1}>{topRight1}</div>}
{Boolean(topRight2?.length) && <div className={styles.TR2}>{topRight2}</div>}
{Boolean(bottomLeft?.length) && (
<div className={styles.BL} style={blStyle}>
{bottomLeft}
</div>
)}
</div>
);
};
const getStyles = (topRight1Exists: boolean) => (theme: GrafanaTheme2) => ({
overlay: css`
position: absolute;
width: 100%;
height: 100%;
z-index: 500;
pointer-events: none;
`,
TR1: css`
right: 0.5em;
pointer-events: auto;
position: absolute;
top: 0.5em;
`,
TR2: css`
position: absolute;
top: ${topRight1Exists ? '80' : '8'}px;
right: 8px;
pointer-events: auto;
`,
BL: css`
position: absolute;
bottom: 8px;
left: 8px;
pointer-events: auto;
`,
});