1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/common/HtmlTooltip/HtmlTooltip.tsx
NicolaeUnleash 23af7a3474
refactor: light theme colors (#3252)
## About the changes
Refactoring the colors for the light theme to be much easier to continue
with dark mode

This is the first step to finish dark mode

https://linear.app/unleash/project/[low][s][alpha]-dark-mode-in-unleash-admin-ui-31b407d13c4b/1

This PR uses `main-theme` as a placeholder for `dark-theme` for now due
to the new changes. Still need to set the correct values here.

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-03-06 12:58:36 +02:00

71 lines
2.0 KiB
TypeScript

import { styled, Tooltip, tooltipClasses, TooltipProps } from '@mui/material';
import { SpacingArgument } from '@mui/system/createTheme/createSpacing';
const StyledHtmlTooltipBody = styled('div')(({ theme }) => ({
overflow: 'auto',
padding: theme.spacing(1, 1.5),
}));
const StyledHtmlTooltip = styled(
({
className,
maxWidth,
maxHeight,
fontSize,
...props
}: IHtmlTooltipProps) => (
<Tooltip
{...props}
title={<StyledHtmlTooltipBody>{props.title}</StyledHtmlTooltipBody>}
classes={{ popper: className }}
/>
),
{
shouldForwardProp: prop =>
prop !== 'maxWidth' && prop !== 'maxHeight' && prop !== 'fontSize',
}
)<{
maxWidth?: SpacingArgument;
maxHeight?: SpacingArgument;
fontSize?: string;
}>(
({
theme,
maxWidth = theme.spacing(37.5),
maxHeight = theme.spacing(37.5),
fontSize = theme.fontSizes.smallerBody,
}) => ({
maxWidth,
[`& .${tooltipClasses.tooltip}`]: {
display: 'flex',
flexDirection: 'column',
backgroundColor: theme.palette.background.paper,
padding: 0,
borderRadius: theme.shape.borderRadiusMedium,
boxShadow: theme.shadows[2],
color: theme.palette.text.primary,
fontWeight: theme.fontWeight.medium,
maxWidth: 'inherit',
border: `1px solid ${theme.palette.divider}`,
maxHeight,
fontSize,
},
[`& .${tooltipClasses.arrow}`]: {
'&:before': {
border: `1px solid ${theme.palette.divider}`,
},
color: theme.palette.background.paper,
},
})
);
export interface IHtmlTooltipProps extends TooltipProps {
maxWidth?: SpacingArgument;
maxHeight?: SpacingArgument;
fontSize?: string;
}
export const HtmlTooltip = (props: IHtmlTooltipProps) => (
<StyledHtmlTooltip {...props}>{props.children}</StyledHtmlTooltip>
);