Skip to content

Commit 520b26a

Browse files
improve code for all components
Signed-off-by: saurabhraghuvanshii <saurabhsraghuvanshi@gmail.com>
1 parent 22f2491 commit 520b26a

4 files changed

Lines changed: 61 additions & 43 deletions

File tree

src/custom/CollaboratorAvatarGroup/CollaboratorAvatarGroup.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,20 @@ const CollaboratorAvatarGroup = ({
144144
return (
145145
<CustomTooltip
146146
key={clientID}
147+
componentsProps={{
148+
tooltip: {
149+
sx: {
150+
background: theme.palette.background.paper,
151+
color: theme.palette.text.primary,
152+
boxShadow: theme.shadows[4]
153+
}
154+
},
155+
arrow: {
156+
sx: {
157+
color: theme.palette.background.paper
158+
}
159+
}
160+
}}
147161
title={
148162
<div style={{ display: 'flex', justifyContent: 'center', flexDirection: 'column' }}>
149163
<Typography

src/custom/CustomTooltip/customTooltip.tsx

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import _ from 'lodash';
12
import React from 'react';
23
import { Tooltip, TooltipProps } from '../../base';
3-
import { useTheme } from '../../theme';
4+
import { WHITE } from '../../theme';
45
import { RenderMarkdownTooltip } from '../Markdown';
56

67
type CustomTooltipProps = {
@@ -10,6 +11,7 @@ type CustomTooltipProps = {
1011
fontSize?: string;
1112
fontWeight?: number;
1213
variant?: 'standard' | 'small';
14+
bgColor?: string;
1315
componentsProps?: TooltipProps['componentsProps'];
1416
} & Omit<TooltipProps, 'title' | 'onClick'>;
1517

@@ -21,41 +23,42 @@ function CustomTooltip({
2123
fontSize,
2224
fontWeight = 400,
2325
variant = 'standard',
26+
bgColor = '#141414',
2427
componentsProps = {},
2528
...props
2629
}: CustomTooltipProps): JSX.Element {
27-
const theme = useTheme();
28-
2930
return (
3031
<Tooltip
3132
enterTouchDelay={0}
3233
leaveTouchDelay={2000}
33-
componentsProps={{
34-
tooltip: {
35-
sx: {
36-
background: theme.palette.background.paper,
37-
color: theme.palette.text.primary,
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: theme.shadows[4]
44-
}
45-
},
46-
popper: {
47-
sx: {
48-
zIndex: 9999999999,
49-
opacity: '1'
50-
}
51-
},
52-
arrow: {
53-
sx: {
54-
color: theme.palette.background.paper
34+
componentsProps={_.merge(
35+
{
36+
tooltip: {
37+
sx: {
38+
background: bgColor,
39+
color: WHITE,
40+
maxWidth: '600px',
41+
fontSize: fontSize || (variant === 'standard' ? '1rem' : '0.75rem'),
42+
fontWeight: { fontWeight },
43+
borderRadius: '0.5rem',
44+
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'
46+
}
47+
},
48+
popper: {
49+
sx: {
50+
zIndex: 9999999999,
51+
opacity: '1'
52+
}
53+
},
54+
arrow: {
55+
sx: {
56+
color: bgColor
57+
}
5558
}
5659
},
57-
...componentsProps
58-
}}
60+
componentsProps
61+
)}
5962
title={typeof title === 'string' ? <RenderMarkdownTooltip content={title} /> : title}
6063
placement={placement}
6164
arrow

src/custom/Markdown/style.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const StyledMarkdownP = styled('p')(({ theme }) => ({
2727
}));
2828

2929
export const StyledMarkdownTooltipP = styled('p')(({ theme }) => ({
30-
color: theme.palette.text.primary,
30+
color: theme.palette.text.constant?.white || '#ffffff',
3131
marginBlock: '0px',
3232
fontFamily: 'inherit'
3333
}));

src/theme/theme.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Interactiveness, PaletteMode, createTheme } from '@mui/material';
2+
import _ from 'lodash';
23
import { components } from './components';
34
import { darkModePalette, lightModePalette } from './palette';
45
import { typography } from './typography';
5-
import _ from 'lodash';
66

77
export const drawerWidth = 240;
88

@@ -11,22 +11,23 @@ export const createCustomTheme = (mode: PaletteMode, brandPalette?: Interactiven
1111

1212
console.log('Creating theme with mode:', mode, 'and brandPalette:', brandPalette);
1313

14-
const customBrandedTheme = brandPalette ? {
15-
primary: {
16-
main: brandPalette.default ,
17-
secondary: brandPalette.hover,
18-
},
19-
secondary: {
20-
main: brandPalette.secondary,
21-
secondary: brandPalette.secondary,
22-
},
23-
background: {
24-
brand: brandPalette
25-
}
26-
} : {};
14+
const customBrandedTheme = brandPalette
15+
? {
16+
primary: {
17+
main: brandPalette.default,
18+
secondary: brandPalette.hover,
19+
},
20+
secondary: {
21+
main: brandPalette.secondary,
22+
secondary: brandPalette.secondary,
23+
},
24+
background: {
25+
brand: brandPalette
26+
}
27+
}
28+
: {};
2729

2830
const themePalette = _.merge({}, basePalette, customBrandedTheme);
29-
3031

3132
return createTheme({
3233
palette: {

0 commit comments

Comments
 (0)