|
|
|
@ -1,5 +1,4 @@ |
|
|
|
|
import { css } from '@emotion/css'; |
|
|
|
|
import classnames from 'classnames'; |
|
|
|
|
import { css, cx } from '@emotion/css'; |
|
|
|
|
import React, { ReactElement, useCallback, useRef, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data'; |
|
|
|
@ -38,18 +37,19 @@ export function HoverWidget({ menu, title, dragClass, children, offset = -32 }: |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div |
|
|
|
|
className={classnames(styles.container, { 'show-on-hover': !menuOpen })} |
|
|
|
|
className={cx(styles.container, { 'show-on-hover': !menuOpen })} |
|
|
|
|
style={{ top: `${offset}px` }} |
|
|
|
|
data-testid="hover-header-container" |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
|
className={classnames(styles.square, styles.draggable, dragClass)} |
|
|
|
|
className={cx(styles.square, styles.draggable, dragClass)} |
|
|
|
|
onPointerDown={onPointerDown} |
|
|
|
|
onPointerUp={onPointerUp} |
|
|
|
|
ref={draggableRef} |
|
|
|
|
> |
|
|
|
|
<Icon name="draggabledots" /> |
|
|
|
|
<Icon name="expand-arrows" className={styles.draggableIcon} /> |
|
|
|
|
</div> |
|
|
|
|
{!title && <h6 className={cx(styles.untitled, styles.draggable, dragClass)}>Untitled</h6>} |
|
|
|
|
{children} |
|
|
|
|
<div className={styles.square}> |
|
|
|
|
<PanelMenu |
|
|
|
@ -77,7 +77,7 @@ function getStyles(theme: GrafanaTheme2) { |
|
|
|
|
position: 'absolute', |
|
|
|
|
zIndex: 1, |
|
|
|
|
right: 0, |
|
|
|
|
boxSizing: 'border-box', |
|
|
|
|
boxSizing: 'content-box', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
background: theme.colors.background.secondary, |
|
|
|
|
color: theme.colors.text.primary, |
|
|
|
@ -92,18 +92,37 @@ function getStyles(theme: GrafanaTheme2) { |
|
|
|
|
alignItems: 'center', |
|
|
|
|
width: theme.spacing(4), |
|
|
|
|
height: '100%', |
|
|
|
|
paddingRight: theme.spacing(0.5), |
|
|
|
|
}), |
|
|
|
|
draggable: css({ |
|
|
|
|
cursor: 'move', |
|
|
|
|
// mobile do not support draggable panels
|
|
|
|
|
[theme.breakpoints.down('md')]: { |
|
|
|
|
display: 'none', |
|
|
|
|
}, |
|
|
|
|
}), |
|
|
|
|
menuButton: css({ |
|
|
|
|
color: theme.colors.text.primary, |
|
|
|
|
// Background and border are overriden when topnav toggle is disabled
|
|
|
|
|
background: 'inherit', |
|
|
|
|
border: 'none', |
|
|
|
|
'&:hover': { |
|
|
|
|
background: 'inherit', |
|
|
|
|
background: theme.colors.secondary.main, |
|
|
|
|
}, |
|
|
|
|
}), |
|
|
|
|
title: css({ |
|
|
|
|
padding: theme.spacing(0.75), |
|
|
|
|
}), |
|
|
|
|
untitled: css({ |
|
|
|
|
color: theme.colors.text.disabled, |
|
|
|
|
fontStyle: 'italic', |
|
|
|
|
marginBottom: 0, |
|
|
|
|
}), |
|
|
|
|
draggableIcon: css({ |
|
|
|
|
transform: 'rotate(45deg)', |
|
|
|
|
color: theme.colors.text.secondary, |
|
|
|
|
'&:hover': { |
|
|
|
|
color: theme.colors.text.primary, |
|
|
|
|
}, |
|
|
|
|
}), |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|