Skip to content

Commit ff41c01

Browse files
authored
Match tooltip styles to VS Code (#2353)
* add border to experiments table tooltips * push border into global style * remove arrow from tooltips * remove extra padding and global style * reduce padding by 5px in info tooltip * remove unused styles file
1 parent cf28616 commit ff41c01

File tree

9 files changed

+29
-20
lines changed

9 files changed

+29
-20
lines changed

webview/src/experiments/components/table/Indicators.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from '../../../shared/components/icons'
1414
import { sendMessage } from '../../../shared/vscode'
1515
import Tooltip from '../../../shared/components/tooltip/Tooltip'
16-
import tooltipStyles from '../../../shared/components/tooltip/styles.module.scss'
1716
import { pluralize } from '../../../util/strings'
1817
import { ExperimentsState } from '../../store'
1918

@@ -31,7 +30,6 @@ export const IndicatorTooltip: React.FC<IndicatorTooltipProps> = ({
3130
placement="bottom-start"
3231
disabled={!tooltipContent}
3332
content={tooltipContent}
34-
className={tooltipStyles.padded}
3533
ref={wrapperRef}
3634
>
3735
{children}

webview/src/experiments/components/table/styles.module.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ $workspace-row-edge-margin: $edge-padding - $cell-padding;
651651
white-space: pre-wrap;
652652
display: flex;
653653
gap: 4px;
654-
font-size: 0.8125rem;
655654

656655
svg {
657656
min-width: 16px;

webview/src/experiments/util/buildDynamicColumns.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ const Cell: React.FC<Cell<Experiment, CellValue>> = cell => {
9797
<Tooltip
9898
content={<CellTooltip stringValue={stringValue} />}
9999
placement="bottom-end"
100-
arrow={true}
101100
delay={[CELL_TOOLTIP_DELAY, 0]}
102101
interactive={true}
103102
>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ $gap: 20px;
365365

366366
.infoTooltip {
367367
max-width: 220px;
368-
padding: 12px 8px;
368+
padding: 7px 3px;
369369
white-space: normal;
370370
display: flex;
371371
gap: 4px;

webview/src/shared/components/contextMenu/ContextMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ export const ContextMenu: React.FC<ContextMenuProps> = ({
5252
trigger = 'contextmenu'
5353
}) => (
5454
<Tooltip
55-
arrow
5655
trigger={trigger}
5756
delay={[100, 200]}
5857
placement={'bottom'}
5958
interactive
59+
isContextMenu={true}
6060
onTrigger={positionContextMenuAndDisableEvents}
6161
content={content}
6262
onShow={onShow}

webview/src/shared/components/iconMenu/IconMenu.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useSingleton } from '@tippyjs/react'
33
import { IconMenuItem, IconMenuItemProps } from './IconMenuItem'
44
import styles from './styles.module.scss'
55
import Tooltip from '../tooltip/Tooltip'
6-
import tooltipStyles from '../tooltip/styles.module.scss'
76

87
interface IconMenuProps {
98
items: IconMenuItemProps[]
@@ -29,7 +28,6 @@ export const IconMenu: React.FC<IconMenuProps> = ({ items }) => {
2928

3029
return (
3130
<Tooltip
32-
className={tooltipStyles.padded}
3331
singleton={tooltipSource}
3432
placement="bottom-end"
3533
popperOptions={popperOptions}

webview/src/shared/components/tooltip/Tooltip.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const CELL_TOOLTIP_DELAY = 1000
88

99
const TooltipRenderFunction: React.ForwardRefRenderFunction<
1010
unknown,
11-
TippyProps
11+
TippyProps & { isContextMenu?: boolean }
1212
> = (
1313
{
1414
children,
@@ -27,19 +27,23 @@ const TooltipRenderFunction: React.ForwardRefRenderFunction<
2727
hideOnClick,
2828
onTrigger,
2929
appendTo,
30-
animation = false,
31-
className = typeof content === 'string' ? styles.padded : undefined,
32-
arrow = false
30+
isContextMenu = false,
31+
animation = false
3332
},
3433
ref
3534
) => (
3635
<Tippy
36+
arrow={false}
3737
animation={animation}
3838
appendTo={appendTo}
39-
content={content}
40-
className={className}
39+
content={
40+
isContextMenu ? (
41+
content
42+
) : (
43+
<div className={styles.tooltipContent}>{content}</div>
44+
)
45+
}
4146
placement={placement}
42-
arrow={arrow}
4347
delay={delay}
4448
disabled={disabled}
4549
popperOptions={popperOptions}

webview/src/shared/components/tooltip/styles.module.scss

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
$tooltip-border: var(--vscode-editorHoverWidget-border);
12
$vscode-drop-shadow: drop-shadow(0 0 4px var(--vscode-widget-shadow));
23
$foreground: var(--vscode-quickInput-foreground);
34
$background: var(--vscode-quickInput-background);
45
$font: var(--vscode-font-family);
56

6-
:global(.tippy-box).padded {
7-
& > :global(.tippy-content) {
8-
padding: 2px 6px;
9-
}
10-
}
117
:global(.tippy-box) {
128
filter: $vscode-drop-shadow;
139
font-family: $font;
@@ -30,3 +26,17 @@ $font: var(--vscode-font-family);
3026
z-index: 2;
3127
}
3228
}
29+
30+
.tooltipContent {
31+
border: 1px solid $tooltip-border;
32+
white-space: pre-wrap;
33+
padding: 5px;
34+
display: flex;
35+
gap: 4px;
36+
font-size: 0.8125rem;
37+
38+
svg {
39+
min-width: 16px;
40+
min-height: 16px;
41+
}
42+
}

webview/src/shared/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $header-bg-color: $bg-color;
2020
$header-border-color: $border-color;
2121
$meta-cell-color: var(--vscode-descriptionForeground);
2222
$header-resizer-color: var(--vscode-sash-hoverBorder);
23+
$tooltip-border: var(--vscode-editorHoverWidget-border);
2324

2425
$hover-background-color: var(--vscode-list-hoverBackground);
2526
$row-hover-background-color: var(--vscode-list-hoverBackground);

0 commit comments

Comments
 (0)