Skip to content

Commit 219c241

Browse files
authored
fix: improve tooltip in different color theme (#304)
* fix: improve tooltip in different color theme * fix(components): add font-family in mac for tooltip
1 parent a400950 commit 219c241

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

src/common/className.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Utils } from '@dtinsight/dt-utils/lib';
12
import { isEmpty } from 'lodash';
23
import { APP_PREFIX } from 'mo/common/const';
34
/**
@@ -55,3 +56,11 @@ export function getBEMElement(block: string, element: string) {
5556
export function getBEMModifier(blockOrElement: string, modifier: string) {
5657
return `${blockOrElement}--${modifier}`;
5758
}
59+
60+
/**
61+
* Returns the className of font-family in mac
62+
* @returns
63+
*/
64+
export function getFontInMac() {
65+
return Utils.isMacOs() ? 'mac' : '';
66+
}

src/components/tooltip/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import { default as RcTooltip } from 'rc-tooltip';
33
import 'rc-tooltip/assets/bootstrap.css';
4-
import { TooltipProps } from 'rc-tooltip/lib/Tooltip';
4+
import type { TooltipProps } from 'rc-tooltip/lib/Tooltip';
5+
import { classNames, getFontInMac } from 'mo/common/className';
56

67
export interface IToolTipProps extends TooltipProps {}
78

@@ -10,15 +11,18 @@ const Tooltip = ({
1011
children,
1112
placement = 'bottom',
1213
trigger = 'hover',
14+
overlayClassName,
15+
mouseEnterDelay,
1316
...rest
1417
}: IToolTipProps) => {
1518
if (overlay) {
1619
return (
1720
<RcTooltip
21+
overlayClassName={classNames(getFontInMac(), overlayClassName)}
1822
placement={placement}
1923
trigger={trigger}
2024
overlay={overlay}
21-
mouseEnterDelay={0.1}
25+
mouseEnterDelay={mouseEnterDelay || 0.1}
2226
{...rest}
2327
>
2428
{children}

src/components/tooltip/style.scss

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
@import 'mo/style/common';
22

33
#{$rcTooltip} {
4+
background-color: var(--menu-background);
45
box-sizing: border-box;
5-
color: var(--tooltip-color);
6+
color: var(--menu-foreground);
7+
font-size: 13px;
68
margin: 0;
79
opacity: 1;
810
padding: 0;
911

1012
&-inner {
11-
background-color: var(--tooltip-background);
13+
background-color: inherit;
1214
border-radius: 2px;
13-
box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
15+
box-shadow: 0 2px 8px var(--widget-shadow);
1416
box-sizing: border-box;
17+
color: inherit;
18+
min-height: auto;
1519
min-width: 30px;
1620
padding: 6px 8px;
1721
}
1822
}
1923

2024
#{$rcTooltip}-placement-bottom #{$rcTooltip}-arrow {
21-
border-bottom-color: var(--tooltip-background);
25+
border-bottom-color: var(--menu-background);
2226
top: -5px;
2327
}

src/extensions/theme-defaults/themes/dark_defaults.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@
5151
"tab.activeForeground": "#fff",
5252
"diffEditor.insertedTextBackground": "#9bb95533",
5353
"diffEditor.removedTextBackground": "#ff000033",
54-
"actionBar.checkedBackground": "rgba(0, 127, 212, 0.4)",
55-
"tooltip.color": "#333",
56-
"tooltip.background": "rgba(0, 0, 0, 0.75)"
54+
"actionBar.checkedBackground": "rgba(0, 127, 212, 0.4)"
5755
},
5856
"semanticHighlighting": true
5957
}

src/extensions/theme-defaults/themes/light_defaults.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
"tab.inactiveBackground": "rgb(236, 236, 236)",
5050
"tab.inactiveForeground": "rgba(51, 51, 51, 0.7)",
5151
"tab.activeBackground": "#fffffe",
52-
"tab.activeForeground": "#333333",
53-
"tooltip.color": "#333",
54-
"tooltip.background": "rgba(0, 0, 0, 0.75)"
52+
"tab.activeForeground": "#333333"
5553
},
5654
"semanticHighlighting": true
5755
}

src/workbench/workbench.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SplitPane from 'react-split-pane';
44
import Pane from 'react-split-pane/lib/Pane';
55
import { container } from 'tsyringe';
66

7-
import { classNames, prefixClaName } from 'mo/common/className';
7+
import { classNames, getFontInMac, prefixClaName } from 'mo/common/className';
88

99
import { EditorView } from 'mo/workbench/editor';
1010
import { SidebarView } from 'mo/workbench/sidebar';
@@ -13,7 +13,6 @@ import { ActivityBarView } from 'mo/workbench/activityBar';
1313
import { StatusBarView } from 'mo/workbench/statusBar';
1414
import { PanelView } from 'mo/workbench/panel';
1515
import { ID_APP } from 'mo/common/id';
16-
import { Utils } from '@dtinsight/dt-utils';
1716
import { APP_PREFIX } from 'mo/common/const';
1817

1918
import { connect } from 'mo/react';
@@ -27,7 +26,7 @@ import { IWorkbench } from 'mo/model';
2726
const mainBenchClassName = prefixClaName('mainBench');
2827
const workbenchClassName = prefixClaName('workbench');
2928
const compositeBarClassName = prefixClaName('compositeBar');
30-
const appClassName = classNames(APP_PREFIX, Utils.isMacOs() ? 'mac' : '');
29+
const appClassName = classNames(APP_PREFIX, getFontInMac());
3130

3231
const layoutController = container.resolve(LayoutController);
3332
const layoutService = container.resolve(LayoutService);

0 commit comments

Comments
 (0)