Dashboards: PanelChrome - remove untitled placeholder and add border when panel is transparent (#73150)

This commit is contained in:
Alexa V 2023-08-10 15:17:56 +02:00 committed by GitHub
parent 05b710ef0c
commit 0dcba0952e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -48,7 +48,6 @@ export function HoverWidget({ menu, title, dragClass, children, offset = -32, on
<Icon name="expand-arrows" className={styles.draggableIcon} /> <Icon name="expand-arrows" className={styles.draggableIcon} />
</div> </div>
)} )}
{!title && <h6 className={cx(styles.untitled, { [styles.draggable]: !!dragClass }, dragClass)}>Untitled</h6>}
{children} {children}
{menu && ( {menu && (
<PanelMenu <PanelMenu
@ -103,12 +102,6 @@ function getStyles(theme: GrafanaTheme2) {
background: theme.colors.secondary.main, background: theme.colors.secondary.main,
}, },
}), }),
untitled: css({
color: theme.colors.text.disabled,
fontStyle: 'italic',
padding: theme.spacing(0, 1),
marginBottom: 0,
}),
draggableIcon: css({ draggableIcon: css({
transform: 'rotate(45deg)', transform: 'rotate(45deg)',
color: theme.colors.text.secondary, color: theme.colors.text.secondary,

View File

@ -122,6 +122,7 @@ export function PanelChrome({
// hover menu is only shown on hover when not on touch devices // hover menu is only shown on hover when not on touch devices
const showOnHoverClass = 'show-on-hover'; const showOnHoverClass = 'show-on-hover';
const isPanelTransparent = displayMode === 'transparent';
const headerHeight = getHeaderHeight(theme, hasHeader); const headerHeight = getHeaderHeight(theme, hasHeader);
const { contentStyle, innerWidth, innerHeight } = getContentStyle( const { contentStyle, innerWidth, innerHeight } = getContentStyle(
@ -139,11 +140,6 @@ export function PanelChrome({
}; };
const containerStyles: CSSProperties = { width, height: isOpen ? height : headerHeight }; const containerStyles: CSSProperties = { width, height: isOpen ? height : headerHeight };
if (displayMode === 'transparent') {
containerStyles.backgroundColor = 'transparent';
containerStyles.border = 'none';
}
const [ref, { width: loadingBarWidth }] = useMeasure<HTMLDivElement>(); const [ref, { width: loadingBarWidth }] = useMeasure<HTMLDivElement>();
/** Old property name now maps to actions */ /** Old property name now maps to actions */
@ -214,8 +210,13 @@ export function PanelChrome({
return ( return (
// tabIndex={0} is needed for keyboard accessibility in the plot area // tabIndex={0} is needed for keyboard accessibility in the plot area
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex <div
<div className={styles.container} style={containerStyles} data-testid={testid} tabIndex={0} ref={ref}> className={cx(styles.container, { [styles.transparentContainer]: isPanelTransparent })}
style={containerStyles}
data-testid={testid}
tabIndex={0} //eslint-disable-line jsx-a11y/no-noninteractive-tabindex
ref={ref}
>
<div className={styles.loadingBarContainer}> <div className={styles.loadingBarContainer}>
{loadingState === LoadingState.Loading ? ( {loadingState === LoadingState.Loading ? (
<LoadingBar width={loadingBarWidth} ariaLabel="Panel loading bar" /> <LoadingBar width={loadingBarWidth} ariaLabel="Panel loading bar" />
@ -361,6 +362,15 @@ const getStyles = (theme: GrafanaTheme2) => {
}, },
}, },
}), }),
transparentContainer: css({
label: 'panel-transparent-container',
backgroundColor: 'transparent',
border: '1px solid transparent',
boxSizing: 'border-box',
'&:hover': {
border: `1px solid ${borderColor}`,
},
}),
loadingBarContainer: css({ loadingBarContainer: css({
label: 'panel-loading-bar-container', label: 'panel-loading-bar-container',
position: 'absolute', position: 'absolute',