Skip to content

Commit 968af22

Browse files
authored
Merge pull request #930 from mrmerlin320/customTooltip
fix: update custom tooltip styles
2 parents 7f1a47b + 5936d9b commit 968af22

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

src/custom/CustomTooltip/customTooltip.tsx

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import _ from 'lodash';
12
import React from 'react';
23
import { Tooltip, TooltipProps } from '../../base';
34
import { WHITE } from '../../theme';
@@ -11,6 +12,7 @@ type CustomTooltipProps = {
1112
fontWeight?: number;
1213
variant?: 'standard' | 'small';
1314
bgColor?: string;
15+
componentsProps?: TooltipProps['componentsProps'];
1416
} & Omit<TooltipProps, 'title' | 'onClick'>;
1517

1618
function CustomTooltip({
@@ -22,34 +24,39 @@ function CustomTooltip({
2224
fontWeight = 400,
2325
variant = 'standard',
2426
bgColor = '#141414',
27+
componentsProps = {},
2528
...props
2629
}: CustomTooltipProps): JSX.Element {
2730
return (
2831
<Tooltip
29-
componentsProps={{
30-
tooltip: {
31-
sx: {
32-
background: bgColor,
33-
color: WHITE,
34-
fontSize: fontSize || (variant === 'standard' ? '1rem' : '0.75rem'),
35-
fontWeight: { fontWeight },
36-
borderRadius: '0.5rem',
37-
padding: variant === 'standard' ? '0.9rem' : '0.5rem 0.75rem',
38-
boxShadow: 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
32+
componentsProps={_.merge(
33+
{
34+
tooltip: {
35+
sx: {
36+
background: bgColor,
37+
color: WHITE,
38+
maxWidth: '600px',
39+
fontSize: fontSize || (variant === 'standard' ? '1rem' : '0.75rem'),
40+
fontWeight: { fontWeight },
41+
borderRadius: '0.5rem',
42+
padding: variant === 'standard' ? '0.9rem' : '0.5rem 0.75rem',
43+
boxShadow: 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
44+
}
45+
},
46+
popper: {
47+
sx: {
48+
zIndex: 9999999999,
49+
opacity: '1'
50+
}
51+
},
52+
arrow: {
53+
sx: {
54+
color: bgColor
55+
}
3956
}
4057
},
41-
popper: {
42-
sx: {
43-
zIndex: 9999999999,
44-
opacity: '1'
45-
}
46-
},
47-
arrow: {
48-
sx: {
49-
color: bgColor
50-
}
51-
}
52-
}}
58+
componentsProps
59+
)}
5360
title={typeof title === 'string' ? <RenderMarkdownTooltip content={title} /> : title}
5461
placement={placement}
5562
arrow

0 commit comments

Comments
 (0)