Skip to content

Commit 5f4c2a4

Browse files
feat: added light mode support
Signed-off-by: saurabhraghuvanshii <[email protected]>
1 parent 29208a0 commit 5f4c2a4

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

src/custom/CollaboratorAvatarGroup/CollaboratorAvatarGroup.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ExpandMore } from '@mui/icons-material';
22
import { MouseEvent, useState } from 'react';
3-
import { Avatar, AvatarGroup, Button, Popover, Typography, Divider } from '../../base';
3+
import { Avatar, AvatarGroup, Button, Divider, Popover, Typography } from '../../base';
44
import { iconSmall } from '../../constants/iconsSizes';
55
import { styled, useTheme } from '../../theme';
66
import { DARK_TEAL_BLUE } from '../../theme/colors/colors';
@@ -144,9 +144,20 @@ const CollaboratorAvatarGroup = ({
144144
return (
145145
<CustomTooltip
146146
key={clientID}
147+
useThemeColors={true} // Enable theme-based colors
147148
title={
148149
<div style={{ display: 'flex', justifyContent: 'center', flexDirection: 'column' }}>
149-
<Typography style={{ display: 'flex', justifyContent: 'center', flexDirection: 'column', margin: 'auto', fontSize: '1rem' }}>{user.name}</Typography>
150+
<Typography
151+
style={{
152+
display: 'flex',
153+
justifyContent: 'center',
154+
flexDirection: 'column',
155+
margin: 'auto',
156+
fontSize: '1rem'
157+
}}
158+
>
159+
{user.name}
160+
</Typography>
150161
<Divider />
151162
<Button
152163
size="small"
@@ -156,7 +167,7 @@ const CollaboratorAvatarGroup = ({
156167
fontSize: '1rem',
157168
padding: '2px 8px',
158169
minWidth: 'auto',
159-
marginTop: '4px'
170+
marginTop: '8px'
160171
}}
161172
>
162173
Open Recents

src/custom/CustomTooltip/customTooltip.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTheme } from '@mui/material/styles';
12
import _ from 'lodash';
23
import React from 'react';
34
import { 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

Comments
 (0)