Skip to content

Commit b5957ee

Browse files
authored
Add tooltip with the meaning of each plot section (#1851)
* Add tooltip with the meaning of each plot section * Add test * Fix vertical alignment * Capitalize descriptions
1 parent ccc411c commit b5957ee

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

webview/src/plots/components/App.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { act } from 'react-dom/test-utils'
3434
import { App } from './App'
3535
import { Plots } from './Plots'
3636
import { NewSectionBlock } from './templatePlots/TemplatePlots'
37+
import { SectionDescription } from './PlotsContainer'
3738
import { vsCodeApi } from '../../shared/api'
3839
import { createBubbledEvent, dragAndDrop, dragEnter } from '../../test/dragDrop'
3940
import { DragEnterDirection } from '../../shared/components/dragDrop/util'
@@ -1056,6 +1057,33 @@ describe('App', () => {
10561057
expect(screen.getByTestId('modal')).toBeInTheDocument()
10571058
})
10581059

1060+
it('should show a tooltip with the meaning of each plot section', () => {
1061+
renderAppWithData({
1062+
checkpoint: checkpointPlotsFixture,
1063+
comparison: comparisonTableFixture,
1064+
sectionCollapsed: DEFAULT_SECTION_COLLAPSED,
1065+
template: complexTemplatePlotsFixture
1066+
})
1067+
1068+
const [templateInfo, comparisonInfo, checkpointInfo] =
1069+
screen.getAllByTestId('info-tooltip-toggle')
1070+
1071+
fireEvent.mouseEnter(templateInfo, { bubbles: true })
1072+
expect(
1073+
screen.getByText(SectionDescription[Section.TEMPLATE_PLOTS])
1074+
).toBeInTheDocument()
1075+
1076+
fireEvent.mouseEnter(comparisonInfo, { bubbles: true })
1077+
expect(
1078+
screen.getByText(SectionDescription[Section.COMPARISON_TABLE])
1079+
).toBeInTheDocument()
1080+
1081+
fireEvent.mouseEnter(checkpointInfo, { bubbles: true })
1082+
expect(
1083+
screen.getByText(SectionDescription[Section.CHECKPOINT_PLOTS])
1084+
).toBeInTheDocument()
1085+
})
1086+
10591087
describe('Virtualization', () => {
10601088
const changeSize = async (size: string, buttonPosition: number) => {
10611089
const sizePickerButton =

webview/src/plots/components/PlotsContainer.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { AllIcons, Icon } from '../../shared/components/Icon'
1515
import { IconMenu } from '../../shared/components/iconMenu/IconMenu'
1616
import { IconMenuItemProps } from '../../shared/components/iconMenu/IconMenuItem'
1717
import { sendMessage } from '../../shared/vscode'
18+
import Tooltip from '../../shared/components/tooltip/Tooltip'
1819

1920
export interface PlotsContainerProps {
2021
sectionCollapsed: SectionCollapsed
@@ -31,6 +32,24 @@ export type BasicContainerProps = Pick<
3132
'onRename' | 'onResize' | 'sectionCollapsed'
3233
>
3334

35+
export const SectionDescription = {
36+
[Section.CHECKPOINT_PLOTS]:
37+
'Linear plots based on data from the experiments table.',
38+
[Section.COMPARISON_TABLE]:
39+
'A table used to display image plots side by side.',
40+
[Section.TEMPLATE_PLOTS]:
41+
'JSON, YAML, CSV or TSV files visualized using Vega pre-defined or custom Vega-Lite templates.'
42+
}
43+
44+
const InfoIcon = () => (
45+
<Icon
46+
icon={AllIcons.INFO}
47+
width={16}
48+
height={16}
49+
className={styles.infoIcon}
50+
/>
51+
)
52+
3453
export const PlotsContainer: React.FC<PlotsContainerProps> = ({
3554
sectionCollapsed,
3655
sectionKey,
@@ -96,6 +115,13 @@ export const PlotsContainer: React.FC<PlotsContainerProps> = ({
96115
onRename(sectionKey, title)
97116
}
98117

118+
const tooltipContent = (
119+
<div className={styles.infoTooltip}>
120+
<InfoIcon />
121+
{SectionDescription[sectionKey]}
122+
</div>
123+
)
124+
99125
return (
100126
<div className={styles.plotsContainerWrapper}>
101127
<details open={open} className={styles.plotsContainer}>
@@ -126,6 +152,14 @@ export const PlotsContainer: React.FC<PlotsContainerProps> = ({
126152
) : (
127153
sectionTitle
128154
)}
155+
<Tooltip content={tooltipContent} placement="bottom-end">
156+
<div
157+
className={styles.infoTooltipToggle}
158+
data-testid="info-tooltip-toggle"
159+
>
160+
<InfoIcon />
161+
</div>
162+
</Tooltip>
129163
</summary>
130164
<div>
131165
{open && (

webview/src/plots/components/styles.module.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ $gap: 20px;
1717
margin: 14px 10px;
1818
font-weight: bold;
1919
font-size: 1.25rem;
20+
display: flex;
21+
align-items: center;
2022
}
2123
}
2224

@@ -321,6 +323,30 @@ $gap: 20px;
321323
}
322324
}
323325

326+
.infoTooltipToggle {
327+
display: flex;
328+
align-items: center;
329+
}
330+
331+
.infoIcon {
332+
fill: $accent-color;
333+
margin-left: 6px;
334+
}
335+
336+
.infoTooltip {
337+
max-width: 220px;
338+
padding: 12px 8px;
339+
white-space: normal;
340+
display: flex;
341+
gap: 4px;
342+
font-size: 0.8125rem;
343+
344+
svg {
345+
min-width: 16px;
346+
min-height: 16px;
347+
}
348+
}
349+
324350
:global(.has-actions) {
325351
summary {
326352
background: $fg-color !important;

webview/src/shared/components/Icon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Ellipsis,
1111
GraphLine,
1212
Gripper,
13+
Info,
1314
Lines,
1415
Pencil,
1516
Refresh,
@@ -27,6 +28,7 @@ export const AllIcons = {
2728
ELLIPSIS: Ellipsis,
2829
GRAPH_LINE: GraphLine,
2930
GRIPPER: Gripper,
31+
INFO: Info,
3032
LINES: Lines,
3133
PENCIL: Pencil,
3234
REFRESH: Refresh,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from 'react'
2+
import { SVGProps } from 'react'
3+
4+
const SvgInfo = (props: SVGProps<SVGSVGElement>) => (
5+
<svg
6+
width={16}
7+
height={16}
8+
viewBox="0 0 16 16"
9+
xmlns="http://www.w3.org/2000/svg"
10+
fill="currentColor"
11+
{...props}
12+
>
13+
<path
14+
fillRule="evenodd"
15+
clipRule="evenodd"
16+
d="M8.568 1.031A6.8 6.8 0 0 1 12.76 3.05a7.06 7.06 0 0 1 .46 9.39 6.85 6.85 0 0 1-8.58 1.74 7 7 0 0 1-3.12-3.5 7.12 7.12 0 0 1-.23-4.71 7 7 0 0 1 2.77-3.79 6.8 6.8 0 0 1 4.508-1.149zM9.04 13.88a5.89 5.89 0 0 0 3.41-2.07 6.07 6.07 0 0 0-.4-8.06 5.82 5.82 0 0 0-7.43-.74 6.06 6.06 0 0 0 .5 10.29 5.81 5.81 0 0 0 3.92.58zM7.375 6h1.25V5h-1.25v1zm1.25 1v4h-1.25V7h1.25z"
17+
/>
18+
</svg>
19+
)
20+
21+
export default SvgInfo

webview/src/shared/components/icons/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { default as DownArrow } from './DownArrow'
1010
export { default as Ellipsis } from './Ellipsis'
1111
export { default as GraphLine } from './GraphLine'
1212
export { default as Gripper } from './Gripper'
13+
export { default as Info } from './Info'
1314
export { default as Lines } from './Lines'
1415
export { default as Pencil } from './Pencil'
1516
export { default as Pin } from './Pin'

0 commit comments

Comments
 (0)