Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(Tooltip): changed CustomTooltip font #839

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 49 additions & 33 deletions src/custom/CustomTooltip/customTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Tooltip, type TooltipProps } from '@mui/material';
import { Tooltip, Typography, styled, type TooltipProps } from '@mui/material';
import React from 'react';
import { WHITE } from '../../theme';
import { SistentThemeProvider, WHITE } from '../../theme';
import { RenderMarkdownTooltip } from '../Markdown';

type CustomTooltipProps = {
Expand All @@ -13,6 +13,12 @@ type CustomTooltipProps = {
bgColor?: string;
} & Omit<TooltipProps, 'title' | 'onClick'>;

const StyledFontWrapper = styled(Typography)(({ theme }) => ({
...theme.typography.textH2Medium,
fontSize: '1rem',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this variant already has the fontsize in it.

lineHeight: '1.5rem'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why specifying here then?

}));

function CustomTooltip({
title,
onClick,
Expand All @@ -25,39 +31,49 @@ function CustomTooltip({
...props
}: CustomTooltipProps): JSX.Element {
return (
<Tooltip
componentsProps={{
tooltip: {
sx: {
background: bgColor,
color: WHITE,
fontSize: fontSize || (variant === 'standard' ? '1rem' : '0.75rem'),
fontWeight: { fontWeight },
borderRadius: '0.5rem',
padding: variant === 'standard' ? '0.9rem' : '0.5rem 0.75rem',
boxShadow: 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
}
},
popper: {
sx: {
zIndex: 9999999999,
opacity: '1'
}
},
arrow: {
sx: {
color: bgColor
<SistentThemeProvider>
<Tooltip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't required here to wrap this provider.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't wrap this then the theme was not being applied properly and we can't access the correct tokens.

componentsProps={{
tooltip: {
sx: {
background: bgColor,
color: WHITE,
fontSize: fontSize || (variant === 'standard' ? '1rem' : '0.75rem'),
fontWeight: { fontWeight },
borderRadius: '0.5rem',
padding: variant === 'standard' ? '0.9rem' : '0.5rem 0.75rem',
boxShadow: 'rgba(0, 0, 0, 0.6) 0px 4px 10px, rgba(0, 0, 0, 0.5) 0px 2px 4px'
}
},
popper: {
sx: {
zIndex: 9999999999,
opacity: '1'
}
},
arrow: {
sx: {
color: bgColor
}
}
}}
title={
typeof title === 'string' ? (
<StyledFontWrapper>
<RenderMarkdownTooltip content={title} />
</StyledFontWrapper>
) : (
title
)
}
}}
title={typeof title === 'string' ? <RenderMarkdownTooltip content={title} /> : title}
placement={placement}
arrow
onClick={onClick}
{...props}
>
{children}
</Tooltip>
placement={placement}
arrow
onClick={onClick}
{...props}
>
{children}
</Tooltip>
</SistentThemeProvider>
);
}

Expand Down
Loading