Skip to content

Commit 4343d0a

Browse files
committed
Modified the Box Shadow of Tooltip Component for Darkmode
Signed-off-by: SplinterSword <[email protected]>
1 parent 249863a commit 4343d0a

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/custom/CustomTooltip/customTooltip.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import _ from 'lodash';
22
import React from 'react';
3+
import type { Theme } from '@mui/material/styles';
4+
import { alpha } from '@mui/material';
35
import { Tooltip, TooltipProps } from '../../base';
46
import { WHITE } from '../../theme';
57
import { RenderMarkdownTooltip } from '../Markdown';
@@ -40,10 +42,16 @@ function CustomTooltip({
4042
color: WHITE,
4143
maxWidth: '600px',
4244
fontSize: fontSize || (variant === 'standard' ? '1rem' : '0.75rem'),
43-
fontWeight: { fontWeight },
45+
fontWeight: fontWeight,
4446
borderRadius: '0.5rem',
4547
padding: variant === 'standard' ? '0.9rem' : '0.5rem 0.75rem',
46-
boxShadow: 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
48+
boxShadow: (theme: Theme) => {
49+
if (theme.palette.mode === 'light') {
50+
return 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px';
51+
}
52+
const green = theme.palette.primary.main;
53+
return `0 10px 30px ${alpha(green, 0.28)}, 0 2px 8px ${alpha(green, 0.2)}, 0 0 1px ${alpha(green, 0.32)}`;
54+
}
4755
}
4856
},
4957
popper: {

src/theme/components.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { MuiSwitch } from './components/switch.modifier';
2020
import { MuiTab } from './components/tab.modifier';
2121
import { MuiTableCombineTheme } from './components/table.modifier';
2222
import { MuiTabs } from './components/tabs.modifier';
23+
import { MuiTooltip } from './components/tooltip.modifier';
2324

2425
export const components: Components<Theme> = {
2526
MuiAppBar,
@@ -42,5 +43,6 @@ export const components: Components<Theme> = {
4243
MuiButtonGroup,
4344
MuiButton,
4445
MuiListItem,
46+
MuiTooltip,
4547
...MuiTableCombineTheme
4648
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { alpha } from '@mui/material';
2+
import type { Components, Theme } from '@mui/material/styles';
3+
4+
export const MuiTooltip: Components<Theme>['MuiTooltip'] = {
5+
styleOverrides: {
6+
tooltip: ({ theme }) => {
7+
const isLight = theme.palette.mode === 'light';
8+
const shadow = isLight
9+
? `0 10px 30px ${alpha('#000', 0.12)}, 0 2px 8px ${alpha('#000', 0.08)}`
10+
: (() => {
11+
const green = theme.palette.primary.main;
12+
return `0 10px 30px ${alpha(green, 0.28)}, 0 2px 8px ${alpha(green, 0.2)}, 0 0 1px ${alpha(green, 0.32)}`;
13+
})();
14+
15+
return {
16+
boxShadow: shadow,
17+
} as const;
18+
},
19+
arrow: ({ theme }) => {
20+
return {
21+
color: theme.palette.divider
22+
} as const;
23+
}
24+
}
25+
};

0 commit comments

Comments
 (0)