1+ import { useTheme } from '@mui/material/styles' ;
12import _ from 'lodash' ;
23import React from 'react' ;
34import { Tooltip , TooltipProps } from '../../base' ;
@@ -12,6 +13,8 @@ type CustomTooltipProps = {
1213 fontWeight ?: number ;
1314 variant ?: 'standard' | 'small' ;
1415 bgColor ?: string ;
16+ textColor ?: string ;
17+ useThemeColors ?: boolean ; // Add prop to enable theme-based colors
1518 componentsProps ?: TooltipProps [ 'componentsProps' ] ;
1619} & Omit < TooltipProps , 'title' | 'onClick' > ;
1720
@@ -24,9 +27,25 @@ function CustomTooltip({
2427 fontWeight = 400 ,
2528 variant = 'standard' ,
2629 bgColor = '#141414' ,
30+ textColor = WHITE ,
31+ useThemeColors = false , // Default to false for backward compatibility
2732 componentsProps = { } ,
2833 ...props
2934} : CustomTooltipProps ) : JSX . Element {
35+ const theme = useTheme ( ) ;
36+
37+ // Determine colors based on theme when useThemeColors is true
38+ const tooltipBgColor = useThemeColors
39+ ? theme . palette . mode === 'dark'
40+ ? '#141414'
41+ : '#ffffff'
42+ : bgColor ;
43+
44+ const tooltipTextColor = useThemeColors
45+ ? theme . palette . mode === 'dark'
46+ ? WHITE
47+ : '#000000'
48+ : textColor ;
3049 return (
3150 < Tooltip
3251 enterTouchDelay = { 0 }
@@ -35,14 +54,17 @@ function CustomTooltip({
3554 {
3655 tooltip : {
3756 sx : {
38- background : bgColor ,
39- color : WHITE ,
57+ background : tooltipBgColor ,
58+ color : tooltipTextColor ,
4059 maxWidth : '600px' ,
4160 fontSize : fontSize || ( variant === 'standard' ? '1rem' : '0.75rem' ) ,
4261 fontWeight : { fontWeight } ,
4362 borderRadius : '0.5rem' ,
4463 padding : variant === 'standard' ? '0.9rem' : '0.5rem 0.75rem' ,
45- boxShadow : 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
64+ boxShadow :
65+ useThemeColors && theme . palette . mode === 'light'
66+ ? 'rgba(0, 0, 0, 0.1) 0px 4px 10px, rgba(0, 0, 0, 0.05) 0px 2px 4px'
67+ : 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
4668 }
4769 } ,
4870 popper : {
@@ -53,7 +75,7 @@ function CustomTooltip({
5375 } ,
5476 arrow : {
5577 sx : {
56- color : bgColor
78+ color : tooltipBgColor
5779 }
5880 }
5981 } ,
0 commit comments