2023-01-16 13:04:52 +01:00
|
|
|
import { ReactNode } from 'react';
|
2023-01-19 14:46:26 +01:00
|
|
|
import { Link, LinkProps, styled } from '@mui/material';
|
2023-01-16 13:04:52 +01:00
|
|
|
import { HtmlTooltip, IHtmlTooltipProps } from '../HtmlTooltip/HtmlTooltip';
|
|
|
|
|
|
|
|
const StyledLink = styled(Link, {
|
2023-10-02 14:25:46 +02:00
|
|
|
shouldForwardProp: (prop) => prop !== 'highlighted',
|
2023-01-16 13:04:52 +01:00
|
|
|
})<{ highlighted?: boolean }>(({ theme, highlighted }) => ({
|
|
|
|
backgroundColor: highlighted ? theme.palette.highlight : 'transparent',
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
textDecorationColor: theme.palette.text.disabled,
|
|
|
|
textDecorationStyle: 'dashed',
|
|
|
|
textUnderlineOffset: theme.spacing(0.5),
|
|
|
|
}));
|
|
|
|
|
|
|
|
interface ITooltipLinkProps extends LinkProps {
|
|
|
|
tooltip: ReactNode;
|
|
|
|
highlighted?: boolean;
|
|
|
|
tooltipProps?: Omit<IHtmlTooltipProps, 'title' | 'children'>;
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const TooltipLink = ({
|
|
|
|
tooltip,
|
|
|
|
highlighted,
|
|
|
|
tooltipProps,
|
|
|
|
children,
|
|
|
|
...props
|
|
|
|
}: ITooltipLinkProps) => (
|
2023-01-19 14:46:26 +01:00
|
|
|
<HtmlTooltip title={tooltip} {...tooltipProps} arrow>
|
2023-03-15 13:22:06 +01:00
|
|
|
<StyledLink tabIndex={0} highlighted={highlighted} {...props}>
|
2023-01-16 13:04:52 +01:00
|
|
|
{children}
|
|
|
|
</StyledLink>
|
|
|
|
</HtmlTooltip>
|
|
|
|
);
|