Skip to content

Commit 6364c14

Browse files
authored
Panel Description Tooltip Design Change (#79213)
* wrapped Embeddable Panel title in EuiTooltip and centered description icon
1 parent fccfad2 commit 6364c14

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

src/plugins/embeddable/public/lib/panel/_embeddable_panel.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@
5454
.embPanel__titleInner {
5555
overflow: hidden;
5656
display: flex;
57+
align-items: center;
5758
padding-right: $euiSizeS;
5859
}
5960

61+
.embPanel__titleTooltipAnchor {
62+
max-width: 100%;
63+
}
64+
6065
.embPanel__titleText {
6166
@include euiTextTruncate;
6267
}

src/plugins/embeddable/public/lib/panel/panel_header/panel_header.tsx

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ function renderNotifications(
9999
});
100100
}
101101

102-
function renderTooltip(description: string) {
103-
return (
104-
description !== '' && (
105-
<EuiToolTip content={description} delay="regular" position="right">
106-
<EuiIcon type="iInCircle" />
107-
</EuiToolTip>
108-
)
109-
);
110-
}
111-
112102
type EmbeddableWithDescription = IEmbeddable & { getDescription: () => string };
113103

114104
function getViewDescription(embeddable: IEmbeddable | EmbeddableWithDescription) {
@@ -134,9 +124,10 @@ export function PanelHeader({
134124
embeddable,
135125
headerId,
136126
}: PanelHeaderProps) {
137-
const viewDescription = getViewDescription(embeddable);
138-
const showTitle = !hidePanelTitle && (!isViewMode || title || viewDescription !== '');
139-
const showPanelBar = !isViewMode || badges.length > 0 || notifications.length > 0 || showTitle;
127+
const description = getViewDescription(embeddable);
128+
const showTitle = !hidePanelTitle && (!isViewMode || title);
129+
const showPanelBar =
130+
!isViewMode || badges.length > 0 || notifications.length > 0 || showTitle || description;
140131
const classes = classNames('embPanel__header', {
141132
// eslint-disable-next-line @typescript-eslint/naming-convention
142133
'embPanel__header--floater': !showPanelBar,
@@ -174,26 +165,36 @@ export function PanelHeader({
174165
);
175166
}
176167

168+
const renderTitle = () => {
169+
const titleComponent = showTitle ? (
170+
<span className={title ? 'embPanel__titleText' : 'embPanel__placeholderTitleText'}>
171+
{title || placeholderTitle}
172+
</span>
173+
) : undefined;
174+
return description ? (
175+
<EuiToolTip
176+
content={description}
177+
delay="regular"
178+
position="top"
179+
anchorClassName="embPanel__titleTooltipAnchor"
180+
>
181+
<span className="embPanel__titleInner">
182+
{titleComponent} <EuiIcon type="iInCircle" color="subdued" />
183+
</span>
184+
</EuiToolTip>
185+
) : (
186+
titleComponent
187+
);
188+
};
189+
177190
return (
178191
<figcaption
179192
className={classes}
180193
data-test-subj={`embeddablePanelHeading-${(title || '').replace(/\s/g, '')}`}
181194
>
182195
<h2 data-test-subj="dashboardPanelTitle" className="embPanel__title embPanel__dragger">
183-
{showTitle ? (
184-
<span className="embPanel__titleInner">
185-
<span
186-
className={title ? 'embPanel__titleText' : 'embPanel__placeholderTitleText'}
187-
aria-hidden="true"
188-
>
189-
{title || placeholderTitle}
190-
</span>
191-
<EuiScreenReaderOnly>{getAriaLabel()}</EuiScreenReaderOnly>
192-
{renderTooltip(viewDescription)}
193-
</span>
194-
) : (
195-
<EuiScreenReaderOnly>{getAriaLabel()}</EuiScreenReaderOnly>
196-
)}
196+
<EuiScreenReaderOnly>{getAriaLabel()}</EuiScreenReaderOnly>
197+
{renderTitle()}
197198
{renderBadges(badges, embeddable)}
198199
</h2>
199200
{renderNotifications(notifications, embeddable)}

0 commit comments

Comments
 (0)