diff --git a/packages/grafana-ui/src/components/PanelChrome/PanelChrome.story.tsx b/packages/grafana-ui/src/components/PanelChrome/PanelChrome.story.tsx index 994756175e4..ddfb9aa3b92 100644 --- a/packages/grafana-ui/src/components/PanelChrome/PanelChrome.story.tsx +++ b/packages/grafana-ui/src/components/PanelChrome/PanelChrome.story.tsx @@ -9,7 +9,7 @@ import { PanelChrome, PanelChromeProps } from '@grafana/ui'; import { DashboardStoryCanvas } from '../../utils/storybook/DashboardStoryCanvas'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; -import { HorizontalGroup, VerticalGroup } from '../Layout/Layout'; +import { HorizontalGroup } from '../Layout/Layout'; import { Menu } from '../Menu/Menu'; const meta: ComponentMeta = { @@ -91,8 +91,8 @@ export const Examples = () => { return ( - - +
+ {renderPanel('Has statusMessage', { title: 'Default title', statusMessage: 'Error text', @@ -116,8 +116,7 @@ export const Examples = () => { title: 'Default title', loadingState: LoadingState.Loading, })} - - + {renderPanel('Default panel: no non-required props')} {renderPanel('No padding', { padding: 'none', @@ -131,8 +130,7 @@ export const Examples = () => { {renderPanel('No title, loading loadingState', { loadingState: LoadingState.Loading, })} - - + {renderPanel('Error status, menu', { title: 'Default title', menu, @@ -155,16 +153,11 @@ export const Examples = () => { menu, loadingState: LoadingState.Streaming, })} - {renderPanel('loadingState is Loading, menu', { title: 'Default title', menu, loadingState: LoadingState.Loading, })} - - - - {renderPanel('Deprecated error indicator', { title: 'Default title', leftItems: [ @@ -186,8 +179,6 @@ export const Examples = () => { />, ], })} - - {renderPanel('Deprecated error indicator, menu', { title: 'Default title', menu, @@ -199,8 +190,14 @@ export const Examples = () => { />, ], })} - - + {renderPanel('Display mode = transparent', { + title: 'Default title', + displayMode: 'transparent', + menu, + leftItems: [], + })} + +
); }; diff --git a/packages/grafana-ui/src/components/PanelChrome/PanelChrome.tsx b/packages/grafana-ui/src/components/PanelChrome/PanelChrome.tsx index df64acc0f88..85f9ec0b829 100644 --- a/packages/grafana-ui/src/components/PanelChrome/PanelChrome.tsx +++ b/packages/grafana-ui/src/components/PanelChrome/PanelChrome.tsx @@ -51,6 +51,7 @@ export interface PanelChromeProps { * of showing/interacting with the panel's state */ leftItems?: ReactNode[]; + displayMode?: 'default' | 'transparent'; } /** @@ -68,6 +69,7 @@ export function PanelChrome({ padding = 'md', title = '', description = '', + displayMode = 'default', titleItems = [], menu, dragClass, @@ -105,6 +107,11 @@ export function PanelChrome({ const containerStyles: CSSProperties = { width, height }; const ariaLabel = title ? selectors.components.Panels.Panel.containerByTitle(title) : 'Panel'; + if (displayMode === 'transparent') { + containerStyles.backgroundColor = 'transparent'; + containerStyles.border = 'none'; + } + return (
@@ -151,7 +158,7 @@ export function PanelChrome({ )} - {leftItems &&
{itemsRenderer(leftItems, (item) => item)}
} + {leftItems &&
{itemsRenderer(leftItems, (item) => item)}
}
{statusMessage && ( @@ -207,7 +214,7 @@ const getContentStyle = ( }; const getStyles = (theme: GrafanaTheme2) => { - const { background, borderColor } = theme.components.panel; + const { background, borderColor, padding } = theme.components.panel; return { container: css({ @@ -248,7 +255,7 @@ const getStyles = (theme: GrafanaTheme2) => { label: 'panel-header', display: 'flex', alignItems: 'center', - padding: theme.spacing(0, 0, 0, 1), + padding: theme.spacing(0, 0, 0, padding), }), streaming: css({ label: 'panel-streaming', @@ -288,6 +295,10 @@ const getStyles = (theme: GrafanaTheme2) => { left: '50%', transform: 'translateX(-50%)', }), + leftItems: css({ + display: 'flex', + paddingRight: theme.spacing(padding), + }), rightAligned: css({ label: 'right-aligned-container', marginLeft: 'auto', diff --git a/packages/grafana-ui/src/components/PanelChrome/TitleItem.tsx b/packages/grafana-ui/src/components/PanelChrome/TitleItem.tsx index f1880272890..9fe041ef172 100644 --- a/packages/grafana-ui/src/components/PanelChrome/TitleItem.tsx +++ b/packages/grafana-ui/src/components/PanelChrome/TitleItem.tsx @@ -50,7 +50,6 @@ const getStyles = (theme: GrafanaTheme2) => { item: css({ color: `${theme.colors.text.secondary}`, label: 'panel-header-item', - backgroundColor: `${theme.colors.background.primary}`, cursor: 'auto', border: 'none', borderRadius: `${theme.shape.borderRadius()}`, diff --git a/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx b/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx index f7602d50dac..03d80ac3a0c 100644 --- a/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx +++ b/public/app/features/dashboard/dashgrid/PanelStateWrapper.tsx @@ -679,6 +679,7 @@ export class PanelStateWrapper extends PureComponent { dragClass={dragClass} dragClassCancel="grid-drag-cancel" padding={padding} + displayMode={transparent ? 'transparent' : 'default'} > {(innerWidth, innerHeight) => ( <>